public function testuserCanAccessMethod_unknownMethodName_Exception() { $userId = $this->environ->createUser('user', 'user', '*****@*****.**', SystemRoles::USER); $rh = new RightsHelper($userId, null, $this->environ->website); $this->environ->inhibitErrorDisplay(); $this->expectException(); $result = $rh->userCanAccessMethod($userId, 'bogusMethodName', array()); // nothing runs in the current test function after an exception. IJH 2014-11 }
public function testEncode_ArchivedText_ManagerCanViewContributorCannot() { $project = $this->environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $managerId = $this->environ->createUser("manager", "manager", "*****@*****.**"); $contributorId = $this->environ->createUser("contributor1", "contributor1", "*****@*****.**"); $project->addUser($managerId, ProjectRoles::MANAGER); $project->addUser($contributorId, ProjectRoles::CONTRIBUTOR); $project->write(); // Question not archived but Text is archived $text = new TextModel($project); $text->title = "Text 1"; $text->isArchived = true; $textId = $text->write(); $question = new QuestionModel($project); $question->title = "the question"; $question->description = "question description"; $question->textRef->id = $textId; $questionId = $question->write(); $dto = QuestionCommentDto::encode($project->id->asString(), $questionId, $managerId); // Manager can view Question of archived Text $this->assertEqual($dto['question']['title'], 'the question'); // Contributor cannot view Question of archived Text, throw Exception $this->environ->inhibitErrorDisplay(); $this->expectException(); $dto = QuestionCommentDto::encode($project->id->asString(), $questionId, $contributorId); // nothing runs in the current test function after an exception. IJH 2014-11 }
public function testRemoveUsers_ProjectOwner_NotRemovedFromProject() { $this->environ->clean(); // setup project and users. user1 is the project owner $project = $this->environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $projectId = $project->id->asString(); $user1Id = $this->environ->createUser("user1name", "User1 Name", "*****@*****.**"); $user2Id = $this->environ->createUser("user2name", "User2 Name", "*****@*****.**"); $user1 = new UserModel($user1Id); $user2 = new UserModel($user2Id); $project->addUser($user1->id->asString(), ProjectRoles::CONTRIBUTOR); $project->addUser($user2->id->asString(), ProjectRoles::CONTRIBUTOR); $project->ownerRef = $user2Id; $project->write(); $user1->addProject($project->id->asString()); $user1->write(); $user2->addProject($project->id->asString()); $user2->write(); // save data for rest of this test $this->save['projectId'] = $projectId; $this->save['user1Id'] = $user1Id; $this->save['user2Id'] = $user2Id; // remove users from project. user1 still remains as project owner $userIds = array($user1->id->asString(), $user2->id->asString()); $this->expectException(); $this->environ->inhibitErrorDisplay(); ProjectCommands::removeUsers($projectId, $userIds); // nothing runs in the current test function after an exception. IJH 2014-11 }
public function testUpdateFromRegistration_ExpiredKey_UserNotUpdatedAndKeyConsumed() { $this->environ->clean(); $user = new UserModel(); $user->emailPending = '*****@*****.**'; $key = $user->setValidation(1); $date = $user->validationExpirationDate; $date->sub(new DateInterval('P2D')); $user->validationExpirationDate = $date; $userId = $user->write(); // save data for rest of this test $this->save['userId'] = $userId; $userArray = array('id' => '', 'username' => 'joe', 'name' => 'joe user', 'password' => 'password'); $this->environ->inhibitErrorDisplay(); $this->expectException(); UserCommands::updateFromRegistration($key, $userArray, $this->environ->website); // nothing runs in the current test function after an exception. IJH 2014-11 }
public function testEncode_ArchivedText_ManagerCanViewContributorCannot() { $project = $this->environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $projectId = $project->id->asString(); // archived Text $text = new TextModel($project); $text->title = "Chapter 3"; $text->isArchived = true; $textId = $text->write(); // Answers are tied to specific users, so let's create some sample users $managerId = $this->environ->createUser("jcarter", "John Carter", "*****@*****.**"); $contributorId = $this->environ->createUser("dthoris", "Dejah Thoris", "*****@*****.**"); $project->addUser($managerId, ProjectRoles::MANAGER); $project->addUser($contributorId, ProjectRoles::CONTRIBUTOR); $project->write(); $dto = QuestionListDto::encode($projectId, $textId, $managerId); // Manager can view archived Text $this->assertEqual($dto['text']['title'], "Chapter 3"); // Contributor cannot view archived Text, throw Exception $this->environ->inhibitErrorDisplay(); $this->expectException(); $dto = QuestionListDto::encode($projectId, $textId, $contributorId); // nothing runs in the current test function after an exception. IJH 2014-11 }