getContext() public static method

Get last compiler context.
public static getContext ( ) : array\arraystring | integer>
return array\arraystring | integer>
 /**
  * @dataProvider issueProvider
  */
 public function testIssues($issue)
 {
     global $tmpdir;
     $php = LightnCandy::compile($issue['template'], isset($issue['options']) ? $issue['options'] : null);
     $context = LightnCandy::getContext();
     $parsed = print_r(LightnCandy::$lastParsed, true);
     if (count($context['error'])) {
         $this->fail('Compile failed due to:' . print_r($context['error'], true) . "\nPARSED: {$parsed}");
     }
     $renderer = LightnCandy::prepare($php);
     $this->assertEquals($issue['expected'], $renderer($issue['data'], array('debug' => $issue['debug'])), "PHP CODE:\n{$php}\n{$parsed}");
 }
Example #2
0
 /**
  * @dataProvider errorProvider
  */
 public function testErrors($test)
 {
     global $tmpdir;
     $php = LightnCandy::compile($test['template'], $test['options']);
     $context = LightnCandy::getContext();
     // This case should be compiled without error
     if (!isset($test['expected'])) {
         return;
     }
     $this->assertEquals($test['expected'], $context['error'], "Code: {$php}");
 }
Example #3
0
 /**
  * @dataProvider compileProvider
  */
 public function testUsedFeature($test)
 {
     LightnCandy::compile($test['template'], $test['options']);
     $context = LightnCandy::getContext();
     $this->assertEquals($test['expected'], $context['usedFeature']);
 }