use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelInterface;
class DisallowRobotsIndexingListenerTest extends TestCase
{ /**
* @dataProvider provideResponses
*/
public function testInvoke(?string
$expected, array
$responseArgs) { $response =
new Response(...
$responseArgs);
$listener =
new DisallowRobotsIndexingListener();
$event =
new ResponseEvent($this->
createMock(HttpKernelInterface::
class),
new Request(), KernelInterface::MAIN_REQUEST,
$response);
$listener->
onResponse($event);
$this->
assertSame($expected,
$response->headers->
get('X-Robots-Tag'
), 'Header doesn\'t match expectations'
);
} public static function provideResponses(): iterable
{ yield 'No header' =>
['noindex',
[]];