Пример #1
0
 public function testExists()
 {
     $loader1 = $this->getMock('Twig_Loader_Array', array('exists', 'getSource'), array(), '', false);
     $loader1->expects($this->once())->method('exists')->will($this->returnValue(false));
     $loader1->expects($this->never())->method('getSource');
     $loader2 = $this->getMock('Twig_LoaderInterface');
     $loader2->expects($this->once())->method('getSource')->will($this->returnValue('content'));
     $loader = new Twig_Loader_Chain();
     $loader->addLoader($loader1);
     $loader->addLoader($loader2);
     $this->assertTrue($loader->exists('foo'));
 }
Пример #2
0
 public function testExists()
 {
     $loader1 = $this->getMockBuilder('Twig_Loader_Array')->setMethods(array('exists', 'getSource'))->disableOriginalConstructor()->getMock();
     $loader1->expects($this->once())->method('exists')->will($this->returnValue(false));
     $loader1->expects($this->never())->method('getSource');
     $loader2 = $this->getMockBuilder('Twig_LoaderInterface')->getMock();
     $loader2->expects($this->once())->method('getSource')->will($this->returnValue('content'));
     $loader = new Twig_Loader_Chain();
     $loader->addLoader($loader1);
     $loader->addLoader($loader2);
     $this->assertTrue($loader->exists('foo'));
 }
Пример #3
0
 /**
  * Gets template names of templates that are present in the viewed profile.
  *
  * @param \Symfony\Component\HttpKernel\Profiler\Profile $profile
  *
  * @return array
  *
  * @throws \UnexpectedValueException
  */
 protected function getNames(Profile $profile)
 {
     $templates = [];
     foreach ($this->templates as $arguments) {
         if (NULL === $arguments) {
             continue;
         }
         list($name, $template) = $arguments;
         if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
             continue;
         }
         if ('.html.twig' === substr($template, -10)) {
             $template = substr($template, 0, -10);
         }
         if (!$this->twigLoader->exists($template . '.html.twig')) {
             throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
         }
         $templates[$name] = $template . '.html.twig';
     }
     return $templates;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function exists($name)
 {
     return $this->chainLoader->exists($name);
 }