Completed
Pull Request — master (#306)
by Benoît
03:13
created

testPaginationAdapter()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 29
rs 8.8571
cc 1
eloc 23
nc 1
nop 0
1
<?php
2
3
namespace League\Fractal\Test\Pagination;
4
5
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
6
use Mockery;
7
8
class IlluminatePaginatorAdapterTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testPaginationAdapter()
11
    {
12
        $total = 50;
13
        $count = 10;
14
        $perPage = 10;
15
        $currentPage = 2;
16
        $lastPage = 5;
17
        $url = 'http://example.com/foo?page=1';
18
19
        $paginator = Mockery::mock('Illuminate\Contracts\Pagination\LengthAwarePaginator');
20
        $paginator->shouldReceive('currentPage')->andReturn($currentPage);
21
        $paginator->shouldReceive('lastPage')->andReturn($lastPage);
22
        $paginator->shouldReceive('count')->andReturn($count);
23
        $paginator->shouldReceive('total')->andReturn($total);
24
        $paginator->shouldReceive('perPage')->andReturn($perPage);
25
        $paginator->shouldReceive('url')->with(1)->andReturn($url);
26
27
        $adapter = new IlluminatePaginatorAdapter($paginator);
28
29
        $this->assertInstanceOf('League\Fractal\Pagination\PaginatorInterface', $adapter);
30
        $this->assertInstanceOf('Illuminate\Contracts\Pagination\LengthAwarePaginator', $adapter->getPaginator());
31
32
        $this->assertSame($currentPage, $adapter->getCurrentPage());
33
        $this->assertSame($lastPage, $adapter->getLastPage());
34
        $this->assertSame($count, $adapter->getCount());
35
        $this->assertSame($total, $adapter->getTotal());
36
        $this->assertSame($perPage, $adapter->getPerPage());
37
        $this->assertSame('http://example.com/foo?page=1', $adapter->getUrl(1));
38
    }
39
40
    public function tearDown()
41
    {
42
        Mockery::close();
43
    }
44
}
45