public function testSemDomItemCommand_UpdateSemDomItem_AddItemUpdateItem()
 {
     $environ = new SemDomMongoTestEnvironment();
     $lang = 'en2';
     $languageName = 'English';
     $environ->cleanPreviousProject($lang);
     $environ->getEnglishProjectAndCreateIfNecessary();
     $user1Id = $environ->createUser('u', 'u', 'u');
     $targetProject = $environ->createSemDomProject($lang, $languageName, $user1Id);
     // insert dummy models
     $targetItemModel = new SemDomTransItemModel($targetProject);
     $targetItemModel->xmlGuid = 'asdf123';
     $targetItemModel->key = '1';
     $targetItemModel->name = new SemDomTransTranslatedForm('universe');
     $targetItemModel->description = new SemDomTransTranslatedForm('Universe description');
     $sq = new SemDomTransQuestion('A universe question', 'A universe question term');
     $targetItemModel->questions[] = $sq;
     $data = JsonEncoder::encode($targetItemModel);
     $itemId = SemDomTransItemCommands::update($data, $targetProject->id->asString());
     $readItem = new SemDomTransItemModel($targetProject, $itemId);
     $this->assertNotNull($readItem->key);
     $this->assertEquals('1', $readItem->key);
     $this->assertNotNull($readItem->name);
     $this->assertEquals('universe', $readItem->name->translation);
     $this->assertEquals(SemDomTransStatus::Draft, $readItem->name->status);
     $this->assertNotNull($readItem->description->translation);
     $this->assertEquals('Universe description', $readItem->description->translation);
     $this->assertEquals(SemDomTransStatus::Draft, $readItem->description->status);
     $readItem->name = new SemDomTransTranslatedForm('universe-edited');
     $data = JsonEncoder::encode($readItem);
     SemDomTransItemCommands::update($data, $targetProject->id->asString());
     $readItemAgain = new SemDomTransItemModel($targetProject, $itemId);
     $this->assertNotNull($readItemAgain->key);
     $this->assertEquals('1', $readItemAgain->key);
     $this->assertNotNull($readItemAgain->name);
     $this->assertEquals('universe-edited', $readItemAgain->name->translation);
     $this->assertEquals(SemDomTransStatus::Draft, $readItemAgain->name->status);
     $this->assertNotNull($readItemAgain->description->translation);
     $this->assertEquals('Universe description', $readItemAgain->description->translation);
     $this->assertEquals(SemDomTransStatus::Draft, $readItemAgain->description->status);
 }
 public function testSemdomItemCommand_UpdateSemDomItem_AddItemUpdateItem()
 {
     $e = new SemDomMongoTestEnvironment();
     $lang = 'en2';
     $languageName = "English";
     $e->cleanPreviousProject($lang);
     $e->getEnglishProjectAndCreateIfNecessary();
     $user1Id = $e->createUser('u', 'u', 'u');
     $targetProject = $e->createSemDomProject($lang, $languageName, $user1Id);
     // insert dummy models
     $targetItemModel = new SemDomTransItemModel($targetProject);
     $targetItemModel->xmlGuid = "asdf123";
     $targetItemModel->key = "1";
     $targetItemModel->name = new SemDomTransTranslatedForm("universe");
     $targetItemModel->description = new SemDomTransTranslatedForm("Universe description");
     $sq = new SemDomTransQuestion("A universe question", "A universe question term");
     $targetItemModel->questions[] = $sq;
     $data = JsonEncoder::encode($targetItemModel);
     $itemId = SemDomTransItemCommands::update($data, $targetProject->id->asString());
     $readItem = new SemDomTransItemModel($targetProject, $itemId);
     $this->assertNotEqual($readItem->key, null);
     $this->assertEqual($readItem->key, "1");
     $this->assertNotEqual($readItem->name, null);
     $this->assertEqual($readItem->name->translation, "universe");
     $this->assertEqual($readItem->name->status, SemDomTransStatus::Draft);
     $this->assertNotEqual($readItem->description->translation, null);
     $this->assertEqual($readItem->description->translation, "Universe description");
     $this->assertEqual($readItem->description->status, SemDomTransStatus::Draft);
     $readItem->name = new SemDomTransTranslatedForm("universe-edited");
     $data = JsonEncoder::encode($readItem);
     SemDomTransItemCommands::update($data, $targetProject->id->asString());
     $readItemAgain = new SemDomTransItemModel($targetProject, $itemId);
     $this->assertNotEqual($readItemAgain->key, null);
     $this->assertEqual($readItemAgain->key, "1");
     $this->assertNotEqual($readItemAgain->name, null);
     $this->assertEqual($readItemAgain->name->translation, "universe-edited");
     $this->assertEqual($readItemAgain->name->status, SemDomTransStatus::Draft);
     $this->assertNotEqual($readItemAgain->description->translation, null);
     $this->assertEqual($readItemAgain->description->translation, "Universe description");
     $this->assertEqual($readItemAgain->description->status, SemDomTransStatus::Draft);
 }
Exemplo n.º 3
0
 public function semdom_item_update($data)
 {
     return SemDomTransItemCommands::update($data, $this->projectId);
 }