visitsHelper = $this->createMock(VisitsStatsHelperInterface::class); $this->action = new DomainVisitsAction($this->visitsHelper, 'the_default.com'); } /** * @test * @dataProvider provideDomainAuthorities */ public function providingCorrectDomainReturnsVisits(string $providedDomain, string $expectedDomain): void { $apiKey = ApiKey::create(); $this->visitsHelper->expects($this->once())->method('visitsForDomain')->with( $expectedDomain, $this->isInstanceOf(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()); } public function provideDomainAuthorities(): iterable { yield 'no default domain' => ['foo.com', 'foo.com']; yield 'default domain' => ['the_default.com', 'DEFAULT']; yield 'DEFAULT keyword' => ['DEFAULT', 'DEFAULT']; } }