ProtectedPropertySupperclassTest.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. * @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 = "Blameable\\Fixture\\Entity\\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. $blameableListener = new BlameableListener();
  29. $blameableListener->setUserValue('testuser');
  30. $evm->addEventSubscriber($blameableListener);
  31. $this->getMockSqliteEntityManager($evm);
  32. }
  33. public function testProtectedProperty()
  34. {
  35. $test = new SupperClassExtension;
  36. $test->setName('name');
  37. $test->setTitle('title');
  38. $this->em->persist($test);
  39. $this->em->flush();
  40. $this->em->clear();
  41. $repo = $this->em->getRepository(self::TRANSLATION);
  42. $translations = $repo->findTranslations($test);
  43. $this->assertCount(0, $translations);
  44. $this->assertEquals('testuser', $test->getCreatedBy());
  45. }
  46. protected function getUsedEntityFixtures()
  47. {
  48. return array(
  49. self::TRANSLATION,
  50. self::SUPERCLASS
  51. );
  52. }
  53. }