urlResolver = $this->createMock(ShortUrlResolverInterface::class); $this->action = new ResolveShortUrlAction($this->urlResolver, new ShortUrlDataTransformer( new ShortUrlStringifier([]), )); } #[Test] public function correctShortCodeReturnsSuccess(): void { $shortCode = 'abc123'; $apiKey = ApiKey::create(); $this->urlResolver->expects($this->once())->method('resolveShortUrl')->with( ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), $apiKey, )->willReturn(ShortUrl::withLongUrl('http://domain.com/foo/bar')); $request = (new ServerRequest())->withAttribute('shortCode', $shortCode)->withAttribute(ApiKey::class, $apiKey); $response = $this->action->handle($request); self::assertEquals(200, $response->getStatusCode()); self::assertStringContainsString('http://domain.com/foo/bar', $response->getBody()->getContents()); } }