diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index c15cde111578..77622099fedf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -67,4 +67,9 @@ public function templateAction(string $template, int $maxAge = null, int $shared return $response; } + + public function __invoke(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null): Response + { + return $this->templateAction($template, $maxAge, $sharedAge, $private); + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index 0bc068d76a55..a3abae0298e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -23,21 +23,23 @@ class TemplateControllerTest extends TestCase public function testTwig() { $twig = $this->getMockBuilder('Twig\Environment')->disableOriginalConstructor()->getMock(); - $twig->expects($this->once())->method('render')->willReturn('bar'); + $twig->expects($this->exactly(2))->method('render')->willReturn('bar'); $controller = new TemplateController($twig); $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); + $this->assertEquals('bar', $controller('mytemplate')->getContent()); } public function testTemplating() { $templating = $this->getMockBuilder(EngineInterface::class)->getMock(); - $templating->expects($this->once())->method('render')->willReturn('bar'); + $templating->expects($this->exactly(2))->method('render')->willReturn('bar'); $controller = new TemplateController(null, $templating); $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); + $this->assertEquals('bar', $controller('mytemplate')->getContent()); } /** @@ -49,5 +51,6 @@ public function testNoTwigNorTemplating() $controller = new TemplateController(); $controller->templateAction('mytemplate')->getContent(); + $controller('mytemplate')->getContent(); } }