shortUrlService = $this->createMock(ShortUrlServiceInterface::class); $this->action = new EditShortUrlAction( $this->shortUrlService, new ShortUrlDataTransformer(new ShortUrlStringifier()), new MapperBuilder()->mapper(), ); } #[Test] public function correctShortCodeReturnsSuccess(): void { $request = ServerRequestFactory::fromGlobals() ->withAttribute('shortCode', 'abc123') ->withAttribute(ApiKey::class, ApiKey::create()) ->withParsedBody(['maxVisits' => 5]); $this->shortUrlService->expects($this->once())->method('updateShortUrl')->willReturn(ShortUrl::createFake()); $resp = $this->action->handle($request); self::assertEquals(200, $resp->getStatusCode()); } }