public function testGuessTemplateNameWithCascadingParentBundle()
 {
     $this->kernel->expects($this->at(1))->method('getBundle')->with($this->equalTo('BarBundle'), false)->will($this->returnValue(array($this->bundles['FooBarBundle'], $this->bundles['BarBundle'])));
     $this->kernel->expects($this->at(2))->method('getBundle')->with($this->equalTo('FooBundle'), false)->will($this->returnValue(array($this->bundles['FooBarBundle'], $this->bundles['BarBundle'], $this->bundles['FooBundle'])));
     $templateGuesser = new TemplateGuesser($this->kernel);
     $templateReference = $templateGuesser->guessTemplateName(array(new Fixture\FooBarBundle\Controller\FooBarController(), 'indexAction'), new Request());
     $this->assertEquals('FooBundle:FooBar:index.html.twig', (string) $templateReference);
 }
示例#2
0
 public function testGuessTemplateWithoutBundle()
 {
     $templateGuesser = new TemplateGuesser($this->kernel);
     $templateReference = $templateGuesser->guessTemplateName(array(new Fixture\Controller\OutOfBundleController(), 'indexAction'), new Request());
     $this->assertEquals(':OutOfBundle:index.html.twig', (string) $templateReference);
 }
示例#3
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage must be an array callable or an object defining the magic method __invoke. "object" given.
  */
 public function testInvalidController()
 {
     $this->kernel->getBundles();
     $templateGuesser = new TemplateGuesser($this->kernel);
     $templateReference = $templateGuesser->guessTemplateName(new Fixture\FooBundle\Controller\FooController(), new Request());
 }
 /**
  * @return string|TemplateReference
  */
 public function guessViewName()
 {
     $view = $this->guesser->guessTemplateName($this->controller, $this->request);
     return $view;
 }