From 5c7962966d6fa1e545362c3c2f0ee7945e0ba40f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 7 Jul 2017 13:28:58 +0200 Subject: [PATCH] Created ListTagsActionTest --- .../Factory/InstallApplicationFactoryTest.php | 2 - module/Core/src/Entity/Tag.php | 5 ++ .../Core/test/Service/Tag/TagServiceTest.php | 2 - .../Rest/test/Action/ListTagsActionTest.php | 50 +++++++++++++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 module/Rest/test/Action/ListTagsActionTest.php diff --git a/module/CLI/test/Factory/InstallApplicationFactoryTest.php b/module/CLI/test/Factory/InstallApplicationFactoryTest.php index 35820bba..c7e87bc7 100644 --- a/module/CLI/test/Factory/InstallApplicationFactoryTest.php +++ b/module/CLI/test/Factory/InstallApplicationFactoryTest.php @@ -1,6 +1,4 @@ name = $name; + } + /** * @return string */ diff --git a/module/Core/test/Service/Tag/TagServiceTest.php b/module/Core/test/Service/Tag/TagServiceTest.php index 2a629c4f..d111afbb 100644 --- a/module/Core/test/Service/Tag/TagServiceTest.php +++ b/module/Core/test/Service/Tag/TagServiceTest.php @@ -1,6 +1,4 @@ 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(); + } +}