/**
  * @covers \PressBooks\Utility\template
  */
 public function test_template()
 {
     $template = \PressBooks\Utility\template(__DIR__ . '/data/template.php', ['title' => 'Foobar', 'body' => 'Hello World!']);
     $this->assertContains('<title>Foobar</title>', $template);
     $this->assertNotContains('<title></title>', $template);
     $this->assertContains("<body>Hello World!</body>", $template);
     $this->assertNotContains('<body></body>', $template);
     try {
         \PressBooks\Utility\template('/tmp/file/does/not/exist');
     } catch (\Exception $e) {
         $this->assertTrue(true);
         return;
     }
     $this->fail();
 }
Example #2
0
 /**
  * Simple template system.
  *
  * @param string $path
  * @param array $vars (optional)
  *
  * @return string
  * @throws \Exception
  */
 protected function loadTemplate($path, array $vars = array())
 {
     return \PressBooks\Utility\template($path, $vars);
 }