$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
    $fileName = $constants['testEntry1']['senses'][0]['pictures'][0]['fileName'];
    $file = array();
示例#2
0
 public function questionTemplate_list()
 {
     return QuestionTemplateCommands::listTemplates($this->_projectId);
 }
 public function testQuestionTemplateCRUD_CRUDOK()
 {
     $e = new ApiCrudTestEnvironment();
     $projectId = $e->makeProject();
     // Initial List
     $result = $e->json(QuestionTemplateCommands::listTemplates($projectId));
     $existingCount = $result['count'];
     // Create
     $model = array('id' => '', 'title' => 'Template Title', 'description' => 'Nice and clear description');
     $id = QuestionTemplateCommands::updateTemplate($projectId, $model);
     $this->assertNotNull($id);
     $this->assertEqual(24, strlen($id));
     // Create Second
     $model = array('id' => '', 'title' => 'Template Title 2', 'description' => 'Nice and clear description 2');
     $id2 = QuestionTemplateCommands::updateTemplate($projectId, $model);
     // List
     $result = $e->json(QuestionTemplateCommands::listTemplates($projectId));
     $this->assertEqual($result['count'], $existingCount + 2);
     // Read
     $result = $e->json(QuestionTemplateCommands::readTemplate($projectId, $id));
     $this->assertNotNull($result['id']);
     $this->assertEqual('Template Title', $result['title']);
     $this->assertEqual('Nice and clear description', $result['description']);
     // Update
     $result['description'] = 'Muddled description';
     $newid = QuestionTemplateCommands::updateTemplate($projectId, $result);
     $this->assertNotNull($newid);
     $this->assertEqual($id, $newid);
     // Verify update actually changed DB
     $postUpdateResult = $e->json(QuestionTemplateCommands::readTemplate($projectId, $id));
     $this->assertNotNull($postUpdateResult['id']);
     $this->assertEqual($postUpdateResult['description'], 'Muddled description');
     // Delete
     $result = QuestionTemplateCommands::deleteQuestionTemplates($projectId, array($id));
     $this->assertTrue($result);
     QuestionTemplateCommands::deleteQuestionTemplates($projectId, array($id2));
 }