mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-19 19:29:56 +09:00
Fixed some bugs in TemplateHandler class
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9274 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
18a01f4e35
commit
a9660e3fe3
2 changed files with 41 additions and 17 deletions
|
|
@ -103,11 +103,31 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
|
|||
'<dummy /><include target="../sample.html" /><div>This is another dummy</div>',
|
||||
'<dummy /><?php echo TemplateHandler::getInstance()->compile(\'tests/classes\',\'sample.html\') ?><div>This is another dummy</div>'
|
||||
),
|
||||
// <load target="../../../modules/page/lang/lang.xml">
|
||||
array(
|
||||
'<dummy /><load target="../../../modules/page/lang/lang.xml" /><dummy />',
|
||||
'<dummy /><?php Context::loadLang(\'modules/page/lang\'); ?><dummy />'
|
||||
),
|
||||
// <load target="style.css">
|
||||
array(
|
||||
'<dummy /><load target="css/style.css" /><dummy />',
|
||||
'<dummy /><!--#Meta:tests/classes/template/css/style.css--><?php $__tmp=array(\'tests/classes/template/css/style.css\',\'\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?><dummy />'
|
||||
),
|
||||
// <unload target="style.css">
|
||||
array(
|
||||
'<dummy /><unload target="css/style.css" /><dummy />',
|
||||
'<dummy /><?php Context::unloadFile(\'tests/classes/template/css/style.css\',\'\',\'\'); ?><dummy />'
|
||||
),
|
||||
// <!--%import("../script.js",type="body")-->
|
||||
array(
|
||||
'<dummy /><!--%import("../script.js",type="body")--><dummy />',
|
||||
'<dummy /><!--#Meta:tests/classes/script.js--><?php $__tmp=array(\'tests/classes/script.js\',\'body\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?><dummy />'
|
||||
),
|
||||
// <!--%unload("../script.js",type="body")-->
|
||||
array(
|
||||
'<dummy /><!--%unload("../script.js",type="body")--><dummy />',
|
||||
'<dummy /><?php Context::unloadFile(\'tests/classes/script.js\',\'\'); ?><dummy />'
|
||||
),
|
||||
// comment
|
||||
array(
|
||||
'<dummy_before /><!--// this is a comment--><dummy_after />',
|
||||
|
|
@ -118,12 +138,12 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
|
|||
'<meta charset="utf-8" cond="$foo">',
|
||||
'<?php if($__Context->foo){ ?><meta charset="utf-8"><?php } ?>'
|
||||
),
|
||||
// relative path
|
||||
// relative path1
|
||||
array(
|
||||
'<img src="http://naver.com/naver.gif"><input type="image" src="../local.gif" />',
|
||||
'<img src="http://naver.com/naver.gif"><input type="image" src="/xe/tests/classes/local.gif" />'
|
||||
),
|
||||
// relative path
|
||||
// relative path2
|
||||
array(
|
||||
'<img src="http://naver.com/naver.gif"><input type="image" src="../../dir/local.gif" />',
|
||||
'<img src="http://naver.com/naver.gif"><input type="image" src="/xe/tests/dir/local.gif" />'
|
||||
|
|
@ -136,7 +156,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
|
|||
// issue 103
|
||||
array(
|
||||
'<load target="http://aaa.com/aaa.js" />',
|
||||
'<?php $__tmp=array(\'http://aaa.com/aaa.js\',\'\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?>'
|
||||
'<!--#Meta:http://aaa.com/aaa.js--><?php $__tmp=array(\'http://aaa.com/aaa.js\',\'\',\'\',\'\',\'\',\'\',\'\');Context::loadFile($__tmp);unset($__tmp); ?>'
|
||||
),
|
||||
// issue 135
|
||||
array(
|
||||
|
|
@ -156,7 +176,7 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testParse($tpl, $expected)
|
||||
{
|
||||
$tmpl = new TemplateHandler();
|
||||
$tmpl = TemplateHandler::getInstance();
|
||||
$tmpl->init(dirname(__FILE__), 'sample.html');
|
||||
$result = $tmpl->parse($tpl, $expected);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue