urlResolver = $this->prophesize(ShortUrlResolverInterface::class); $this->action = new ResolveShortUrlAction($this->urlResolver->reveal(), new ShortUrlDataTransformer( new ShortUrlStringifier([]), )); } /** @test */ public function correctShortCodeReturnsSuccess(): void { $shortCode = 'abc123'; $apiKey = ApiKey::create(); $this->urlResolver->resolveShortUrl(new ShortUrlIdentifier($shortCode), $apiKey)->willReturn( ShortUrl::withLongUrl('http://domain.com/foo/bar'), )->shouldBeCalledOnce(); $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()); } }