mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 08:56:42 -06:00
Created TagVisitsActionTest
This commit is contained in:
parent
9b9de8e290
commit
7f39e6d768
41
module/Rest/test/Action/Visit/TagVisitsActionTest.php
Normal file
41
module/Rest/test/Action/Visit/TagVisitsActionTest.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Rest\Action\Visit;
|
||||
|
||||
use Laminas\Diactoros\ServerRequest;
|
||||
use Laminas\Paginator\Adapter\ArrayAdapter;
|
||||
use Laminas\Paginator\Paginator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Core\Model\VisitsParams;
|
||||
use Shlinkio\Shlink\Core\Service\VisitsTracker;
|
||||
use Shlinkio\Shlink\Rest\Action\Visit\TagVisitsAction;
|
||||
|
||||
class TagVisitsActionTest extends TestCase
|
||||
{
|
||||
private TagVisitsAction $action;
|
||||
private ObjectProphecy $visitsTracker;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->visitsTracker = $this->prophesize(VisitsTracker::class);
|
||||
$this->action = new TagVisitsAction($this->visitsTracker->reveal());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function providingCorrectShortCodeReturnsVisits(): void
|
||||
{
|
||||
$tag = 'foo';
|
||||
$getVisits = $this->visitsTracker->visitsForTag($tag, Argument::type(VisitsParams::class))->willReturn(
|
||||
new Paginator(new ArrayAdapter([])),
|
||||
);
|
||||
|
||||
$response = $this->action->handle((new ServerRequest())->withAttribute('tag', $tag));
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$getVisits->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user