PaginatorTest.php 846 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use Test\Tool\BaseTestCase;
  3. use Knp\Component\Pager\Paginator;
  4. use Symfony\Component\EventDispatcher\EventDispatcher;
  5. use Knp\Component\Pager\Pagination\PaginationInterface;
  6. use Knp\Component\Pager\Event\Subscriber\Paginate\PaginationSubscriber;
  7. class PaginatorTest extends BaseTestCase
  8. {
  9. /**
  10. * @test
  11. * @expectedException RuntimeException
  12. */
  13. function shouldNotBeAbleToPaginateWithoutListeners()
  14. {
  15. $p = new Paginator(new EventDispatcher);
  16. $p->paginate(array());
  17. }
  18. /**
  19. * @test
  20. * @expectedException RuntimeException
  21. */
  22. function shouldFailToPaginateUnsupportedValue()
  23. {
  24. $dispatcher = new EventDispatcher;
  25. $dispatcher->addSubscriber(new PaginationSubscriber);
  26. $p = new Paginator($dispatcher);
  27. $view = $p->paginate(null, 1, 10);
  28. }
  29. }