public function testFind()
 {
     $this->dm->persist($this->doc);
     $this->dm->flush();
     $doc = $this->dm->find('Doctrine\\Tests\\Models\\Translation\\Article', '/functional/' . $this->testNodeName);
     $this->assertNotNull($doc);
     $this->assertEquals('en', $doc->locale);
     $node = $this->getTestNode();
     $this->assertNotNull($node);
     $this->assertTrue($node->hasProperty(AttributeTranslationStrategyTest::propertyNameForLocale('en', 'topic')));
     $this->assertEquals('Some interesting subject', $node->getPropertyValue(AttributeTranslationStrategyTest::propertyNameForLocale('en', 'topic')));
 }
 /**
  * We only validate when saving, never when loading. This has to find the
  * incomplete english translation.
  */
 public function testFindNullableFieldIncomplete()
 {
     $node = $this->node->addNode('find');
     $node->setProperty('phpcr:class', 'Doctrine\\Tests\\Models\\Translation\\Article');
     $node->setProperty(AttributeTranslationStrategyTest::propertyNameForLocale('en', 'topic'), 'title');
     $node->setProperty(AttributeTranslationStrategyTest::propertyNameForLocale('de', 'topic'), 'Titel');
     $this->dm->getPhpcrSession()->save();
     $this->dm->clear();
     /** @var $doc Article */
     $doc = $this->dm->find(null, $this->node->getPath() . '/find');
     $this->assertEquals('en', $doc->locale);
     $this->assertEquals('title', $doc->topic);
     $this->assertNull($doc->text);
 }
 /**
  * Just make one field of a document untranslated again
  */
 public function testPartialUntranslateAttribute()
 {
     $article = new Article();
     $article->id = '/functional/convert';
     $article->topic = 'Some interesting subject';
     $article->setText('Lorem ipsum...');
     $this->dm->persist($article);
     $this->dm->flush();
     $this->dm->clear();
     $class = 'Doctrine\\Tests\\Models\\Translation\\Article';
     $field = 'author';
     $comment = $this->node->getNode('convert');
     $comment->setProperty(AttributeTranslationStrategyTest::propertyNameForLocale('en', $field), 'Move to untranslated');
     $this->session->save();
     $this->assertFalse($this->converter->convert($class, array('en'), array($field)));
     $this->session->save();
     $this->dm->clear();
     $this->dm = $this->createDocumentManager();
     $this->dm->setLocaleChooserStrategy(new LocaleChooser($this->localePrefs, 'en'));
     $this->assertTrue($comment->hasProperty($field), 'new property was not created');
     $this->assertFalse($comment->hasProperty(AttributeTranslationStrategyTest::propertyNameForLocale('en', $field)), 'old property was not removed');
     $article = $this->dm->find(null, '/functional/convert');
     $this->assertInstanceof($class, $article);
     $this->assertEquals('Move to untranslated', $article->author);
     $this->assertEquals('Lorem ipsum...', $article->getText());
     $this->dm->clear();
     $article = $this->dm->find(null, '/functional/convert');
     $this->assertInstanceof($class, $article);
     $this->assertEquals('Move to untranslated', $article->author);
     $this->assertEquals('Lorem ipsum...', $article->getText());
 }