mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-23 07:33:58 -06:00
Migrated ShortUrlRepositoryAdapterTest to use PHPUnit mocks
This commit is contained in:
parent
6a2227efc5
commit
8753e3a77f
@ -5,9 +5,8 @@ declare(strict_types=1);
|
||||
namespace ShlinkioTest\Shlink\Core\ShortUrl\Paginator\Adapter;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlsParams;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\TagsMode;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Paginator\Adapter\ShortUrlRepositoryAdapter;
|
||||
@ -18,13 +17,11 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
class ShortUrlRepositoryAdapterTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private ObjectProphecy $repo;
|
||||
private MockObject $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->repo = $this->prophesize(ShortUrlRepositoryInterface::class);
|
||||
$this->repo = $this->createMock(ShortUrlRepositoryInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,13 +42,14 @@ class ShortUrlRepositoryAdapterTest extends TestCase
|
||||
'endDate' => $endDate,
|
||||
'orderBy' => $orderBy,
|
||||
]);
|
||||
$adapter = new ShortUrlRepositoryAdapter($this->repo->reveal(), $params, null);
|
||||
$adapter = new ShortUrlRepositoryAdapter($this->repo, $params, null);
|
||||
$orderBy = $params->orderBy();
|
||||
$dateRange = $params->dateRange();
|
||||
|
||||
$this->repo->findList(
|
||||
$this->repo->expects($this->once())->method('findList')->with(
|
||||
new ShortUrlsListFiltering(10, 5, $orderBy, $searchTerm, $tags, TagsMode::ANY, $dateRange),
|
||||
)->shouldBeCalledOnce();
|
||||
);
|
||||
|
||||
$adapter->getSlice(5, 10);
|
||||
}
|
||||
|
||||
@ -72,12 +70,12 @@ class ShortUrlRepositoryAdapterTest extends TestCase
|
||||
'endDate' => $endDate,
|
||||
]);
|
||||
$apiKey = ApiKey::create();
|
||||
$adapter = new ShortUrlRepositoryAdapter($this->repo->reveal(), $params, $apiKey);
|
||||
$adapter = new ShortUrlRepositoryAdapter($this->repo, $params, $apiKey);
|
||||
$dateRange = $params->dateRange();
|
||||
|
||||
$this->repo->countList(
|
||||
$this->repo->expects($this->once())->method('countList')->with(
|
||||
new ShortUrlsCountFiltering($searchTerm, $tags, TagsMode::ANY, $dateRange, $apiKey),
|
||||
)->shouldBeCalledOnce();
|
||||
);
|
||||
$adapter->getNbResults();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user