Issue84Test.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. * @package Gedmo.Translatable
  12. * @link http://www.gediminasm.org
  13. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  14. */
  15. class Issue84Test extends BaseTestCaseORM
  16. {
  17. const ARTICLE = 'Translatable\\Fixture\\Article';
  18. const TRANSLATION = 'Gedmo\\Translatable\\Entity\\Translation';
  19. private $translatableListener;
  20. protected function setUp()
  21. {
  22. parent::setUp();
  23. $evm = new EventManager;
  24. $this->translatableListener = new TranslatableListener();
  25. $this->translatableListener->setTranslatableLocale('en');
  26. $evm->addEventSubscriber($this->translatableListener);
  27. $this->getMockSqliteEntityManager($evm);
  28. }
  29. public function testIssue84()
  30. {
  31. $repo = $this->em->getRepository(self::TRANSLATION);
  32. $article = new Article;
  33. $article->setTitle('en art');
  34. $article->setContent('content');
  35. $this->em->persist($article);
  36. $this->em->flush();
  37. $this->em->clear();
  38. $article = $this->em->getReference(self::ARTICLE, 1);
  39. $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $article);
  40. $trans = $repo->findTranslations($article);
  41. $this->assertEquals(1, count($trans));
  42. }
  43. protected function getUsedEntityFixtures()
  44. {
  45. return array(
  46. self::ARTICLE,
  47. self::TRANSLATION
  48. );
  49. }
  50. }