diff --git a/module/CLI/test/Command/Tag/CreateTagCommandTest.php b/module/CLI/test/Command/Tag/CreateTagCommandTest.php index 413f0970..6dab8d86 100644 --- a/module/CLI/test/Command/Tag/CreateTagCommandTest.php +++ b/module/CLI/test/Command/Tag/CreateTagCommandTest.php @@ -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); diff --git a/module/CLI/test/Command/Tag/ListTagsCommandTest.php b/module/CLI/test/Command/Tag/ListTagsCommandTest.php new file mode 100644 index 00000000..2c3a0a90 --- /dev/null +++ b/module/CLI/test/Command/Tag/ListTagsCommandTest.php @@ -0,0 +1,75 @@ +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(); + } +}