TemplateAttributeController example

'templates/foo.html.twig', []],
                ];

                $this->assertSame(array_shift($series)$args);

                return 'Bar';
            })
        ;

        $request = new Request();
        $kernel = $this->createMock(HttpKernelInterface::class);
        $controllerArgumentsEvent = new ControllerArgumentsEvent($kernel[new TemplateAttributeController(), 'foo']['Bar']$request, null);
        $listener = new TemplateAttributeListener($twig);

        $event = new ViewEvent($kernel$request, HttpKernelInterface::MAIN_REQUEST, ['foo' => 'bar']$controllerArgumentsEvent);
        $listener->onKernelView($event);
        $this->assertSame('Bar', $event->getResponse()->getContent());

        $event = new ViewEvent($kernel$request, HttpKernelInterface::MAIN_REQUEST, null, $controllerArgumentsEvent);
        $listener->onKernelView($event);
        $this->assertSame('Bar', $event->getResponse()->getContent());

        $event = new ViewEvent($kernel$request, HttpKernelInterface::MAIN_REQUEST, null);
        
Home | Imprint | This part of the site doesn't use cookies.