FiltrationSubscriberTest.php 744 B

12345678910111213141516171819202122232425
  1. <?php
  2. use Test\Tool\BaseTestCase;
  3. use Knp\Component\Pager\Event\Subscriber\Filtration\FiltrationSubscriber;
  4. use Knp\Component\Pager\Event\BeforeEvent;
  5. class FiltrationSubscriberTest extends BaseTestCase
  6. {
  7. /**
  8. * @test
  9. */
  10. function shouldRegisterExpectedSubscribersOnlyOnce()
  11. {
  12. $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
  13. $dispatcher->expects($this->exactly(2))->method('addSubscriber');
  14. $subscriber = new FiltrationSubscriber;
  15. $beforeEvent = new BeforeEvent($dispatcher);
  16. $subscriber->before($beforeEvent);
  17. // Subsequent calls do not add more subscribers
  18. $subscriber->before($beforeEvent);
  19. }
  20. }