From 575509c45b797be79a011d16ac2643b9d3965749 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 15 Jul 2017 09:12:07 +0200 Subject: [PATCH] Created CreateTagsActiontest --- .../test/Action/Tag/CreateTagsActionTest.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 module/Rest/test/Action/Tag/CreateTagsActionTest.php diff --git a/module/Rest/test/Action/Tag/CreateTagsActionTest.php b/module/Rest/test/Action/Tag/CreateTagsActionTest.php new file mode 100644 index 00000000..795827fa --- /dev/null +++ b/module/Rest/test/Action/Tag/CreateTagsActionTest.php @@ -0,0 +1,58 @@ +tagService = $this->prophesize(TagServiceInterface::class); + $this->action = new CreateTagsAction($this->tagService->reveal()); + } + + /** + * @test + * @dataProvider provideTags + * @param array|null $tags + */ + public function processDelegatesIntoService($tags) + { + $request = ServerRequestFactory::fromGlobals()->withParsedBody(['tags' => $tags]); + /** @var MethodProphecy $deleteTags */ + $deleteTags = $this->tagService->createTags($tags ?: [])->willReturn(new ArrayCollection()); + + $response = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + + $this->assertEquals(200, $response->getStatusCode()); + $deleteTags->shouldHaveBeenCalled(); + } + + public function provideTags() + { + return [ + [['foo', 'bar', 'baz']], + [['some', 'thing']], + [null], + [[]], + ]; + } +}