コード例 #1
0
ファイル: EngineTest.php プロジェクト: zvax/templating
 public function testMixing()
 {
     $templateString = '{first}{$second}{$obj->third}';
     $engine = new Engine();
     $obj = new stdClass();
     $obj->third = 'sentence.';
     $string = $engine->render($templateString, ['first' => 'This ', 'second' => 'is a ', 'obj' => $obj]);
     $this->assertEquals('This is a sentence.', $string);
 }
コード例 #2
0
ファイル: SanityChecksTest.php プロジェクト: zvax/templating
 public function testEmptyValuesNotRender()
 {
     $engine = new Engine();
     $o = new \stdClass();
     $o->nullValue = null;
     $o->falseValue = false;
     $o->emptyString = '';
     $this->assertEquals('', $engine->render('{$this->nullValue}', $o));
     $this->assertEquals('', $engine->render('{$this->falseValue}', $o));
     $this->assertEquals('', $engine->render('{$this->emptyString}', $o));
     $a = ['nullValue' => null, 'falseValue' => false, 'emptyString' => ''];
     $this->assertEquals('', $engine->render('{$nullValue}', $a));
     $this->assertEquals('', $engine->render('{$falseValue}', $a));
     $this->assertEquals('', $engine->render('{$emptyString}', $a));
     $a = ['{zNullValue}' => null, '{zFalseValue}' => false, '{zEmptyString}' => ''];
     $this->assertEquals('', $engine->render('{zNullValue}', $a));
     $this->assertEquals('', $engine->render('{zFalseValue}', $a));
     $this->assertEquals('', $engine->render('{zEmptyString}', $a));
 }