service = $this->prophesize(ShortUrlService::class); $this->action = new ListShortcodesAction($this->service->reveal(), Translator::factory([])); } /** * @test */ public function properListReturnsSuccessResponse() { $page = 3; $this->service->listShortUrls($page, null, [], null)->willReturn(new Paginator(new ArrayAdapter())) ->shouldBeCalledTimes(1); $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withQueryParams([ 'page' => $page, ])); $this->assertEquals(200, $response->getStatusCode()); } /** * @test */ public function anExceptionsReturnsErrorResponse() { $page = 3; $this->service->listShortUrls($page, null, [], null)->willThrow(\Exception::class) ->shouldBeCalledTimes(1); $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withQueryParams([ 'page' => $page, ])); $this->assertEquals(500, $response->getStatusCode()); } }