Completed
Pull Request — master (#303)
by
unknown
08:49
created

testPaginationAdapter()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 31
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\PhalconFrameworkPaginatorAdapter;
6
use Mockery;
7
8
class PhalconFrameworkPaginatorAdapterTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testPaginationAdapter()
11
    {
12
        $total = 50;
13
        $count = 10;
14
        $perPage = 10;
0 ignored issues
show
Unused Code introduced by
$perPage is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
15
        $currentPage = 2;
16
        $lastPage = 5;
17
18
        $paginate =[
19
            'last'        => $lastPage,
20
            'current'     => $currentPage,
21
            'total_items' => $total,
22
            'total_pages' => $count,
23
24
        ];
25
26
        $paginator = Mockery::mock('Phalcon\Paginator\Adapter\QueryBuilder');
27
        $paginator->shouldReceive('currentPage')->andReturn($currentPage);
28
        $paginator->shouldReceive('lastPage')->andReturn($lastPage);
29
        $paginator->shouldReceive('count')->andReturn($count);
30
        $paginator->shouldReceive('total')->andReturn($total);
31
        $paginator->shouldReceive('getPaginate')->andReturn((object) $paginate);
32
33
        $adapter = new PhalconFrameworkPaginatorAdapter($paginator);
34
35
        $this->assertInstanceOf('League\Fractal\Pagination\PaginatorInterface', $adapter);
36
        $this->assertSame($currentPage, $adapter->getCurrentPage());
37
        $this->assertSame($lastPage, $adapter->getLastPage());
38
        $this->assertSame($count, $adapter->getCount());
39
        $this->assertSame($total, $adapter->getTotal());
40
    }
41
42
    public function tearDown()
43
    {
44
        Mockery::close();
45
    }
46
}
47