public function testDeleteTexts_NoThrow() { $project = self::$environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $text = new TextModel($project); $text->title = 'Some Title'; $text->write(); TextCommands::deleteTexts($project->id->asString(), array($text->id->asString())); }
public function testTextCRUD_CRUDOK() { $projectId = self::$environ->makeProject(); $project = new ProjectModel($projectId); $userId = self::$environ->getProjectMember($projectId, 'user1'); // Initial List $result = self::$environ->fixJson(ProjectPageDto::encode($projectId, $userId)); $count = count($result['texts']); // Create $model = array('id' => '', 'title' => 'SomeText'); $id = TextCommands::updateText($projectId, $model); $this->assertNotNull($id); $this->assertEquals(24, strlen($id)); // Read $result = self::$environ->fixJson(TextCommands::readText($projectId, $id)); $this->assertNotNull($result['id']); $this->assertEquals('SomeText', $result['title']); // Update $result['title'] = 'OtherText'; $id = TextCommands::updateText($projectId, $result); $this->assertNotNull($id); $this->assertEquals($result['id'], $id); // Read back $result = self::$environ->fixJson(TextCommands::readText($projectId, $id)); $this->assertEquals('OtherText', $result['title']); // List $result = self::$environ->fixJson(ProjectPageDto::encode($projectId, $userId)); $this->assertCount($count + 1, $result['texts']); // Delete $result = TextCommands::deleteTexts($projectId, array($id)); $this->assertTrue($result > 0); // List to confirm delete $result = self::$environ->fixJson(ProjectPageDto::encode($projectId, $userId)); $this->assertCount($count, $result['texts']); // Clean up after ourselves ProjectCommands::deleteProjects(array($projectId), $project->ownerRef->asString()); }