urlResolver = $this->createMock(ShortUrlResolverInterface::class); $this->requestTracker = $this->createMock(RequestTrackerInterface::class); $this->action = new PixelAction($this->urlResolver, $this->requestTracker); } #[Test] public function imageIsReturned(): void { $shortCode = 'abc123'; $this->urlResolver->expects($this->once())->method('resolveEnabledShortUrl')->with( ShortUrlIdentifier::fromShortCodeAndDomain($shortCode, ''), )->willReturn(ShortUrl::withLongUrl('http://domain.com/foo/bar')); $this->requestTracker->expects($this->once())->method('trackIfApplicable')->withAnyParameters(); $request = (new ServerRequest())->withAttribute('shortCode', $shortCode); $response = $this->action->process($request, $this->createMock(RequestHandlerInterface::class)); self::assertInstanceOf(PixelResponse::class, $response); self::assertEquals(200, $response->getStatusCode()); self::assertEquals('image/gif', $response->getHeaderLine('content-type')); } }