urlShortener = $this->prophesize(UrlShortener::class); $this->action = new ResolveShortUrlAction($this->urlShortener->reveal(), []); } /** @test */ public function correctShortCodeReturnsSuccess(): void { $shortCode = 'abc123'; $this->urlShortener->shortCodeToUrl($shortCode, null)->willReturn( new ShortUrl('http://domain.com/foo/bar') )->shouldBeCalledOnce(); $request = (new ServerRequest())->withAttribute('shortCode', $shortCode); $response = $this->action->handle($request); $this->assertEquals(200, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), 'http://domain.com/foo/bar') > 0); } }