Skip to content

Commit

Permalink
Merge pull request #166 from einorler/PagerTests
Browse files Browse the repository at this point in the history
covered Pager with tests
  • Loading branch information
saimaz committed Jun 27, 2016
2 parents 3b667c6 + f8874ab commit f2fd53c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Tests/Unit/Pager/Adapters/CountAdapterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ONGR\FilterManagerBundle\Tests\Unit\Pager\Adapters;

use ONGR\FilterManagerBundle\Pager\Adapters\CountAdapter;

class CountAdapterTest extends \PHPUnit_Framework_TestCase
{
public function testGetResults()
{
$adapter = new CountAdapter(0);
$this->assertEquals([], $adapter->getResults(0, 0));
}
}
52 changes: 52 additions & 0 deletions Tests/Unit/Pager/PagerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,58 @@ public function testGetResults($totalResults, $results, $expected)
$this->assertEquals($expected, $result);
}

/**
* Data provider for testGettersAndSetters().
*
* @return array
*/
public function getTestGettersAndSettersData()
{
$result = [];
// #0
$result[] = [
[
'limit' => 2,
'page' => 4,
],
2,
4
];
// #1
$result[] = [
[
'limit' => 0,
'page' => 15,
],
1,
10
];
// #2
$result[] = [
[
'limit' => 11,
'page' => 15,
],
11,
1
];
return $result;
}

/**
* Tests Limit and Page getters and setters
*
* @dataProvider getTestGettersAndSettersData
*/
public function testGettersAndSetters($options, $limit, $page)
{
$adapter = $this->getMock('ONGR\FilterManagerBundle\Pager\PagerAdapterInterface');
$adapter->expects($this->any())->method('getTotalResults')->will($this->returnValue(10));
$pager = new PagerService($adapter, $options);
$this->assertEquals($limit, $pager->getLimit());
$this->assertEquals($page, $pager->getPage());
}

/**
* Data provider for testGetOffset().
*
Expand Down

0 comments on commit f2fd53c

Please sign in to comment.