コード例 #1
0
 /**
  * @depends testRemoveUsers_ProjectOwner_NotRemovedFromProject
  */
 public function testRemoveUsers_ProjectOwner_NotRemovedFromProject_RestoreErrorDisplay()
 {
     // restore error display after last test
     self::$environ->restoreErrorDisplay();
     // read from disk
     $sameProject = new ProjectModel(self::$save['projectId']);
     $sameUser1 = new UserModel(self::$save['user1Id']);
     $sameUser2 = new UserModel(self::$save['user2Id']);
     // project still has project owner
     $this->assertEquals(1, $sameProject->listUsers()->count);
     $this->assertEquals(0, $sameUser1->listProjects(self::$environ->website->domain)->count);
     $this->assertEquals(1, $sameUser2->listProjects(self::$environ->website->domain)->count);
 }
コード例 #2
0
 public function testProjectListUsers_TwoUsers_ListHasDetails()
 {
     $environ = new MongoTestEnvironment();
     $userId1 = $environ->createUser('user1', 'User One', '*****@*****.**');
     $um1 = new UserModel($userId1);
     $userId2 = $environ->createUser('user2', 'User Two', '*****@*****.**');
     $um2 = new UserModel($userId2);
     $project = $environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     // Check the list users is empty
     $result = $project->listUsers();
     $this->assertEquals(0, $result->count);
     $this->assertEquals([], $result->entries);
     // Add our two users
     $project->addUser($userId1, ProjectRoles::CONTRIBUTOR);
     $um1->addProject($projectId);
     $um1->write();
     $project->addUser($userId2, ProjectRoles::CONTRIBUTOR);
     $um2->addProject($projectId);
     $um2->write();
     $project->write();
     $otherProject = new ProjectModel($projectId);
     $result = $otherProject->listUsers();
     $this->assertEquals(2, $result->count);
     $this->assertEquals([['email' => '*****@*****.**', 'name' => 'User One', 'username' => 'user1', 'id' => $userId1, 'role' => ProjectRoles::CONTRIBUTOR], ['email' => '*****@*****.**', 'name' => 'User Two', 'username' => 'user2', 'id' => $userId2, 'role' => ProjectRoles::CONTRIBUTOR]], $result->entries);
 }
コード例 #3
0
 public function testCreateSimple_CreateUser_PasswordAndJoinProject()
 {
     self::$environ->clean();
     // setup parameters: username and project
     $userName = '******';
     $project = self::$environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $currentUserId = self::$environ->createUser('test1', 'test1', '*****@*****.**');
     // create user
     $dto = UserCommands::createSimple($userName, $projectId, $currentUserId, self::$environ->website);
     // read from disk
     $user = new UserModel($dto['id']);
     $sameProject = new ProjectModel($projectId);
     // user created and password created, user joined to project
     $this->assertEquals('username', $user->username);
     $this->assertEquals(4, strlen($dto['password']));
     $projectUser = $sameProject->listUsers()->entries[0];
     $this->assertEquals('username', $projectUser['username']);
     $userProject = $user->listProjects(self::$environ->website->domain)->entries[0];
     $this->assertEquals(SF_TESTPROJECT, $userProject['projectName']);
 }
コード例 #4
0
 /**
  * markUnreadForProjectMembers() is only intended to be called from a child class such as UnreadActivityModel
  * @param string $itemId
  * @param ProjectModel $project
  * @param string $questionId
  * @param string $exceptThisUserId
  * @throws \Exception
  */
 public static function markUnreadForProjectMembers($itemId, $project, $questionId = '', $exceptThisUserId = '')
 {
     $className = get_called_class();
     if ($className == 'Api\\Model\\UserUnreadModel') {
         throw new \Exception("static method markUnreadForProject cannot be called from base class UserUnreadModel");
     }
     $userList = $project->listUsers();
     foreach ($userList->entries as $user) {
         if ($user['id'] == $exceptThisUserId) {
             continue;
         }
         // TODO: Review: This code is getting cumbersome with if statements for specific child classes.  Maybe it's time to move this method to the child classes - cjh 2013/10
         if ($questionId != '') {
             $unreadModel = new $className($user['id'], $project->id->asString(), $questionId);
         } else {
             $unreadModel = new $className($user['id'], $project->id->asString());
         }
         /** @var UserUnreadModel $unreadModel */
         $unreadModel->markUnread($itemId);
         $unreadModel->write();
     }
 }