コード例 #1
0
 public function lex_entry_read($entryId)
 {
     return LexEntryCommands::readEntry($this->projectId, $entryId);
 }
コード例 #2
0
 public function testUpdateEntry_ClearedData_DataIsCleared()
 {
     $project = self::$environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $entry = new LexEntryModel($project);
     $entry->lexeme->form('th', 'apple');
     $entryId = $entry->write();
     $params = json_decode(json_encode(LexEntryCommands::readEntry($projectId, $entryId)), true);
     $params['lexeme']['th']['value'] = '';
     $userId = self::$environ->createUser('john', 'john', 'john');
     LexEntryCommands::updateEntry($projectId, $params, $userId);
     $updatedEntry = LexEntryCommands::readEntry($projectId, $entryId);
     $this->assertEquals('', $updatedEntry['lexeme']['th']['value']);
 }
コード例 #3
0
 public function testUpdateEntry_DataPersists()
 {
     $e = new LexiconMongoTestEnvironment();
     $e->clean();
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $userId = $e->createUser('john', 'john', 'john');
     $entry = new LexEntryModel($project);
     $entry->lexeme->form('th', 'apple');
     $sense = new Sense();
     $sense->definition->form('en', 'red fruit');
     $sense->gloss->form('en', 'rose fruit');
     $sense->partOfSpeech->value = 'noun';
     $example = new Example();
     $example->sentence->form('th', 'example1');
     $example->translation->form('en', 'trans1');
     $sense->examples[] = $example;
     $entry->senses[] = $sense;
     $entryId = $entry->write();
     $params = json_decode(json_encode(LexEntryCommands::readEntry($projectId, $entryId)), true);
     $params['lexeme']['th']['value'] = 'rose apple';
     LexEntryCommands::updateEntry($projectId, $params, $userId);
     $newEntry = LexEntryCommands::readEntry($projectId, $entryId);
     $this->assertEqual($newEntry['lexeme']['th']['value'], 'rose apple');
     $this->assertEqual($newEntry['senses'][0]['definition']['en']['value'], 'red fruit');
     $this->assertEqual($newEntry['senses'][0]['gloss']['en']['value'], 'rose fruit');
     $this->assertEqual($newEntry['senses'][0]['partOfSpeech']['value'], 'noun');
     $this->assertEqual($newEntry['senses'][0]['examples'][0]['sentence']['th']['value'], 'example1');
     $this->assertEqual($newEntry['senses'][0]['examples'][0]['translation']['en']['value'], 'trans1');
 }
コード例 #4
0
 function testReadEntry_NoComments_ReadBackOk()
 {
     $e = new LexiconMongoTestEnvironment();
     $e->clean();
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $projectId = $project->id->asString();
     $entry = new LexEntryModel($project);
     $entry->lexeme->form('th', 'apple');
     $sense = new Sense();
     $sense->definition->form('en', 'red fruit');
     $sense->partOfSpeech = new LexiconField('noun');
     $example = new Example();
     $example->sentence->form('th', 'example1');
     $example->translation->form('en', 'trans1');
     $sense->examples[] = $example;
     $entry->senses[] = $sense;
     $entryId = $entry->write();
     $newEntry = LexEntryCommands::readEntry($projectId, $entryId);
     $this->assertEqual($newEntry['lexeme']['th']['value'], 'apple');
     $this->assertEqual($newEntry['senses'][0]['definition']['en']['value'], 'red fruit');
     $this->assertEqual($newEntry['senses'][0]['partOfSpeech']['value'], 'noun');
     $this->assertEqual($newEntry['senses'][0]['examples'][0]['sentence']['th']['value'], 'example1');
     $this->assertEqual($newEntry['senses'][0]['examples'][0]['translation']['en']['value'], 'trans1');
 }