visitsHelper = $this->prophesize(VisitsStatsHelperInterface::class); $this->action = new DomainVisitsAction($this->visitsHelper->reveal(), 'the_default.com'); } /** * @test * @dataProvider provideDomainAuthorities */ public function providingCorrectDomainReturnsVisits(string $providedDomain, string $expectedDomain): void { $apiKey = ApiKey::create(); $getVisits = $this->visitsHelper->visitsForDomain( $expectedDomain, Argument::type(VisitsParams::class), $apiKey, )->willReturn(new Paginator(new ArrayAdapter([]))); $response = $this->action->handle( ServerRequestFactory::fromGlobals()->withAttribute('domain', $providedDomain) ->withAttribute(ApiKey::class, $apiKey), ); self::assertEquals(200, $response->getStatusCode()); $getVisits->shouldHaveBeenCalledOnce(); } public function provideDomainAuthorities(): iterable { yield 'no default domain' => ['foo.com', 'foo.com']; yield 'default domain' => ['the_default.com', 'DEFAULT']; yield 'DEFAULT keyword' => ['DEFAULT', 'DEFAULT']; } }