|
@@ -40,19 +40,22 @@ class TranslatableEntityCollectionTest extends BaseTestCaseORM
|
|
|
'user' => 'root',
|
|
|
'password' => 'nimda'
|
|
|
);
|
|
|
- //$this->getMockCustomEntityManager($conn, $evm);
|
|
|
- $this->getMockSqliteEntityManager($evm);
|
|
|
+ $this->getMockCustomEntityManager($conn, $evm);
|
|
|
+ //$this->getMockSqliteEntityManager($evm);
|
|
|
$this->populate();
|
|
|
}
|
|
|
|
|
|
- public function testMultipleTranslationPersistence()
|
|
|
+ /**
|
|
|
+ * test
|
|
|
+ */
|
|
|
+ function shouldPersistMultipleTranslations()
|
|
|
{
|
|
|
$repo = $this->em->getRepository(self::TRANSLATION);
|
|
|
$sport = $this->em->getRepository(self::ARTICLE)->find(1);
|
|
|
$translations = $repo->findTranslations($sport);
|
|
|
|
|
|
$this->assertEquals(2, count($translations));
|
|
|
-
|
|
|
+
|
|
|
$this->assertArrayHasKey('de_de', $translations);
|
|
|
$this->assertArrayHasKey('title', $translations['de_de']);
|
|
|
$this->assertArrayHasKey('content', $translations['de_de']);
|
|
@@ -66,21 +69,50 @@ class TranslatableEntityCollectionTest extends BaseTestCaseORM
|
|
|
$this->assertEquals('content ru', $translations['ru_ru']['content']);
|
|
|
}
|
|
|
|
|
|
- public function testMultipleTranslationUpdates()
|
|
|
+ /**
|
|
|
+ * test
|
|
|
+ */
|
|
|
+ function shouldUpdateTranslation()
|
|
|
+ {
|
|
|
+ $repo = $this->em->getRepository(self::TRANSLATION);
|
|
|
+ $sport = $this->em->getRepository(self::ARTICLE)->find(1);
|
|
|
+ $repo
|
|
|
+ ->translate($sport, 'title', 'ru_ru', 'sport ru change')
|
|
|
+ ->translate($sport, 'content', 'ru_ru', 'content ru change')
|
|
|
+ ;
|
|
|
+ $this->em->flush();
|
|
|
+
|
|
|
+ $translations = $repo->findTranslations($sport);
|
|
|
+ $this->assertEquals(2, count($translations));
|
|
|
+
|
|
|
+ $this->assertArrayHasKey('ru_ru', $translations);
|
|
|
+ $this->assertArrayHasKey('title', $translations['ru_ru']);
|
|
|
+ $this->assertArrayHasKey('content', $translations['ru_ru']);
|
|
|
+ $this->assertEquals('sport ru change', $translations['ru_ru']['title']);
|
|
|
+ $this->assertEquals('content ru change', $translations['ru_ru']['content']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @test
|
|
|
+ */
|
|
|
+ function shouldUpdateMultipleTranslations()
|
|
|
{
|
|
|
$repo = $this->em->getRepository(self::TRANSLATION);
|
|
|
$sport = $this->em->getRepository(self::ARTICLE)->find(1);
|
|
|
- $sport->setTitle('Changed');
|
|
|
$repo
|
|
|
->translate($sport, 'title', 'lt_lt', 'sport lt')
|
|
|
->translate($sport, 'content', 'lt_lt', 'content lt')
|
|
|
->translate($sport, 'title', 'ru_ru', 'sport ru change')
|
|
|
- ->translate($sport, 'content', 'ru_ru', 'content ru change');
|
|
|
-
|
|
|
- $this->em->persist($sport);
|
|
|
+ ->translate($sport, 'content', 'ru_ru', 'content ru change')
|
|
|
+ ->translate($sport, 'title', 'en_us', 'sport en update')
|
|
|
+ ->translate($sport, 'content', 'en_us', 'content en update')
|
|
|
+ ;
|
|
|
$this->em->flush();
|
|
|
- $translations = $repo->findTranslations($sport);
|
|
|
|
|
|
+ $this->assertEquals('sport en update', $sport->getTitle());
|
|
|
+ $this->assertEquals('content en update', $sport->getContent());
|
|
|
+
|
|
|
+ $translations = $repo->findTranslations($sport);
|
|
|
$this->assertEquals(3, count($translations));
|
|
|
|
|
|
$this->assertArrayHasKey('de_de', $translations);
|
|
@@ -113,7 +145,8 @@ class TranslatableEntityCollectionTest extends BaseTestCaseORM
|
|
|
->translate($sport, 'title', 'de_de', 'sport de')
|
|
|
->translate($sport, 'content', 'de_de', 'content de')
|
|
|
->translate($sport, 'title', 'ru_ru', 'sport ru')
|
|
|
- ->translate($sport, 'content', 'ru_ru', 'content ru');
|
|
|
+ ->translate($sport, 'content', 'ru_ru', 'content ru')
|
|
|
+ ;
|
|
|
|
|
|
$this->em->persist($sport);
|
|
|
$this->em->flush();
|