ClearEventTest.php 788B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional;
  3. use Doctrine\ORM\Event\OnClearEventArgs;
  4. use Doctrine\ORM\Events;
  5. require_once __DIR__ . '/../../TestInit.php';
  6. /**
  7. * ClearEventTest
  8. *
  9. * @author Michael Ridgway <mcridgway@gmail.com>
  10. */
  11. class ClearEventTest extends \Doctrine\Tests\OrmFunctionalTestCase
  12. {
  13. protected function setUp() {
  14. parent::setUp();
  15. }
  16. public function testEventIsCalledOnClear()
  17. {
  18. $listener = new OnClearListener;
  19. $this->_em->getEventManager()->addEventListener(Events::onClear, $listener);
  20. $this->_em->clear();
  21. $this->assertTrue($listener->called);
  22. }
  23. }
  24. class OnClearListener
  25. {
  26. public $called = false;
  27. public function onClear(OnClearEventArgs $args)
  28. {
  29. $this->called = true;
  30. }
  31. }