12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace Gedmo\Translatable;
- use Doctrine\Common\EventManager;
- use Tool\BaseTestCaseORM;
- use Translatable\Fixture\Issue75\Article;
- use Translatable\Fixture\Issue75\Image;
- use Translatable\Fixture\Issue75\File;
- /**
- * These are tests for translatable behavior
- *
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
- * @package Gedmo.Translatable
- * @link http://www.gediminasm.org
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
- class Issue75Test extends BaseTestCaseORM
- {
- const ARTICLE = 'Translatable\\Fixture\\Issue75\\Article';
- const IMAGE = 'Translatable\\Fixture\\Issue75\\Image';
- const FILE = 'Translatable\\Fixture\\Issue75\\File';
- const TRANSLATION = 'Gedmo\\Translatable\\Entity\\Translation';
- private $translatableListener;
- protected function setUp()
- {
- parent::setUp();
- $evm = new EventManager;
- $this->translatableListener = new TranslationListener();
- $this->translatableListener->setTranslatableLocale('en');
- $this->translatableListener->setDefaultLocale('en');
- $evm->addEventSubscriber($this->translatableListener);
- $this->getMockSqliteEntityManager($evm);
- }
- public function testIssue75()
- {
- $repo = $this->em->getRepository(self::TRANSLATION);
-
- // Step1: article creation in default locale
- $image1 = new Image;
- $image1->setTitle('img1');
- $this->em->persist($image1);
- $image2 = new Image;
- $image2->setTitle('img2');
- $this->em->persist($image2);
-
- $article = new Article;
- $article->setTitle('en art');
- $article->setImages(array($image1, $image2));
- $this->em->persist($article);
-
- $this->em->flush();
- //Step2: article update in another locale
- $article = $this->em->find(self::ARTICLE, $article->getId());
- $image1 = $this->em->find(self::IMAGE, $image1->getId());
- $image2 = $this->em->find(self::IMAGE, $image2->getId());
- $article->setTitle('en updated');
- $article->setImages(array($image1, $image2));
- $this->em->persist($article);
- $this->em->flush();
- }
- protected function getUsedEntityFixtures()
- {
- return array(
- self::ARTICLE,
- self::TRANSLATION,
- self::IMAGE,
- self::FILE
- );
- }
- }
|