mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Migrated TagsInfoPaginatorAdapterTest to use PHPUnit mocks
This commit is contained in:
parent
c81ae9c40d
commit
3b20f955ff
1 changed files with 6 additions and 14 deletions
|
@ -4,45 +4,37 @@ 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\TagsInfoPaginatorAdapter;
|
||||
use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
|
||||
|
||||
class TagsInfoPaginatorAdapterTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private TagsInfoPaginatorAdapter $adapter;
|
||||
private ObjectProphecy $repo;
|
||||
private MockObject $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repo = $this->prophesize(TagRepositoryInterface::class);
|
||||
$this->adapter = new TagsInfoPaginatorAdapter($this->repo->reveal(), TagsParams::fromRawData([]), null);
|
||||
$this->repo = $this->createMock(TagRepositoryInterface::class);
|
||||
$this->adapter = new TagsInfoPaginatorAdapter($this->repo, TagsParams::fromRawData([]), null);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function getSliceIsDelegatedToRepository(): void
|
||||
{
|
||||
$findTags = $this->repo->findTagsWithInfo(Argument::cetera())->willReturn([]);
|
||||
|
||||
$this->repo->expects($this->once())->method('findTagsWithInfo')->willReturn([]);
|
||||
$this->adapter->getSlice(1, 1);
|
||||
|
||||
$findTags->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function getNbResultsIsDelegatedToRepository(): void
|
||||
{
|
||||
$match = $this->repo->matchSingleScalarResult(Argument::cetera())->willReturn(3);
|
||||
$this->repo->expects($this->once())->method('matchSingleScalarResult')->willReturn(3);
|
||||
|
||||
$result = $this->adapter->getNbResults();
|
||||
|
||||
self::assertEquals(3, $result);
|
||||
$match->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue