PhalconFrameworkPaginatorAdapterTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace League\Fractal\Test\Pagination;
  3. use League\Fractal\Pagination\PhalconFrameworkPaginatorAdapter;
  4. use Mockery;
  5. use PHPUnit\Framework\TestCase;
  6. class PhalconFrameworkPaginatorAdapterTest extends TestCase
  7. {
  8. public function testPaginationAdapter()
  9. {
  10. $total = 50;
  11. $count = 10;
  12. $perPage = 10;
  13. $currentPage = 2;
  14. $lastPage = 5;
  15. $paginate =[
  16. 'last' => $lastPage,
  17. 'current' => $currentPage,
  18. 'total_items' => $total,
  19. 'total_pages' => $count,
  20. ];
  21. $paginator = Mockery::mock('Phalcon\Paginator\Adapter\QueryBuilder');
  22. $paginator->shouldReceive('currentPage')->andReturn($currentPage);
  23. $paginator->shouldReceive('lastPage')->andReturn($lastPage);
  24. $paginator->shouldReceive('count')->andReturn($count);
  25. $paginator->shouldReceive('total')->andReturn($total);
  26. $paginator->shouldReceive('getPaginate')->andReturn((object) $paginate);
  27. $adapter = new PhalconFrameworkPaginatorAdapter($paginator);
  28. $this->assertInstanceOf('League\Fractal\Pagination\PaginatorInterface', $adapter);
  29. $this->assertSame($currentPage, $adapter->getCurrentPage());
  30. $this->assertSame($lastPage, $adapter->getLastPage());
  31. $this->assertSame($count, $adapter->getCount());
  32. $this->assertSame($total, $adapter->getTotal());
  33. }
  34. public function tearDown()
  35. {
  36. Mockery::close();
  37. }
  38. }