Пример #1
0
 public function question_read($questionId)
 {
     return QuestionCommands::readQuestion($this->_projectId, $questionId);
 }
Пример #2
0
 public function testQuestionCRUD_CRUDOK()
 {
     $e = new ApiCrudTestEnvironment();
     // create project
     $projectId = $e->makeProject();
     // create an user and add to the project
     $userId = $e->getProjectMember($projectId, 'user1');
     // create text
     $textId = $e->makeText($projectId, "test text 1");
     // List
     $dto = $e->json(QuestionListDto::encode($projectId, $textId, $userId));
     $this->assertEqual($dto['count'], 0);
     // Create
     $model = array('id' => '', 'title' => 'SomeQuestion', 'description' => 'SomeDescription', 'textRef' => $textId);
     $questionId = QuestionCommands::updateQuestion($projectId, $model);
     $this->assertNotNull($questionId);
     $this->assertEqual(24, strlen($questionId));
     // Read
     $result = $e->json(QuestionCommands::readQuestion($projectId, $questionId));
     $this->assertNotNull($result['id']);
     $this->assertEqual('SomeQuestion', $result['title']);
     // Update
     $result['title'] = 'OtherQuestion';
     $id = QuestionCommands::updateQuestion($projectId, $result);
     $this->assertNotNull($id);
     $this->assertEqual($result['id'], $id);
     // Read back
     $result = $e->json(QuestionCommands::readQuestion($projectId, $questionId));
     $this->assertEqual('OtherQuestion', $result['title']);
     // List
     $dto = $e->json(QuestionListDto::encode($projectId, $textId, $userId));
     $this->assertEqual(1, $dto['count']);
     // Delete
     $result = QuestionCommands::deleteQuestions($projectId, array($questionId));
     $this->assertTrue($result);
     // List to confirm delete
     $dto = $e->json(QuestionListDto::encode($projectId, $textId, $userId));
     $this->assertEqual(0, $dto['count']);
     // Clean up after ourselves
     ProjectCommands::deleteProjects(array($projectId));
 }