Пример #1
0
 public function text_read($textId)
 {
     return TextCommands::readText($this->_projectId, $textId);
 }
Пример #2
0
 public function testTextCRUD_CRUDOK()
 {
     $e = new ApiCrudTestEnvironment();
     $projectId = $e->makeProject();
     $userId = $e->getProjectMember($projectId, 'user1');
     // Initial List
     $result = $e->json(ProjectPageDto::encode($projectId, $userId));
     $count = count($result['texts']);
     // Create
     $model = array('id' => '', 'title' => 'SomeText');
     $id = TextCommands::updateText($projectId, $model);
     $this->assertNotNull($id);
     $this->assertEqual(24, strlen($id));
     // Read
     $result = $e->json(TextCommands::readText($projectId, $id));
     $this->assertNotNull($result['id']);
     $this->assertEqual('SomeText', $result['title']);
     // Update
     $result['title'] = 'OtherText';
     $id = TextCommands::updateText($projectId, $result);
     $this->assertNotNull($id);
     $this->assertEqual($result['id'], $id);
     // Read back
     $result = $e->json(TextCommands::readText($projectId, $id));
     $this->assertEqual('OtherText', $result['title']);
     // List
     $result = $e->json(ProjectPageDto::encode($projectId, $userId));
     $this->assertEqual($count + 1, count($result['texts']));
     // Delete
     $result = TextCommands::deleteTexts($projectId, array($id));
     $this->assertTrue($result);
     // List to confirm delete
     $result = $e->json(ProjectPageDto::encode($projectId, $userId));
     $this->assertEqual($count, count($result['texts']));
     // Clean up after ourselves
     ProjectCommands::deleteProjects(array($projectId));
 }