コード例 #1
0
ファイル: User.php プロジェクト: jiangti/usvn
 /**
  * Get all groups associated with $project for this user
  *
  * Project can be the project name as a string or a project row.
  *
  * @param string|USVN_Db_Table_Row_Project $project
  * @return Zend_Db_Table_Rowset
  */
 public function getAllGroupsFor($project)
 {
     if (!is_object($project)) {
         $projects = new USVN_Db_Table_Projects();
         $project = $projects->findByName($project);
     }
     $groups = new USVN_Db_Table_Groups();
     return $groups->fetchAllForUserAndProject($this, $project);
 }
コード例 #2
0
ファイル: GroupsTest.php プロジェクト: phpscr/usvn
 function testFetchAllForUserAndProject()
 {
     $group1 = $this->createGroup("group1");
     $group2 = $this->createGroup("group2");
     $group3 = $this->createGroup("group3");
     $group4 = $this->createGroup("group4");
     $user1 = $this->createUser("user1");
     $user1->addGroup($group1);
     $user1->addGroup($group2);
     $user1->addGroup($group4);
     $user2 = $this->createUser("user2");
     $user2->addGroup($group1);
     $user2->addGroup($group3);
     $user2->addGroup($group4);
     $proj1 = $this->createProject("proj1");
     $proj1->addGroup($group1);
     $proj1->addGroup($group3);
     $proj2 = $this->createProject("proj2");
     $proj2->addGroup($group2);
     $proj2->addGroup($group4);
     $table = new USVN_Db_Table_Groups();
     $groups = $table->fetchAllForUserAndProject($user1, $proj1);
     $res = array();
     foreach ($groups as $group) {
         array_push($res, $group->name);
     }
     $this->assertContains("group1", $res);
     $this->assertNotContains("group2", $res);
     $this->assertNotContains("group3", $res);
     $this->assertNotContains("group4", $res);
     $groups = $table->fetchAllForUserAndProject($user1, $proj2);
     $res = array();
     foreach ($groups as $group) {
         array_push($res, $group->name);
     }
     $this->assertContains("group2", $res);
     $this->assertContains("group4", $res);
     $this->assertNotContains("group1", $res);
     $this->assertNotContains("group3", $res);
     $groups = $table->fetchAllForUserAndProject($user2, $proj1);
     $res = array();
     foreach ($groups as $group) {
         array_push($res, $group->name);
     }
     $this->assertContains("group1", $res);
     $this->assertContains("group3", $res);
     $this->assertNotContains("group2", $res);
     $this->assertNotContains("group4", $res);
     $groups = $table->fetchAllForUserAndProject($user2, $proj2);
     $res = array();
     foreach ($groups as $group) {
         array_push($res, $group->name);
     }
     $this->assertContains("group4", $res);
     $this->assertNotContains("group1", $res);
     $this->assertNotContains("group2", $res);
     $this->assertNotContains("group3", $res);
 }