urlResolver = $this->prophesize(ShortUrlResolverInterface::class); $this->visitTracker = $this->prophesize(VisitsTracker::class); $this->action = new PixelAction( $this->urlResolver->reveal(), $this->visitTracker->reveal(), new AppOptions(), ); } /** @test */ public function imageIsReturned(): void { $shortCode = 'abc123'; $this->urlResolver->shortCodeToEnabledShortUrl($shortCode, '')->willReturn( new ShortUrl('http://domain.com/foo/bar'), )->shouldBeCalledOnce(); $this->visitTracker->track(Argument::cetera())->shouldBeCalledOnce(); $request = (new ServerRequest())->withAttribute('shortCode', $shortCode); $response = $this->action->process($request, $this->prophesize(RequestHandlerInterface::class)->reveal()); $this->assertInstanceOf(PixelResponse::class, $response); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('image/gif', $response->getHeaderLine('content-type')); } }