コード例 #1
0
 /**
  * Reads a MultiText from the XmlNode $sxeNode given by the element 'gloss'
  *
  * @param SimpleXMLElement $sxeNode
  * @param MultiText $multiText
  * @param ArrayOf $inputSystems
  * @return MultiText
  */
 public function readMultiTextGloss($sxeNode, $multiText, $inputSystems = null)
 {
     CodeGuard::checkTypeAndThrow($multiText, 'Api\\Model\\Languageforge\\Lexicon\\MultiText');
     if ($sxeNode->getName() != 'gloss') {
         throw new \Exception("'" . $sxeNode->getName() . "' is not a gloss");
     }
     $inputSystemTag = (string) $sxeNode['lang'];
     $multiText->form($inputSystemTag, (string) $sxeNode->text);
     $this->projectModel->addInputSystem($inputSystemTag);
     // TODO InputSystems should extend ArrayOf (or Map) and become more useful. CP 2014-10
     if (isset($inputSystems)) {
         // i.e. $inputSystems->ensureFieldHasInputSystem($inputSystemTag);
         $inputSystems->value($inputSystemTag);
     }
 }
コード例 #2
0
    $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();
    $file['name'] = $fileName;
    $_FILES['file'] = $file;
    // put a copy of the test file in tmp
    $tmpFilePath = sys_get_temp_dir() . "/CopyOf{$fileName}";
    copy(dirname(TestPath) . "/php/common/{$fileName}", $tmpFilePath);
    $response = LexUploadCommands::uploadImageFile($testProjectId, 'sense-image', $tmpFilePath);
    // cleanup tmp file if it still exists
    if (file_exists($tmpFilePath) and !is_dir($tmpFilePath)) {
        @unlink($tmpFilePath);
    }