diff --git a/module/Core/test/Action/PixelActionTest.php b/module/Core/test/Action/PixelActionTest.php new file mode 100644 index 00000000..1a7f7296 --- /dev/null +++ b/module/Core/test/Action/PixelActionTest.php @@ -0,0 +1,63 @@ +urlShortener = $this->prophesize(UrlShortener::class); + $this->visitTracker = $this->prophesize(VisitsTracker::class); + + $this->action = new PixelAction( + $this->urlShortener->reveal(), + $this->visitTracker->reveal(), + new AppOptions() + ); + } + + /** + * @test + */ + public function imageIsReturned() + { + $shortCode = 'abc123'; + $this->urlShortener->shortCodeToUrl($shortCode)->willReturn('http://domain.com/foo/bar') + ->shouldBeCalledTimes(1); + $this->visitTracker->track(Argument::cetera())->willReturn(null) + ->shouldBeCalledTimes(1); + + $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); + $response = $this->action->process($request, TestUtils::createReqHandlerMock()->reveal()); + + $this->assertInstanceOf(PixelResponse::class, $response); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals('image/gif', $response->getHeaderLine('content-type')); + } +}