ProtectedPropertySupperclassTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Gedmo\Tree;
  3. use Doctrine\Common\EventManager;
  4. use Tool\BaseTestCaseORM;
  5. use Gedmo\Translatable\TranslationListener;
  6. use Gedmo\Timestampable\TimestampableListener;
  7. use Doctrine\Common\Util\Debug;
  8. use Timestampable\Fixture\SupperClassExtension;
  9. /**
  10. * These are tests for Timestampable behavior
  11. *
  12. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  13. * @package Gedmo.Tree
  14. * @link http://www.gediminasm.org
  15. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  16. */
  17. class ProtectedPropertySupperclassTest extends BaseTestCaseORM
  18. {
  19. const SUPERCLASS = "Timestampable\\Fixture\\SupperClassExtension";
  20. const TRANSLATION = "Gedmo\\Translatable\\Entity\\Translation";
  21. protected function setUp()
  22. {
  23. parent::setUp();
  24. $evm = new EventManager;
  25. $translationListener = new TranslationListener;
  26. $translationListener->setTranslatableLocale('en_us');
  27. $evm->addEventSubscriber($translationListener);
  28. $evm->addEventSubscriber(new TimestampableListener);
  29. $this->getMockSqliteEntityManager($evm);
  30. }
  31. public function testProtectedProperty()
  32. {
  33. $test = new SupperClassExtension;
  34. $test->setName('name');
  35. $test->setTitle('title');
  36. $this->em->persist($test);
  37. $this->em->flush();
  38. $this->em->clear();
  39. $repo = $this->em->getRepository(self::TRANSLATION);
  40. $translations = $repo->findTranslations($test);
  41. $this->assertEquals(1, count($translations));
  42. $this->assertArrayHasKey('en_us', $translations);
  43. $this->assertEquals(2, count($translations['en_us']));
  44. $this->assertTrue($test->getCreatedAt() !== null);
  45. }
  46. protected function getUsedEntityFixtures()
  47. {
  48. return array(
  49. self::TRANSLATION,
  50. self::SUPERCLASS
  51. );
  52. }
  53. }