Esempio n. 1
0
 /**
  * Add user in a group
  *
  * @param mixed Group
  */
 public function addGroup($group)
 {
     if (is_numeric($group)) {
         $groups = new USVN_Db_Table_Groups();
         $group = $groups->find($group)->current();
     }
     $group->addUser($this);
 }
Esempio n. 2
0
 public function testfetchAllAssignedTwoUserInGroup()
 {
     $table_user = new USVN_Db_Table_Users();
     $user = $table_user->fetchNew();
     $user->setFromArray(array('users_login' => 'test', 'users_password' => 'password', 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**'));
     $user->save();
     $user2 = $table_user->fetchNew();
     $user2->setFromArray(array('users_login' => 'test2', 'users_password' => 'password', 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**'));
     $user2->save();
     $table_project = new USVN_Db_Table_Projects();
     $project = $table_project->fetchNew();
     $project->setFromArray(array('projects_name' => 'InsertProjectOk', 'projects_start_date' => '1984-12-03 00:00:00'));
     $project->save();
     $project2 = $table_project->fetchNew();
     $project2->setFromArray(array('projects_name' => 'Project2', 'projects_start_date' => '1984-12-03 00:00:00'));
     $project2->save();
     $group_table = new USVN_Db_Table_Groups();
     $group_table->insert(array("groups_id" => 2, "groups_name" => "toto"));
     $group = $group_table->find(2)->current();
     $group_table = new USVN_Db_Table_Groups();
     $group_table->insert(array("groups_id" => 3, "groups_name" => "titi"));
     $group = $group_table->find(3)->current();
     $project->addGroup($group);
     $this->assertEquals(count($table_project->fetchAllAssignedTo($user)), 0);
     $group->addUser($user);
     $group->addUser($user2);
     $this->assertEquals(count($table_project->fetchAllAssignedTo($user)), 1);
 }
Esempio n. 3
0
 public function testFindUserInGroup()
 {
     $test = $this->createUser("test");
     $babar = $this->createUser("babar");
     $john = $this->createUser("john");
     $group = $this->createGroup("toto");
     $user_groups = new USVN_Db_Table_UsersToGroups();
     $user_groups->insert(array("groups_id" => $group->id, "users_id" => $test->id, "is_leader" => false));
     $user_groups->insert(array("groups_id" => $group->id, "users_id" => $babar->id, "is_leader" => false));
     $group_table = new USVN_Db_Table_Groups();
     $group = $group_table->find($test->id)->current();
     $users = $group->findManyToManyRowset('USVN_Db_Table_Users', 'USVN_Db_Table_UsersToGroups');
     $res = array();
     foreach ($users as $user) {
         array_push($res, $user->users_login);
     }
     $this->assertContains("test", $res);
     $this->assertContains("babar", $res);
     $this->assertNotContains("john", $res);
 }
Esempio n. 4
0
 public function test_edit()
 {
     $groups = new USVN_Db_Table_Groups();
     $group = $groups->find(43)->current();
     $group->addUser($this->user);
     $this->request->setParam('name', 'Indochine');
     $this->runAction('edit');
     $this->assertEquals(2, count($this->controller->view->users));
     $this->assertContains('Indochine', $this->getBody(), $this->getBody());
 }