mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 19:59:04 +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;
|
namespace ShlinkioTest\Shlink\Core\Tag\Paginator\Adapter;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
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\Model\TagsParams;
|
||||||
use Shlinkio\Shlink\Core\Tag\Paginator\Adapter\TagsInfoPaginatorAdapter;
|
use Shlinkio\Shlink\Core\Tag\Paginator\Adapter\TagsInfoPaginatorAdapter;
|
||||||
use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
|
use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
|
||||||
|
|
||||||
class TagsInfoPaginatorAdapterTest extends TestCase
|
class TagsInfoPaginatorAdapterTest extends TestCase
|
||||||
{
|
{
|
||||||
use ProphecyTrait;
|
|
||||||
|
|
||||||
private TagsInfoPaginatorAdapter $adapter;
|
private TagsInfoPaginatorAdapter $adapter;
|
||||||
private ObjectProphecy $repo;
|
private MockObject $repo;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->repo = $this->prophesize(TagRepositoryInterface::class);
|
$this->repo = $this->createMock(TagRepositoryInterface::class);
|
||||||
$this->adapter = new TagsInfoPaginatorAdapter($this->repo->reveal(), TagsParams::fromRawData([]), null);
|
$this->adapter = new TagsInfoPaginatorAdapter($this->repo, TagsParams::fromRawData([]), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function getSliceIsDelegatedToRepository(): void
|
public function getSliceIsDelegatedToRepository(): void
|
||||||
{
|
{
|
||||||
$findTags = $this->repo->findTagsWithInfo(Argument::cetera())->willReturn([]);
|
$this->repo->expects($this->once())->method('findTagsWithInfo')->willReturn([]);
|
||||||
|
|
||||||
$this->adapter->getSlice(1, 1);
|
$this->adapter->getSlice(1, 1);
|
||||||
|
|
||||||
$findTags->shouldHaveBeenCalledOnce();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function getNbResultsIsDelegatedToRepository(): void
|
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();
|
$result = $this->adapter->getNbResults();
|
||||||
|
|
||||||
self::assertEquals(3, $result);
|
self::assertEquals(3, $result);
|
||||||
$match->shouldHaveBeenCalledOnce();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue