helper = $this->createMock(CrawlingHelperInterface::class); } #[Test, DataProvider('provideShortCodes')] public function buildsRobotsLinesFromCrawlableShortCodes( array $shortCodes, bool $allowAllShortUrls, string $expected, ): void { $this->helper ->expects($allowAllShortUrls ? $this->never() : $this->once()) ->method('listCrawlableShortCodes') ->willReturn($shortCodes); $response = $this->action($allowAllShortUrls)->handle(ServerRequestFactory::fromGlobals()); self::assertEquals(200, $response->getStatusCode()); self::assertEquals($expected, $response->getBody()->__toString()); self::assertEquals('text/plain', $response->getHeaderLine('Content-Type')); } public static function provideShortCodes(): iterable { yield 'three short codes' => [['foo', 'bar', 'baz'], false, << [['foo', 'bar', 'some', 'thing', 'baz'], false, << [[], false, << [['foo', 'bar', 'some'], true, << [[], true, <<helper, allowAllShortUrls: $allowAllShortUrls); } }