shortUrlService = $this->prophesize(ShortUrlServiceInterface::class); $this->action = new EditShortUrlAction($this->shortUrlService->reveal(), []); } /** @test */ public function invalidDataThrowsError(): void { $request = (new ServerRequest())->withParsedBody([ 'maxVisits' => 'invalid', ]); $this->expectException(ValidationException::class); $this->action->handle($request); } /** @test */ public function correctShortCodeReturnsSuccess(): void { $request = (new ServerRequest())->withAttribute('shortCode', 'abc123') ->withAttribute(ApiKey::class, new ApiKey()) ->withParsedBody([ 'maxVisits' => 5, ]); $updateMeta = $this->shortUrlService->updateShortUrl(Argument::cetera())->willReturn( ShortUrl::createEmpty(), ); $resp = $this->action->handle($request); self::assertEquals(200, $resp->getStatusCode()); $updateMeta->shouldHaveBeenCalled(); } }