urlShortener = $this->prophesize(UrlShortenerInterface::class); $this->action = new SingleStepCreateShortUrlAction( $this->urlShortener->reveal(), [ 'schema' => 'http', 'hostname' => 'foo.com', ], ); } /** @test */ public function properDataIsPassedWhenGeneratingShortCode(): void { $apiKey = new ApiKey(); $request = (new ServerRequest())->withQueryParams([ 'longUrl' => 'http://foobar.com', ])->withAttribute(ApiKey::class, $apiKey); $generateShortCode = $this->urlShortener->shorten( [], ShortUrlMeta::fromRawData(['apiKey' => $apiKey, 'longUrl' => 'http://foobar.com']), )->willReturn(ShortUrl::createEmpty()); $resp = $this->action->handle($request); self::assertEquals(200, $resp->getStatusCode()); $generateShortCode->shouldHaveBeenCalled(); } }