2016-07-30 17:45:48 +02:00
|
|
|
<?php
|
2017-10-12 10:13:20 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-07-30 17:45:48 +02:00
|
|
|
namespace ShlinkioTest\Shlink\Common\Paginator;
|
|
|
|
|
2017-03-24 20:34:18 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-07-30 17:45:48 +02: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 19:30:27 +01:00
|
|
|
/** @var PaginableRepositoryAdapter */
|
2018-11-20 19:37:22 +01:00
|
|
|
private $adapter;
|
2018-11-20 19:30:27 +01:00
|
|
|
/** @var ObjectProphecy */
|
2018-11-20 19:37:22 +01:00
|
|
|
private $repo;
|
2016-07-30 17:45:48 +02:00
|
|
|
|
2019-02-16 10:53:45 +01:00
|
|
|
public function setUp(): void
|
2016-07-30 17:45:48 +02:00
|
|
|
{
|
|
|
|
$this->repo = $this->prophesize(PaginableRepositoryInterface::class);
|
2016-10-22 12:57:24 +02:00
|
|
|
$this->adapter = new PaginableRepositoryAdapter($this->repo->reveal(), 'search', ['foo', 'bar'], 'order');
|
2016-07-30 17:45:48 +02:00
|
|
|
}
|
|
|
|
|
2019-02-17 20:28:34 +01:00
|
|
|
/** @test */
|
2016-07-30 17:45:48 +02:00
|
|
|
public function getItemsFallbacksToFindList()
|
|
|
|
{
|
2018-11-11 13:18:21 +01:00
|
|
|
$this->repo->findList(10, 5, 'search', ['foo', 'bar'], 'order')->shouldBeCalledOnce();
|
2016-07-30 17:45:48 +02:00
|
|
|
$this->adapter->getItems(5, 10);
|
|
|
|
}
|
|
|
|
|
2019-02-17 20:28:34 +01:00
|
|
|
/** @test */
|
2016-07-30 17:45:48 +02:00
|
|
|
public function countFallbacksToCountList()
|
|
|
|
{
|
2018-11-11 13:18:21 +01:00
|
|
|
$this->repo->countList('search', ['foo', 'bar'])->shouldBeCalledOnce();
|
2016-07-30 17:45:48 +02:00
|
|
|
$this->adapter->count();
|
|
|
|
}
|
|
|
|
}
|