helper = $this->createMock(CrawlingHelperInterface::class); } #[Test, DataProvider('provideShortCodes')] public function buildsRobotsLinesFromCrawlableShortCodes( array $shortCodes, RobotsOptions $options, string $expected, ): void { $this->helper ->expects($options->allowAllShortUrls ? $this->never() : $this->once()) ->method('listCrawlableShortCodes') ->willReturn($shortCodes); $response = $this->action($options)->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'], new RobotsOptions(), << [['foo', 'bar', 'some', 'thing', 'baz'], new RobotsOptions(), << [[], new RobotsOptions(), << [ ['foo', 'bar', 'some'], new RobotsOptions(allowAllShortUrls: true), << [[], new RobotsOptions(allowAllShortUrls: true), << [[], new RobotsOptions(userAgents: ['foo', 'bar']), <<helper, $options); } }