$testProjectModel->allowInviteAFriend = $constants['testProjectAllowInvites'];
$testProjectModel->write();
$otherProject = ProjectCommands::createProject($constants['otherProjectName'], $constants['otherProjectCode'], $projectType, $managerUserId, $website);
$otherProjectModel = new ProjectModel($otherProject);
$otherProjectModel->projectCode = $constants['otherProjectCode'];
$otherProjectModel->allowInviteAFriend = $constants['otherProjectAllowInvites'];
$otherProjectModel->write();
ProjectCommands::updateUserRole($testProject, $managerUserId, ProjectRoles::MANAGER);
ProjectCommands::updateUserRole($testProject, $memberUserId, ProjectRoles::CONTRIBUTOR);
ProjectCommands::updateUserRole($testProject, $resetUserId, ProjectRoles::CONTRIBUTOR);
ProjectCommands::updateUserRole($otherProject, $adminUserId, ProjectRoles::MANAGER);
if ($site == 'scriptureforge') {
    $text1 = TextCommands::updateText($testProject, array('id' => '', 'title' => $constants['testText1Title'], 'content' => $constants['testText1Content']));
    $text2 = TextCommands::updateText($testProject, array('id' => '', 'title' => $constants['testText2Title'], 'content' => $constants['testText2Content']));
    $question1 = QuestionCommands::updateQuestion($testProject, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question1Title'], 'description' => $constants['testText1Question1Content']));
    $question2 = QuestionCommands::updateQuestion($testProject, array('id' => '', 'textRef' => $text1, 'title' => $constants['testText1Question2Title'], 'description' => $constants['testText1Question2Content']));
    $template1 = QuestionTemplateCommands::updateTemplate($testProject, array('id' => '', 'title' => 'first template', 'description' => 'not particularly interesting'));
    $template2 = QuestionTemplateCommands::updateTemplate($testProject, array('id' => '', 'title' => 'second template', 'description' => 'not entirely interesting'));
    $answer1 = QuestionCommands::updateAnswer($testProject, $question1, array('id' => '', 'content' => $constants['testText1Question1Answer']), $managerUserId);
    $answer1Id = array_keys($answer1)[0];
    $answer2 = QuestionCommands::updateAnswer($testProject, $question2, array('id' => '', 'content' => $constants['testText1Question2Answer']), $managerUserId);
    $answer2Id = array_keys($answer2)[0];
    $comment1 = QuestionCommands::updateComment($testProject, $question1, $answer1Id, array('id' => '', 'content' => $constants['testText1Question1Answer1Comment']), $managerUserId);
    $comment2 = QuestionCommands::updateComment($testProject, $question2, $answer2Id, array('id' => '', 'content' => $constants['testText1Question2Answer2Comment']), $managerUserId);
} elseif ($site == 'languageforge') {
    // Set up LanguageForge E2E test envrionment here
    $testProjectModel = new LexiconProjectModel($testProject);
    $testProjectModel->addInputSystem("th-fonipa", "tipa", "Thai");
    $testProjectModel->config->entry->fields[LexiconConfigObj::LEXEME]->inputSystems[] = 'th-fonipa';
    $testProjectId = $testProjectModel->write();
    // setup to mimic file upload
Example #2
0
 public function question_update($object)
 {
     return QuestionCommands::updateQuestion($this->_projectId, $object);
 }
 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));
 }