예제 #1
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);
 }
예제 #2
0
 /**
  * @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();
 }