public function testEncode_2Questions1Archived_DtoCorrect1ArchivedQuestion()
 {
     $environ = new MongoTestEnvironment();
     $environ->clean();
     $userId = $environ->createUser("User", "Name", "*****@*****.**");
     $user = new UserModel($userId);
     $user->role = SystemRoles::USER;
     $project = $environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $project->addUser($userId, ProjectRoles::MANAGER);
     $user->addProject($projectId);
     $user->write();
     $project->write();
     $text = new TextModel($project);
     $text->title = "Text Title";
     $textId = $text->write();
     $question1 = new QuestionModel($project);
     $question1->title = "Some Title";
     $question1->textRef->id = $textId;
     $question1->write();
     $question2 = new QuestionModel($project);
     $question2->title = "Archived Title";
     $question2->textRef->id = $textId;
     $question2->isArchived = true;
     $question2->write();
     $dto = TextSettingsDto::encode($projectId, $textId, $userId);
     $this->assertInternalType('array', $dto['text']);
     $this->assertEquals($textId, $dto['text']['id']);
     $this->assertEquals('Text Title', $dto['text']['title']);
     $this->assertInternalType('array', $dto['archivedQuestions']);
     $this->assertCount(1, $dto['archivedQuestions']);
     $this->assertEquals('Archived Title', $dto['archivedQuestions'][0]['title']);
     $this->assertTrue(count($dto['rights']) > 0, "No rights in dto");
     $this->assertEquals('settings', $dto['bcs']['op']);
     $this->assertEquals(array('id' => $projectId, 'crumb' => SF_TESTPROJECT), $dto['bcs']['project']);
 }
Пример #2
0
 public function text_settings_dto($textId)
 {
     return TextSettingsDto::encode($this->projectId, $textId, $this->userId);
 }