mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Created ListTagsActionTest
This commit is contained in:
50
module/Rest/test/Action/ListTagsActionTest.php
Normal file
50
module/Rest/test/Action/ListTagsActionTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace ShlinkioTest\Shlink\Rest\Action;
|
||||
|
||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Prophecy\MethodProphecy;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
|
||||
use Shlinkio\Shlink\Rest\Action\ListTagsAction;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
|
||||
class ListTagsActionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ListTagsAction
|
||||
*/
|
||||
private $action;
|
||||
/**
|
||||
* @var ObjectProphecy
|
||||
*/
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
$this->action = new ListTagsAction($this->tagService->reveal());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsDataFromService()
|
||||
{
|
||||
/** @var MethodProphecy $listTags */
|
||||
$listTags = $this->tagService->listTags()->willReturn([new Tag('foo'), new Tag('bar')]);
|
||||
|
||||
$resp = $this->action->process(
|
||||
ServerRequestFactory::fromGlobals(),
|
||||
$this->prophesize(DelegateInterface::class)->reveal()
|
||||
);
|
||||
|
||||
$this->assertEquals([
|
||||
'tags' => [
|
||||
'data' => ['foo', 'bar'],
|
||||
],
|
||||
], \json_decode((string) $resp->getBody(), true));
|
||||
$listTags->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user