$fourthProjectId = ProjectCommands::createProject($constants['fourthProjectName'], $constants['fourthProjectCode'], $projectType, $managerUserId, $website); $fourthProjectModel = new ProjectModel($fourthProjectId); $fourthProjectModel->projectCode = $constants['fourthProjectCode']; $fourthProjectModel->allowInviteAFriend = $constants['fourthProjectAllowInvites']; $fourthProjectModel->write(); $srProject = array('identifier' => $constants['srIdentifier'], 'name' => $constants['srName'], 'repository' => 'http://public.languagedepot.org', 'role' => 'manager'); $srTestProjectId = ProjectCommands::createProject($constants['srProjectName'], $constants['srProjectCode'], $projectType, $managerUserId, $website, $srProject); ProjectCommands::updateUserRole($testProjectId, $managerUserId, ProjectRoles::MANAGER); ProjectCommands::updateUserRole($testProjectId, $memberUserId, ProjectRoles::CONTRIBUTOR); ProjectCommands::updateUserRole($testProjectId, $resetUserId, ProjectRoles::CONTRIBUTOR); ProjectCommands::updateUserRole($otherProjectId, $adminUserId, ProjectRoles::MANAGER); ProjectCommands::updateUserRole($fourthProjectId, $adminUserId, ProjectRoles::MANAGER); ProjectCommands::updateUserRole($srTestProjectId, $adminUserId, ProjectRoles::MANAGER); if ($site == 'scriptureforge') { $text1 = TextCommands::updateText($testProjectId, array('id' => '', 'title' => $constants['testText1Title'], 'content' => $constants['testText1Content'])); $text2 = TextCommands::updateText($testProjectId, array('id' => '', 'title' => $constants['testText2Title'], 'content' => $constants['testText2Content'])); $question1 = QuestionCommands::updateQuestion($testProjectId, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question1Title'], 'description' => $constants['testText1Question1Content'])); $question2 = QuestionCommands::updateQuestion($testProjectId, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question2Title'], 'description' => $constants['testText1Question2Content'])); $template1 = QuestionTemplateCommands::updateTemplate($testProjectId, array('id' => '', 'title' => 'first template', 'description' => 'not particularly interesting')); $template2 = QuestionTemplateCommands::updateTemplate($testProjectId, array('id' => '', 'title' => 'second template', 'description' => 'not entirely interesting')); $answer1 = QuestionCommands::updateAnswer($testProjectId, $question1, array('id' => '', 'content' => $constants['testText1Question1Answer']), $managerUserId); $answer1Id = array_keys($answer1)[0]; $answer2 = QuestionCommands::updateAnswer($testProjectId, $question2, array('id' => '', 'content' => $constants['testText1Question2Answer']), $managerUserId); $answer2Id = array_keys($answer2)[0]; $comment1 = QuestionCommands::updateComment($testProjectId, $question1, $answer1Id, array('id' => '', 'content' => $constants['testText1Question1Answer1Comment']), $managerUserId); $comment2 = QuestionCommands::updateComment($testProjectId, $question2, $answer2Id, array('id' => '', 'content' => $constants['testText1Question2Answer2Comment']), $managerUserId); } elseif ($site == 'languageforge') { // Set up LanguageForge E2E test envrionment here ProjectCommands::updateUserRole($testProjectId, $observerUserId, LexRoles::OBSERVER); $testProjectModel = new LexProjectModel($testProjectId); $testProjectModel->addInputSystem('th-fonipa', 'tipa', 'Thai');
public function text_update($object) { return TextCommands::updateText($this->projectId, $object); }
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()); }