visitsHelper = $this->createMock(VisitsStatsHelperInterface::class); $this->orphanVisitTransformer = $this->createMock(DataTransformerInterface::class); $this->action = new OrphanVisitsAction($this->visitsHelper, $this->orphanVisitTransformer); } /** @test */ public function requestIsHandled(): void { $visitor = Visitor::emptyInstance(); $visits = [Visit::forInvalidShortUrl($visitor), Visit::forRegularNotFound($visitor)]; $this->visitsHelper->expects($this->once())->method('orphanVisits')->with( $this->isInstanceOf(VisitsParams::class), )->willReturn(new Paginator(new ArrayAdapter($visits))); $visitsAmount = count($visits); $this->orphanVisitTransformer->expects($this->exactly($visitsAmount))->method('transform')->with( $this->isInstanceOf(Visit::class), )->willReturn([]); /** @var JsonResponse $response */ $response = $this->action->handle(ServerRequestFactory::fromGlobals()); $payload = $response->getPayload(); self::assertCount($visitsAmount, $payload['visits']['data']); self::assertEquals(200, $response->getStatusCode()); } }