ProtectedPropertySupperclassTest.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Gedmo\Tree;
  3. use Doctrine\Common\EventManager;
  4. use Tool\BaseTestCaseORM;
  5. use Gedmo\Translatable\TranslatableListener;
  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. $translatableListener = new TranslatableListener;
  26. $translatableListener->setTranslatableLocale('en_US');
  27. $evm->addEventSubscriber($translatableListener);
  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->assertCount(0, $translations);
  42. $this->assertNotNull($test->getCreatedAt());
  43. }
  44. protected function getUsedEntityFixtures()
  45. {
  46. return array(
  47. self::TRANSLATION,
  48. self::SUPERCLASS
  49. );
  50. }
  51. }