mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Created ListTagsCommand
This commit is contained in:
parent
b37f303e76
commit
095d8e73b8
2 changed files with 78 additions and 3 deletions
|
@ -55,12 +55,12 @@ class CreateTagCommandTest extends TestCase
|
|||
public function serviceIsInvokedOnSuccess()
|
||||
{
|
||||
$tagNames = ['foo', 'bar'];
|
||||
$this->commandTester->execute([
|
||||
'--name' => $tagNames,
|
||||
]);
|
||||
/** @var MethodProphecy $createTags */
|
||||
$createTags = $this->tagService->createTags($tagNames)->willReturn([]);
|
||||
|
||||
$this->commandTester->execute([
|
||||
'--name' => $tagNames,
|
||||
]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains(sprintf('Created tags: ["%s"]', implode('", "', $tagNames)), $output);
|
||||
|
|
75
module/CLI/test/Command/Tag/ListTagsCommandTest.php
Normal file
75
module/CLI/test/Command/Tag/ListTagsCommandTest.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
|
||||
|
||||
use Prophecy\Prophecy\MethodProphecy;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\CLI\Command\Tag\ListTagsCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Zend\I18n\Translator\Translator;
|
||||
|
||||
class ListTagsCommandTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ListTagsCommand
|
||||
*/
|
||||
private $command;
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $commandTester;
|
||||
/**
|
||||
* @var ObjectProphecy
|
||||
*/
|
||||
private $tagService;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->tagService = $this->prophesize(TagServiceInterface::class);
|
||||
|
||||
$command = new ListTagsCommand($this->tagService->reveal(), Translator::factory([]));
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
|
||||
$this->commandTester = new CommandTester($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function noTagsPrintsEmptyMessage()
|
||||
{
|
||||
/** @var MethodProphecy $listTags */
|
||||
$listTags = $this->tagService->listTags()->willReturn([]);
|
||||
|
||||
$this->commandTester->execute([]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('No tags yet', $output);
|
||||
$listTags->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function listOfTagsIsPrinted()
|
||||
{
|
||||
/** @var MethodProphecy $listTags */
|
||||
$listTags = $this->tagService->listTags()->willReturn([
|
||||
(new Tag())->setName('foo'),
|
||||
(new Tag())->setName('bar'),
|
||||
]);
|
||||
|
||||
$this->commandTester->execute([]);
|
||||
$output = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertContains('foo', $output);
|
||||
$this->assertContains('bar', $output);
|
||||
$listTags->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue