2016-07-30 10:45:48 -05:00
|
|
|
<?php
|
2017-10-12 03:13:20 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-07-30 10:45:48 -05:00
|
|
|
namespace ShlinkioTest\Shlink\Common\Paginator;
|
|
|
|
|
2017-03-24 14:34:18 -05:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-07-30 10:45:48 -05:00
|
|
|
use Prophecy\Prophecy\ObjectProphecy;
|
|
|
|
use Shlinkio\Shlink\Common\Paginator\Adapter\PaginableRepositoryAdapter;
|
|
|
|
use Shlinkio\Shlink\Common\Repository\PaginableRepositoryInterface;
|
|
|
|
|
|
|
|
class PaginableRepositoryAdapterTest extends TestCase
|
|
|
|
{
|
2018-11-20 12:30:27 -06:00
|
|
|
/** @var PaginableRepositoryAdapter */
|
2018-11-20 12:37:22 -06:00
|
|
|
private $adapter;
|
2018-11-20 12:30:27 -06:00
|
|
|
/** @var ObjectProphecy */
|
2018-11-20 12:37:22 -06:00
|
|
|
private $repo;
|
2016-07-30 10:45:48 -05:00
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$this->repo = $this->prophesize(PaginableRepositoryInterface::class);
|
2016-10-22 05:57:24 -05:00
|
|
|
$this->adapter = new PaginableRepositoryAdapter($this->repo->reveal(), 'search', ['foo', 'bar'], 'order');
|
2016-07-30 10:45:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function getItemsFallbacksToFindList()
|
|
|
|
{
|
2018-11-11 06:18:21 -06:00
|
|
|
$this->repo->findList(10, 5, 'search', ['foo', 'bar'], 'order')->shouldBeCalledOnce();
|
2016-07-30 10:45:48 -05:00
|
|
|
$this->adapter->getItems(5, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function countFallbacksToCountList()
|
|
|
|
{
|
2018-11-11 06:18:21 -06:00
|
|
|
$this->repo->countList('search', ['foo', 'bar'])->shouldBeCalledOnce();
|
2016-07-30 10:45:48 -05:00
|
|
|
$this->adapter->count();
|
|
|
|
}
|
|
|
|
}
|