Example #1
0
 function test_local()
 {
     $root = dirname(__FILE__) . '/templates/';
     $file_system = new LiquidLocalFileSystem($root);
     $this->assertEqual($root . "mypartial.tpl", $file_system->full_path("mypartial"));
     $this->assertEqual($root . "dir/mypartial.tpl", $file_system->full_path("dir/mypartial"));
     try {
         $file_system->full_path('../dir/mypartial');
         $this->fail();
     } catch (Exception $e) {
         $this->assertEqual($e->getMessage(), "Illegal template name '../dir/mypartial'");
     }
     try {
         $file_system->full_path("/dir/../../dir/mypartial");
         $this->fail();
     } catch (Exception $e) {
         $this->assertEqual($e->getMessage(), "Illegal template name '/dir/../../dir/mypartial'");
     }
     try {
         $file_system->full_path("/etc/passwd");
         $this->fail();
     } catch (Exception $e) {
         $this->assertEqual($e->getMessage(), "Illegal template name '/etc/passwd'");
     }
 }
Example #2
0
 function test_local()
 {
     $root = dirname(__FILE__) . '/templates/';
     $file_system = new LiquidLocalFileSystem($root);
     $this->assertEqual($root . "_mypartial.liquid", $file_system->full_path("mypartial"));
     $this->assertEqual($root . "dir/_mypartial.liquid", $file_system->full_path("dir/mypartial"));
     $root = dirname(__FILE__) . '/dir/templates/';
     $file_system->full_path('../dir/mypartial');
     $this->assertError("Illegal template name '../dir/mypartial'");
     $file_system->full_path("/dir/../../dir/mypartial");
     $this->assertError();
     $file_system->full_path("/etc/passwd");
     $this->assertError();
 }