ProtectedPropertySupperclassTest.php 1.8 KB

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