Example #1
0
 public function testThatDefaultErrorTemplateRespectsCustomDelimiters()
 {
     $this->loader->addTemplate('template', '{*');
     ob_start();
     try {
         $this->env->render('template');
     } catch (TemplatingException $e) {
         $this->fail();
     }
     ob_end_clean();
 }
Example #2
0
 /**
  * @test
  * @dataProvider getTests
  */
 public function runIntegrationTests($file, $description, $templates, $data, $expectation, $exception, $exceptionMessage)
 {
     //global counter to provide random namespaces to avoid class name collision
     $options = $this->optionsProperty->getValue($this->environment);
     $options['cache_namespace'] = 'test_' . ++self::$counter;
     $this->optionsProperty->setValue($this->environment, $options);
     foreach ($templates as $name => $template) {
         $this->stringLoader->addTemplate($name, $template);
     }
     if ($data) {
         eval('$data = ' . $data . ';');
     } else {
         $data = [];
     }
     if ($exception) {
         $this->setExpectedException($exception, $exceptionMessage);
     }
     $obLevel = ob_get_level();
     try {
         ob_start();
         $this->environment->render('index', $data);
         $output = rtrim(ob_get_clean(), "\n");
         if ($expectation) {
             $this->assertEquals($expectation, $output, $description . ' (' . $file . ')');
         }
     } catch (\Exception $e) {
         if (ob_get_level() !== $obLevel) {
             ob_end_clean();
         }
         throw $e;
     }
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function setEnvironment(Environment $environment)
 {
     parent::setEnvironment($environment);
     $this->addTemplate('__compile_error_template', $this->getCompileErrorTemplate($environment->getOption('delimiters'), $environment->getOption('block_end_prefix')));
 }