visitsHelper = $this->prophesize(VisitsStatsHelperInterface::class); $this->orphanVisitTransformer = $this->prophesize(DataTransformerInterface::class); $this->action = new OrphanVisitsAction($this->visitsHelper->reveal(), $this->orphanVisitTransformer->reveal()); } /** @test */ public function requestIsHandled(): void { $visitor = Visitor::emptyInstance(); $visits = [Visit::forInvalidShortUrl($visitor), Visit::forRegularNotFound($visitor)]; $orphanVisits = $this->visitsHelper->orphanVisits(Argument::type(VisitsParams::class))->willReturn( new Paginator(new ArrayAdapter($visits)), ); $transform = $this->orphanVisitTransformer->transform(Argument::type(Visit::class))->willReturn([]); $response = $this->action->handle(ServerRequestFactory::fromGlobals()); self::assertInstanceOf(JsonResponse::class, $response); self::assertEquals(200, $response->getStatusCode()); $orphanVisits->shouldHaveBeenCalledOnce(); $transform->shouldHaveBeenCalledTimes(count($visits)); } }