Issue84Test.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Gedmo\Translatable;
  3. use Doctrine\Common\EventManager;
  4. use Tool\BaseTestCaseORM;
  5. use Translatable\Fixture\Article;
  6. use Doctrine\ORM\Proxy\Proxy;
  7. /**
  8. * These are tests for translatable behavior
  9. *
  10. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  11. * @link http://www.gediminasm.org
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. class Issue84Test extends BaseTestCaseORM
  15. {
  16. const ARTICLE = 'Translatable\\Fixture\\Article';
  17. const TRANSLATION = 'Gedmo\\Translatable\\Entity\\Translation';
  18. private $translatableListener;
  19. protected function setUp()
  20. {
  21. parent::setUp();
  22. $evm = new EventManager;
  23. $this->translatableListener = new TranslatableListener();
  24. $this->translatableListener->setTranslatableLocale('en');
  25. $evm->addEventSubscriber($this->translatableListener);
  26. $this->getMockSqliteEntityManager($evm);
  27. }
  28. public function testIssue84()
  29. {
  30. $repo = $this->em->getRepository(self::TRANSLATION);
  31. $article = new Article;
  32. $article->setTitle('en art');
  33. $article->setContent('content');
  34. $this->em->persist($article);
  35. $this->em->flush();
  36. $this->em->clear();
  37. $article = $this->em->getReference(self::ARTICLE, 1);
  38. $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $article);
  39. $trans = $repo->findTranslations($article);
  40. $this->assertEquals(1, count($trans));
  41. }
  42. protected function getUsedEntityFixtures()
  43. {
  44. return array(
  45. self::ARTICLE,
  46. self::TRANSLATION
  47. );
  48. }
  49. }