From 042d31ef925b1673d59698a1e7fd7dfc1495826d Mon Sep 17 00:00:00 2001 From: dantleech Date: Thu, 8 Oct 2015 09:39:08 +0200 Subject: [PATCH] Failing test for issue #657 --- .../Translation/DocumentManagerTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php index ee8fcbfcb..ff1753522 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Translation/DocumentManagerTest.php @@ -881,4 +881,31 @@ public function testAdditionalFindCallsDoNotRefresh() $this->assertEquals('Guten tag', $trans->topic); } + + /** + * It should be able to find a bound translation before flush. + */ + public function testRetainTranslation() + { + $article = new Article; + $article->id = '/functional/article-1'; + $article->text = 'Foo'; + $this->dm->persist($article); + + $article->topic = 'Hello everybody!'; + $this->dm->bindTranslation($article, 'en'); + + $article->topic = 'Bonjour le monde!'; + $this->dm->bindTranslation($article, 'fr'); + $articleInstance = $this->dm->findTranslation(get_class($article), '/functional/article-1', 'en'); + + // Fails - returns "foo" + // $this->assertEquals('Hello everybody!', $articleInstance->text); + + // Fails, could not find /functional/article-1 + $this->dm->flush(); + $this->dm->clear(); + + $this->assertEquals('Hello everybody!', $article->topic); + } }