Example #1
0
 public function testLoad()
 {
     $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . rand(111111, 999999);
     mkdir($dir, 0777, true);
     $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
     $loader->setDebugger($debugger = new \ProjectTemplateDebugger());
     $this->assertFalse($loader->load('foo'), '->load() returns false if the embed loader is not able to load the template');
     $loader->load('index');
     $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found');
     $loader->load('index');
     $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache');
 }
 public function testLoad()
 {
     $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . rand(111111, 999999);
     mkdir($dir, 0777, true);
     $loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
     $loader->setDebugger($debugger = new \ProjectTemplateDebugger());
     $this->assertFalse($loader->load('foo'), '->load() returns false if the embed loader is not able to load the template');
     $loader->load('index');
     $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found');
     $loader->load('index');
     $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache');
     // load() template compilation
     $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . rand(111111, 999999);
     mkdir($dir, 0777, true);
     $loader = new ProjectTemplateLoader(new CompilableTemplateLoader(), $dir);
     $loader->setDebugger($debugger = new \ProjectTemplateDebugger());
     $template = $loader->load('special', array('renderer' => 'comp'));
     $this->assertTrue($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found');
     $this->assertEquals('php', $template->getRenderer(), '->load() changes the renderer to php if the template is compilable');
     $template = $loader->load('special', array('renderer' => 'comp'));
     $this->assertTrue($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache');
     $this->assertEquals('php', $template->getRenderer(), '->load() changes the renderer to php if the template is compilable');
 }