public function itverifiesUserGroupMembersAreProjectMembersWhenProjectIsPrivate() { $user1 = mock('PFUser'); $user1->setReturnValue('getUserName', 'user1'); $user2 = mock('PFUser'); $user2->setReturnValue('getUserName', 'user2'); $project = new MockProject($this); $project->setReturnValue('getMembers', array($user2)); $project->setReturnValue('isPublic', false); $usergroup_dao = new MockUGroupDao(); $usergroup_dao->setReturnValue('searchByGroupId', array(array('name' => 'Perms'))); $this->backend->setReturnValue('getUGroupDao', $usergroup_dao); $ugroup = new MockProjectUGroup($this); $ugroup->setReturnValue('getMembers', array($user1, $user2)); $ugroup->setReturnValue('getName', 'Perms'); $this->backend->setReturnValue('getUGroupFromRow', $ugroup); $ugroup_members_line = $this->backend->getSVNAccessUserGroupMembers($project); $this->assertEqual($ugroup_members_line, "Perms = user2\n\n"); }
function testUgroupCountNonAdminForStaticUgroupsMixed() { $this->skipUnless(MOCKFUNCTION_AVAILABLE, "Function mocking not available"); if (MOCKFUNCTION_AVAILABLE) { $uGroup = new MockProjectUGroup(); $uGroup->setReturnValue('exists', true, array(1, 1)); $uGroup->setReturnValue('exists', true, array(1, 2)); $uGroup->setReturnValue('exists', true, array(1, 3)); $uGroup->setReturnValue('exists', true, array(1, 4)); MockFunction::generate('ugroup_get_ugroup'); MockFunction::setReturnValue('ugroup_get_ugroup', $uGroup); MockFunction::generate('ugroup_count_project_admins'); MockFunction::setReturnValueAt(0, 'ugroup_count_project_admins', array('admins' => 0, 'non_admins' => 2)); MockFunction::setReturnValueAt(1, 'ugroup_count_project_admins', array('admins' => 1, 'non_admins' => 3)); MockFunction::expectCallCount('ugroup_count_project_admins', 2); $validUGroups = array(1, 2); $this->assertEqual(3, ugroup_count_non_admin_for_static_ugroups(1, array(3, 4), $validUGroups)); $this->assertEqual(array(1, 2, 4), $validUGroups); MockFunction::restore('ugroup_count_project_admins'); } }