/** * @param $html * @param $expect * @dataProvider dataForTestInject */ public function testInject($html, $expect) { // precondition $token = (new FormToken())->setName('token-name')->setValue('token-value'); // test $injector = new FormTokenInjector(); $actual = $injector->inject($html, $token); $this->assertSame($expect, $actual); }
/** * Event for kernel.response * @param FilterResponseEvent $event */ public function onKernelResponse(FilterResponseEvent $event) { /** @var $response Response */ $response = $event->getResponse(); $newContent = $this->formTokenInjector->inject($response->getContent(), $this->generate()); $response->setContent($newContent); }