Migrated TagsPaginatorAdapterTest to use PHPUnit mocks

This commit is contained in:
Alejandro Celaya 2022-10-23 20:28:45 +02:00
parent 3b20f955ff
commit 3b25fb27fe

View File

@ -4,34 +4,27 @@ declare(strict_types=1);
namespace ShlinkioTest\Shlink\Core\Tag\Paginator\Adapter;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Shlinkio\Shlink\Core\Tag\Model\TagsParams;
use Shlinkio\Shlink\Core\Tag\Paginator\Adapter\TagsPaginatorAdapter;
use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
class TagsPaginatorAdapterTest extends TestCase
{
use ProphecyTrait;
private TagsPaginatorAdapter $adapter;
private ObjectProphecy $repo;
private MockObject $repo;
protected function setUp(): void
{
$this->repo = $this->prophesize(TagRepositoryInterface::class);
$this->adapter = new TagsPaginatorAdapter($this->repo->reveal(), TagsParams::fromRawData([]), null);
$this->repo = $this->createMock(TagRepositoryInterface::class);
$this->adapter = new TagsPaginatorAdapter($this->repo, TagsParams::fromRawData([]), null);
}
/** @test */
public function getSliceDelegatesToRepository(): void
{
$match = $this->repo->match(Argument::cetera())->willReturn([]);
$this->repo->expects($this->once())->method('match')->willReturn([]);
$this->adapter->getSlice(1, 1);
$match->shouldHaveBeenCalledOnce();
}
}