コード例 #1
0
 public function testEncode_ProjectWithUser_DtoCorrect()
 {
     $e = new MongoTestEnvironment();
     $e->clean();
     $userId = $e->createUser("User", "Name", "*****@*****.**");
     $user = new UserModel($userId);
     $user->role = SystemRoles::USER;
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $project->addUser($userId, ProjectRoles::CONTRIBUTOR);
     $user->addProject($projectId);
     $user->write();
     $project->write();
     $dto = ManageUsersDto::encode($projectId);
     $this->assertEqual($dto['userCount'], 1);
     $this->assertIsA($dto['users'], 'array');
     $this->assertEqual($dto['users'][0]['id'], $userId);
     $this->assertEqual($dto['users'][0]['name'], 'Name');
     $this->assertEqual($dto['users'][0]['role'], ProjectRoles::CONTRIBUTOR);
 }
コード例 #2
0
 /**
  * List users in the project
  * @param string $projectId
  * @return array - the DTO array
  */
 public static function usersDto($projectId)
 {
     CodeGuard::checkTypeAndThrow($projectId, 'string');
     CodeGuard::checkNotFalseAndThrow($projectId, '$projectId');
     $usersDto = ManageUsersDto::encode($projectId);
     return $usersDto;
 }