deleter = $this->createMock(VisitsDeleterInterface::class); $this->action = new DeleteOrphanVisitsAction($this->deleter); } #[Test, DataProvider('provideVisitsCounts')] public function orphanVisitsAreDeleted(int $visitsCount): void { $apiKey = ApiKey::create(); $request = ServerRequestFactory::fromGlobals()->withAttribute(ApiKey::class, $apiKey); $this->deleter->expects($this->once())->method('deleteOrphanVisits')->with($apiKey)->willReturn( new BulkDeleteResult($visitsCount), ); /** @var JsonResponse $resp */ $resp = $this->action->handle($request); $payload = $resp->getPayload(); self::assertEquals(['deletedVisits' => $visitsCount], $payload); } public static function provideVisitsCounts(): iterable { yield '1' => [1]; yield '0' => [0]; yield '300' => [300]; yield '1234' => [1234]; } }