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