mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
add and rework tests
add spacing tests for newlines between tags and text 3.1.32-dev-36
This commit is contained in:
@@ -32,6 +32,6 @@ class SmartyBcTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testSmartyPhpTag()
|
public function testSmartyPhpTag()
|
||||||
{
|
{
|
||||||
$this->assertEquals('hello world', $this->smartyBC->fetch('eval:{php} echo "hello world"; {/php}'));
|
$this->assertEquals('hello world', $this->smartyBC->fetch('string:{php} echo "hello world"; {/php}'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
* class for spacing test
|
* class for spacing test
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcess
|
* @runTestsInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @backupStaticAttributes enabled
|
* @backupStaticAttributes enabled
|
||||||
*/
|
*/
|
||||||
class SpacingTest extends PHPUnit_Smarty
|
class SpacingTest extends PHPUnit_Smarty
|
||||||
@@ -18,92 +18,60 @@ class SpacingTest extends PHPUnit_Smarty
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
$this->smarty->assign('foo', 'bar');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testInit()
|
public function testInit()
|
||||||
{
|
{
|
||||||
$this->cleanDirs();
|
$this->cleanDirs();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* test variable output
|
|
||||||
*/
|
|
||||||
public function testVariableSpacing1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:{\$foo}", null, null, $this->smarty);
|
|
||||||
$this->assertEquals("bar", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVariableSpacing2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:{\$foo}{\$foo}", null, null, $this->smarty);
|
|
||||||
$this->assertEquals("barbar", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVariableSpacing3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:{\$foo} {\$foo}", null, null, $this->smarty);
|
|
||||||
$this->assertEquals("bar bar", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test variable text combinations
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
public function testVariableText1()
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:A{\$foo}B", null, null, $this->smarty);
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
$this->assertEquals("AbarB", $this->smarty->fetch($tpl));
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->template_dir = './templates_tmp';
|
||||||
|
$this->smarty->assign('file', $file);
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testVariableText2()
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:A {\$foo}B", null, null, $this->smarty);
|
$i = 1;
|
||||||
$this->assertEquals("A barB", $this->smarty->fetch($tpl));
|
/*
|
||||||
}
|
* Code
|
||||||
|
* result
|
||||||
public function testVariableText3()
|
* test name
|
||||||
{
|
* test number
|
||||||
$tpl = $this->smarty->createTemplate("eval:A{\$foo} B", null, null, $this->smarty);
|
*/
|
||||||
$this->assertEquals("Abar B", $this->smarty->fetch($tpl));
|
return array(array('{$foo}', 'bar', 'T1', $i++),
|
||||||
}
|
array('{$foo}{$foo}', 'barbar', 'T2', $i++),
|
||||||
|
array('A{$foo}{$foo}B', 'AbarbarB', 'T3', $i++),
|
||||||
public function testVariableText4()
|
array('{$foo} {$foo}', 'bar bar', 'T4', $i++),
|
||||||
{
|
array('A{$foo}B', 'AbarB', 'T5', $i++),
|
||||||
$tpl = $this->smarty->createTemplate("eval:A{\$foo}\nB", null, null, $this->smarty);
|
array('A{counter}B', 'A1B', 'T6', $i++),
|
||||||
$this->assertEquals("Abar\nB", $this->smarty->fetch($tpl));
|
array('A {$foo}B', 'A barB', 'T7', $i++),
|
||||||
}
|
array('A{$foo} B', 'Abar B', 'T8', $i++),
|
||||||
|
array("A{\$foo}\nB", "Abar\nB", 'T9', $i++),
|
||||||
public function testVariableText5()
|
array("A{counter start=1}\nB", "A1\nB", 'T10', $i++),
|
||||||
{
|
array("A{\$foo}B\nC", "AbarB\nC", 'T11', $i++),
|
||||||
$tpl = $this->smarty->createTemplate("eval:A{\$foo}B\nC", null, null, $this->smarty);
|
array("A{assign var=zoo value='blah'}B", "AB", 'T12', $i++),
|
||||||
$this->assertEquals("AbarB\nC", $this->smarty->fetch($tpl));
|
array("A\n{assign var=zoo value='blah'}\nB", "A\nB", 'T13', $i++),
|
||||||
}
|
array("E{assign var=zoo value='blah'}\nF", "EF", 'T14', $i++),
|
||||||
|
array("G\n{assign var=zoo value='blah'}H", "G\nH", 'T15', $i++),
|
||||||
/**
|
);
|
||||||
* test tag text combinations
|
|
||||||
*/
|
|
||||||
public function testTagText1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:A{assign var=zoo value='blah'}B");
|
|
||||||
$this->assertEquals("AB", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagText2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("string:A\n{assign var=zoo value='blah'}\nB");
|
|
||||||
$this->assertEquals("A\nB", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagText3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:E{assign var=zoo value='blah'}\nF");
|
|
||||||
$this->assertEquals("EF", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testTagText4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:G\n{assign var=zoo value='blah'}H");
|
|
||||||
$this->assertEquals("G\nH", $this->smarty->fetch($tpl));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -31,16 +31,17 @@ class CompileAppendTest extends PHPUnit_Smarty
|
|||||||
/**
|
/**
|
||||||
* Test {append} tags
|
* Test {append} tags
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestAppend
|
* @dataProvider dataTestAppend
|
||||||
*/
|
*/
|
||||||
public function testAppend($code, $result, $testName, $testNumber)
|
public function testAppend($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$file = "testAppend_{$testNumber}.tpl";
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Append_{$name}.tpl";
|
||||||
$this->makeTemplateFile($file, $code);
|
$this->makeTemplateFile($file, $code);
|
||||||
$this->smarty->assignGlobal('file', $file);
|
$this->smarty->assignGlobal('file', $file);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "testAppend - {$code} - {$testName}");
|
$this->assertEquals($result, $this->smarty->fetch($file), "testAppend - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -55,11 +56,94 @@ class CompileAppendTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
return array(// old format
|
return array(// old format
|
||||||
array('{$foo=1}{append var=foo value=2}{$foo|var_export:true}', 'array(0=>1,1=>2,)', '', $i ++),
|
array('{$foo=1}{append var=foo value=2}{$foo|var_export:true}', var_export(array(0=>1,1=>2,),true), '', $i ++),
|
||||||
array('{append var=foo value=2}{$foo|var_export:true}', 'array(0=>2,)', '', $i ++),
|
array('{$foo[\'i\']=1}{append var=foo value=2 index=\'j\'}{$foo|var_export:true}', var_export(array('i'=>1,'j'=>2,),true), '', $i ++),
|
||||||
array('{append foo value=3}{$foo|var_export:true}', 'array(0=>3,)', '', $i ++),
|
array('{$bar=\'j\'}{$foo[\'i\']=1}{append var=foo value=2 index=$bar}{$foo|var_export:true}', var_export(array('i'=>1,'j'=>2,),true), '', $i ++),
|
||||||
array('{append foo 5}{$foo|var_export:true}', 'array(0=>5,)', '', $i ++), // new format
|
array('{append var=foo value=2}{$foo|var_export:true}', var_export(array(0=>2,),true), '', $i ++),
|
||||||
array('{$foo[]=2}{$foo|var_export:true}', 'array(0=>2,)', '', $i ++),
|
array('{append foo value=3}{$foo|var_export:true}', var_export(array(0=>3,),true), '', $i ++),
|
||||||
|
array('{append foo 5}{$foo|var_export:true}', var_export(array(0=>5,),true), '', $i ++), // new format
|
||||||
|
array('{$foo[]=2}{$foo|var_export:true}', var_export(array(0=>2,),true), '', $i ++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Assign spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testAppendSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Append nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testAppendSpacingNocache($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('1');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar',true);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Append nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testAppendSpacingNocache2($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('1');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo',true);
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array("A{append var=buh value=\$foo}B{\$buh[0]}", "ABbar", 'Text', $i++),
|
||||||
|
array("A\n{append var=buh value=\$foo}\nB{\$buh[0]}", "A\nBbar", 'Newline1', $i++),
|
||||||
|
array("E{append var=buh value=\$foo}\nF{\$buh[0]}", "EFbar", 'Newline2', $i++),
|
||||||
|
array("G\n{append var=buh value=\$foo}H{\$buh[0]}", "G\nHbar", 'Newline3', $i++),
|
||||||
|
array("A{\$buh[]=\$foo}B{\$buh[0]}", "ABbar", '2_Text', $i++),
|
||||||
|
array("A\n{\$buh[]=\$foo}\nB{\$buh[0]}", "A\nBbar", '2_Newline1', $i++),
|
||||||
|
array("E{\$buh[]=\$foo}\nF{\$buh[0]}", "EFbar", '2_Newline2', $i++),
|
||||||
|
array("G\n{\$buh[]=\$foo}H{\$buh[0]}", "G\nHbar", '2_Newline3', $i++),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
tests/UnitTests/TemplateSource/TagTests/Append/cache/dummy.txt
vendored
Normal file
1
tests/UnitTests/TemplateSource/TagTests/Append/cache/dummy.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
class CompileAssignTest extends PHPUnit_Smarty
|
class CompileAssignTest extends PHPUnit_Smarty
|
||||||
{
|
{
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
@@ -38,11 +37,11 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testAssign($code, $result, $testName, $testNumber)
|
public function testAssign($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$file = "testAssign_{$testNumber}.tpl";
|
$file = "Assign_{$testNumber}.tpl";
|
||||||
$this->makeTemplateFile($file, $code);
|
$this->makeTemplateFile($file, $code);
|
||||||
$this->smarty->assignGlobal('file', $file);
|
$this->smarty->assignGlobal('file', $file);
|
||||||
$this->smarty->assign('bar', 'buh');
|
$this->smarty->assign('bar', 'buh');
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "testAssign - {$code} - {$testName}");
|
$this->assertEquals($result, $this->smarty->fetch($file), "testAssign - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -57,30 +56,113 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
return array(// old format
|
return array(// old format
|
||||||
array('{assign var=foo value=1}{$foo}', '1', '', $i ++),
|
array('{assign var=foo value=1}{$foo}', '1', '', $i++),
|
||||||
array('{assign var=\'foo\' value=2}{$foo}', '2', '', $i ++),
|
array('{assign var=\'foo\' value=2}{$foo}', '2', '', $i++),
|
||||||
array('{assign var="foo" value=3}{$foo}', '3', '', $i ++),
|
array('{assign var="foo" value=3}{$foo}', '3', '', $i++),
|
||||||
array('{assign var=foo value=$bar}{$foo}', 'buh', '', $i ++),
|
array('{assign var=foo value=$bar}{$foo}', 'buh', '', $i++),
|
||||||
array('{assign var=$bar value=11}{$buh}', '11', '', $i ++),
|
array('{assign var=$bar value=11}{$buh}', '11', '', $i++),
|
||||||
array('{assign var=foo value=bar}{$foo}', 'bar', '', $i ++),
|
array('{assign var=foo value=bar}{$foo}', 'bar', '', $i++),
|
||||||
array('{assign var=foo value=1+2}{$foo}', '3', '', $i ++),
|
array('{assign var=foo value=1+2}{$foo}', '3', '', $i++),
|
||||||
array('{assign var=foo value=strlen(\'barbuh\')}{$foo}', '6', '', $i ++),
|
array('{assign var=foo value=strlen(\'barbuh\')}{$foo}', '6', '', $i++),
|
||||||
array('{assign var=foo value=\'barr\'|strlen}{$foo}', '4', '', $i ++),
|
array('{assign var=foo value=\'barr\'|strlen}{$foo}', '4', '', $i++),
|
||||||
array('{assign var=foo value=[9,8,7,6]}{$foo|var_export:true}', 'array(0=>9,1=>8,2=>7,3=>6,)', '', $i ++),
|
array('{assign var=foo value=[9,8,7,6]}{$foo|var_export:true}',
|
||||||
array(
|
var_export(array(9, 8, 7, 6), true), '', $i++),
|
||||||
'{assign var=foo value=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}',
|
array(
|
||||||
'array(\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6,)', '', $i ++,
|
'{assign var=foo value=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}',
|
||||||
), array('{assign foo value=1}{$foo}', '1', '', $i ++), array('{assign foo 1}{$foo}', '1', '', $i ++),
|
var_export(array('a' => 9, 'b' => 8, 'c' => 7, 'd' => 6,), true), '', $i++,),
|
||||||
// new format
|
array('{assign foo value=1}{$foo}', '1', '', $i++),
|
||||||
array('{$foo=1}{$foo}', '1', '', $i ++), array('{$foo =2}{$foo}', '2', '', $i ++),
|
array('{assign foo 1}{$foo}', '1', '', $i++),
|
||||||
array('{$foo=bar}{$foo}', 'bar', '', $i ++), array('{$foo=1+2}{$foo}', '3', '', $i ++),
|
// new format
|
||||||
array('{$foo = 1+3}{$foo}', '4', '', $i ++), array('{$foo = 1 + 4}{$foo}', '5', '', $i ++),
|
array('{$foo=1}{$foo}', '1', '', $i++),
|
||||||
array('{$foo=strlen(\'bar\')}{$foo}', '3', '', $i ++), array('{$foo=\'bar\'|strlen}{$foo}', '3', '', $i ++),
|
array('{$foo =2}{$foo}', '2', '', $i++),
|
||||||
array('{$foo[\'a\'][4]=1}{$foo[\'a\'][4]}', '1', '', $i ++),
|
array('{$foo=bar}{$foo}', 'bar', '', $i++),
|
||||||
array('{$foo=[9,8,7,6]}{$foo|var_export:true}', 'array(0=>9,1=>8,2=>7,3=>6,)', '', $i ++), array(
|
array('{$foo=1+2}{$foo}', '3', '', $i++),
|
||||||
'{$foo=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}',
|
array('{$foo = 1+3}{$foo}', '4', '', $i++),
|
||||||
'array(\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6,)', '', $i ++,
|
array('{$foo = 1 + 4}{$foo}', '5', '', $i++),
|
||||||
),
|
array('{$foo=strlen(\'bar\')}{$foo}', '3', '', $i++),
|
||||||
|
array('{$foo=\'bar\'|strlen}{$foo}', '3', '', $i++),
|
||||||
|
array('{$foo[\'a\'][4]=1}{$foo[\'a\'][4]}', '1', '', $i++),
|
||||||
|
array('{$foo=[9,8,7,6]}{$foo|var_export:true}', var_export(array(9, 8, 7, 6), true), '', $i++),
|
||||||
|
array(
|
||||||
|
'{$foo=[\'a\'=>9,\'b\'=>8,\'c\'=>7,\'d\'=>6]}{$foo|var_export:true}',
|
||||||
|
var_export(array('a' => 9, 'b' => 8, 'c' => 7, 'd' => 6,), true), '', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Assign spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testAssignSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testAssignSpacingNocache($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('1');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar',true);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testAssignSpacingNocache2($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('1');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo',true);
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array("A{assign var=buh value=\$foo}B{\$buh}", "ABbar", 'Text1', $i++),
|
||||||
|
array("A\n{assign var=buh value=\$foo}\nB{\$buh}", "A\nBbar", 'Newline1', $i++),
|
||||||
|
array("E{assign var=buh value=\$foo}\nF{\$buh}", "EFbar", 'Newline2', $i++),
|
||||||
|
array("G\n{assign var=buh value=\$foo}H{\$buh}", "G\nHbar", 'Newline3', $i++),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
tests/UnitTests/TemplateSource/TagTests/Assign/cache/dummy.txt
vendored
Normal file
1
tests/UnitTests/TemplateSource/TagTests/Assign/cache/dummy.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -252,6 +252,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->registerDefaultPluginHandler('my_block_plugin_handler');
|
$this->smarty->registerDefaultPluginHandler('my_block_plugin_handler');
|
||||||
$this->assertEquals('defaultblock hello world', $this->smarty->fetch('default2.tpl'));
|
$this->assertEquals('defaultblock hello world', $this->smarty->fetch('default2.tpl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test tag stack
|
* test tag stack
|
||||||
*
|
*
|
||||||
@@ -262,7 +263,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
|
|||||||
public function testBlockPluginTagStack()
|
public function testBlockPluginTagStack()
|
||||||
{
|
{
|
||||||
$this->assertEquals('noop-teststack', $this->smarty->fetch('tag_stack.tpl'));
|
$this->assertEquals('noop-teststack', $this->smarty->fetch('tag_stack.tpl'));
|
||||||
$this->assertEmpty($this->smarty->_cache['_tag_stack']);
|
$this->assertEmpty($this->smarty->_cache[ '_tag_stack' ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,8 +274,16 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
|
|||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function testCache($isCached, $caching, $cachable, $testNumber, $compileTestNumber, $renderTestNumber,
|
public function testCache($isCached,
|
||||||
$resultNumber, $nocache, $compileid, $testName)
|
$caching,
|
||||||
|
$cachable,
|
||||||
|
$testNumber,
|
||||||
|
$compileTestNumber,
|
||||||
|
$renderTestNumber,
|
||||||
|
$resultNumber,
|
||||||
|
$nocache,
|
||||||
|
$compileid,
|
||||||
|
$testName)
|
||||||
{
|
{
|
||||||
$this->smarty->registerFilter('pre', array($this, 'prefilterTest'));
|
$this->smarty->registerFilter('pre', array($this, 'prefilterTest'));
|
||||||
$this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable);
|
$this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable);
|
||||||
@@ -288,7 +297,8 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()');
|
$this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()');
|
||||||
}
|
}
|
||||||
$result = $this->smarty->fetch($tpl);
|
$result = $this->smarty->fetch($tpl);
|
||||||
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
|
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}",
|
||||||
|
$result,
|
||||||
$testName . ' - fetch() failure test number');
|
$testName . ' - fetch() failure test number');
|
||||||
$this->assertContains("block test{$resultNumber}", $result, $testName . ' - fetch() failure result');
|
$this->assertContains("block test{$resultNumber}", $result, $testName . ' - fetch() failure result');
|
||||||
}
|
}
|
||||||
@@ -308,8 +318,152 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
|
|||||||
array(true, true, true, 11, 10, 10, 11, true, 3, 'not cachable isCached'),
|
array(true, true, true, 11, 10, 10, 11, true, 3, 'not cachable isCached'),
|
||||||
array(true, true, true, 12, 10, 10, 12, true, 3, 'not cachable isCached'),);
|
array(true, true, true, 12, 10, 10, 12, true, 3, 'not cachable isCached'),);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "testSpacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{noop}\nB{/noop}C", "ABC", 'Newline1', $i++),
|
||||||
|
array("A{noop}\nB\n{/noop}C", "AB\nC", 'Newline2', $i++),
|
||||||
|
array("A{noop}\nB{/noop}\nC", "ABC", 'Newline3', $i++),
|
||||||
|
array("A\n{noop}\nB\n{/noop}\nC", "A\nB\nC", 'Newline4', $i++),
|
||||||
|
array("A{noop}\n{\$foo}{/noop}C", "AbarC", 'Var1', $i++),
|
||||||
|
array("A{noop}\n{\$foo}\n{/noop}C", "Abar\nC", 'Var2', $i++),
|
||||||
|
array("A{noop}\n{\$foo}{/noop}\nC", "AbarC", 'Var3', $i++),
|
||||||
|
array("A\n{noop}\n{\$foo}\n{/noop}\nC", "A\nbar\nC", 'Var4', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestDefaultSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacingDefault($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "testSpacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->registerDefaultPluginHandler('my_block_plugin_handler');
|
||||||
|
$this->smarty->compile_id='default';
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestDefaultSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{scriptblock}\nB{/scriptblock}C", "Ascriptblock BC", 'Newline1', $i++),
|
||||||
|
array("A{scriptblock}\nB\n{/scriptblock}C", "Ascriptblock B\nC", 'Newline2', $i++),
|
||||||
|
array("A{scriptblock}\nB{/scriptblock}\nC", "Ascriptblock BC", 'Newline3', $i++),
|
||||||
|
array("A\n{scriptblock}\nB\n{/scriptblock}\nC", "A\nscriptblock B\nC", 'Newline4', $i++),
|
||||||
|
array("A{scriptblock}\n{\$foo}{/scriptblock}C", "Ascriptblock barC", 'Var1', $i++),
|
||||||
|
array("A{scriptblock}\n{\$foo}\n{/scriptblock}C", "Ascriptblock bar\nC", 'Var2', $i++),
|
||||||
|
array("A{scriptblock}\n{\$foo}{/scriptblock}\nC", "Ascriptblock barC", 'Var3', $i++),
|
||||||
|
array("A\n{scriptblock}\n{\$foo}\n{/scriptblock}\nC", "A\nscriptblock bar\nC", 'Var4', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test nocache block spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestNocacheSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testBlockNocache($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Nocache_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setCompileId('nocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('bar', 'bar',true);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testNocache - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test nocache block spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestNocacheSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testBlockNocache2($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Nocache_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('nocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('bar', 'foo',true);
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testNocache2 - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestNocacheSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{testparameter value=\$bar}\n{\$foo}{/testparameter}C", "AbarC", 'Var1', $i++),
|
||||||
|
array("A{testparameter value=\$bar}\n{\$foo}\n{/testparameter}C", "Abar\nC", 'Var2', $i++),
|
||||||
|
array("A{testparameter value=\$bar}\n{\$foo}{/testparameter}\nC", "AbarC", 'Var3', $i++),
|
||||||
|
array("A\n{testparameter value=\$bar}\n{\$foo}\n{/testparameter}\nC", "A\nbar\nC", 'Var4', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
function myblockplugintest($params, $content, &$smarty_tpl, &$repeat)
|
function myblockplugintest($params, $content, &$smarty_tpl, &$repeat)
|
||||||
{
|
{
|
||||||
if (!$repeat) {
|
if (!$repeat) {
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin for testing block plugins
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PHPunitPlugin
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty {testparameter}{/testparameter} block plugin
|
||||||
|
*
|
||||||
|
* @param array $params parameter array
|
||||||
|
* @param string $content contents of the block
|
||||||
|
* @param \Smarty_Internal_Template $template template object
|
||||||
|
* @param bool $repeat flag
|
||||||
|
*
|
||||||
|
* @return string content re-formatted
|
||||||
|
*/
|
||||||
|
function smarty_block_testparameter($params, $content, Smarty_Internal_Template $template, &$repeat)
|
||||||
|
{
|
||||||
|
if (isset($content)) {
|
||||||
|
return $content;
|
||||||
|
} else {
|
||||||
|
$template->assign('foo', $params[ 'value' ]);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -1017,4 +1017,186 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->fetch('037_parent.tpl');
|
$this->smarty->fetch('037_parent.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testBlockSpacingNocache($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('VarNocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar',true);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testVarNocache - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testBlockSpacingNocache2($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('VarNocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo',true);
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testVarNocache1 - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{block name='a'}{\$foo}{/block}C", "AbarC", 'Var0', $i++),
|
||||||
|
array("A{block name='a'}\n{\$foo}{/block}C", "A\nbarC", 'Var1', $i++),
|
||||||
|
array("A{block name='a'}\n{\$foo}\n{/block}C", "A\nbar\nC", 'Var2', $i++),
|
||||||
|
array("A{block name='a'}\n{\$foo}{/block}\nC", "A\nbar\nC", 'Var3', $i++),
|
||||||
|
array("A\n{block name='a'}\n{\$foo}\n{/block}\nC", "A\n\nbar\n\nC", 'Var4', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestChildSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testChildSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_Parent{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$child = "{extends file='$file'}\n";
|
||||||
|
$child .= preg_replace(array('/A/','/C/','/[$]foo/','/\s*[{][$]smarty[.]block[.]child[}]\s*/'),array('G','H','$bar','{$bar}'),$code);
|
||||||
|
$file = "Spacing_Child{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $child);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo');
|
||||||
|
$this->smarty->assign('bar', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testChildSpacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestChildSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{block name='a'}{\$foo}{/block}C", "AbarC", 'Var0', $i++),
|
||||||
|
array("A{block name='a'}\n{\$foo}{/block}C", "A\nbarC", 'Var1', $i++),
|
||||||
|
array("A{block name='a'}\n{\$foo}\n{/block}C", "A\nbar\nC", 'Var2', $i++),
|
||||||
|
array("A{block name='a'}\n{\$foo}{/block}\nC", "A\nbar\nC", 'Var3', $i++),
|
||||||
|
array("A\n{block name='a'}\n{\$foo}\n{/block}\nC", "A\n\nbar\n\nC", 'Var4', $i++),
|
||||||
|
array("A{block name='a'}{\$smarty.block.child}{/block}C", "AbarC", 'BlockChild0', $i++),
|
||||||
|
array("A{block name='a'}\n{\$smarty.block.child}{/block}C", "A\nbarC", 'BlockChild1', $i++),
|
||||||
|
array("A{block name='a'}\n{\$smarty.block.child}\n{/block}C", "A\nbar\nC", 'BlockChild2', $i++),
|
||||||
|
array("A{block name='a'}\n{\$smarty.block.child}{/block}\nC", "A\nbar\nC", 'BlockChild3', $i++),
|
||||||
|
array("A\n{block name='a'}\n{\$smarty.block.child}\n{/block}\nC", "A\n\nbar\n\nC", 'BlockChild4', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Block nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestBlockNocache
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testBlockNocacheSpacing($code, $result, $name, $testNumber)
|
||||||
|
{
|
||||||
|
$file = "blockNocache_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setCompileId('BlockNocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"blockNocache - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Block nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestBlockNocache
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testBlockNocacheSpacing2($code, $result, $name, $testNumber)
|
||||||
|
{
|
||||||
|
$file = "blockNocache_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('BlockNocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo');
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"blockNocache - {$file}");
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Data provider für TestBlockNocache
|
||||||
|
*/
|
||||||
|
public function dataTestBlockNocache()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{nocache}{block name='a'}{\$foo}{/block}{/nocache}C", "AbarC", 'Var0', $i++),
|
||||||
|
array("A{nocache}{block name='a'}\n{\$foo}{/block}{/nocache}C", "A\nbarC", 'Var1', $i++),
|
||||||
|
array("A{nocache}{block name='a'}\n{\$foo}\n{/block}{/nocache}C", "A\nbar\nC", 'Var2', $i++),
|
||||||
|
array("A{nocache}{block name='a'}\n{\$foo}{/block}\n{/nocache}C", "A\nbar\nC", 'Var3', $i++),
|
||||||
|
array("A{nocache}\n{block name='a'}\n{\$foo}\n{/block}\n{/nocache}C", "A\n\nbar\n\nC", 'Var4', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -39,7 +39,7 @@ class CompileCaptureTest extends PHPUnit_Smarty
|
|||||||
$file = "testCapture{$testNumber}.tpl";
|
$file = "testCapture{$testNumber}.tpl";
|
||||||
$this->makeTemplateFile($file, $code);
|
$this->makeTemplateFile($file, $code);
|
||||||
$this->smarty->assignGlobal('file', $file);
|
$this->smarty->assignGlobal('file', $file);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "testCapture - {$code} - {$testName}");
|
$this->assertEquals($result, $this->smarty->fetch($file), "testCapture - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -103,4 +103,47 @@ class CompileCaptureTest extends PHPUnit_Smarty
|
|||||||
$this->assertContains('lowercase', $result);
|
$this->assertContains('lowercase', $result);
|
||||||
$this->assertContains('uppercase', $result);
|
$this->assertContains('uppercase', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"Spacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{capture}B{/capture}C{\$smarty.capture.default}", "ACB", 'Newline1', $i++),
|
||||||
|
array("A{capture}\nB{/capture}C{\$smarty.capture.default}", "ACB", 'Newline2', $i++),
|
||||||
|
array("A{capture}B\n{/capture}C{\$smarty.capture.default}", "ACB\n", 'Newline3', $i++),
|
||||||
|
array("A\n{capture}\nB\n{/capture}C{\$smarty.capture.default}", "A\nCB\n", 'Newline4', $i++),
|
||||||
|
array("{capture}B{/capture}A{\$smarty.capture.default}C", "ABC", 'Newline5', $i++),
|
||||||
|
array("{capture}B{/capture}A\n{\$smarty.capture.default}C", "A\nBC", 'Newline6', $i++),
|
||||||
|
array("{capture}B{/capture}A{\$smarty.capture.default}\nC", "AB\nC", 'Newline7', $i++),
|
||||||
|
array("{capture}B{/capture}A\n{\$smarty.capture.default}\nC", "A\nB\nC", 'Newline8', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -30,13 +30,13 @@ class CompileDelimiterTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testLeftDelimiter()
|
public function testLeftDelimiter()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:x{ldelim}x');
|
$tpl = $this->smarty->createTemplate('string:x{ldelim}x');
|
||||||
$this->assertEquals('x{x', $this->smarty->fetch($tpl));
|
$this->assertEquals('x{x', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRightDelimiter()
|
public function testRightDelimiter()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:x{rdelim}x');
|
$tpl = $this->smarty->createTemplate('string:x{rdelim}x');
|
||||||
$this->assertEquals('x}x', $this->smarty->fetch($tpl));
|
$this->assertEquals('x}x', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,19 +30,19 @@ class CompileEvalTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testEval1()
|
public function testEval1()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:{eval var='hello world'}");
|
$tpl = $this->smarty->createTemplate("string:{eval var='hello world'}");
|
||||||
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEval2()
|
public function testEval2()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:{eval var='hello world' assign=foo}{\$foo}");
|
$tpl = $this->smarty->createTemplate("string:{eval var='hello world' assign=foo}{\$foo}");
|
||||||
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEval3()
|
public function testEval3()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:{eval var='hello world' assign=foo}");
|
$tpl = $this->smarty->createTemplate("string:{eval var='hello world' assign=foo}");
|
||||||
$this->assertEquals("", $this->smarty->fetch($tpl));
|
$this->assertEquals("", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,91 +27,54 @@ class CompileForTest extends PHPUnit_Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test {for $x=0;$x<10;$x++} tag
|
* Test For
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestFor
|
||||||
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
public function testFor1()
|
public function testFor($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0;$x<10;$x++}{$x}{/for}');
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
$this->assertEquals("0123456789", $this->smarty->fetch($tpl));
|
$file = "For_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFor2()
|
/*
|
||||||
|
* Data provider für testFor
|
||||||
|
*/
|
||||||
|
public function dataTestFor()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0; $x<10; $x++}{$x}{forelse}else{/for}');
|
$i = 1;
|
||||||
$this->assertEquals("0123456789", $this->smarty->fetch($tpl));
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array('{for $x=0;$x<10;$x++}{$x}{/for}', '0123456789', 'T1', $i++),
|
||||||
|
array('{for $x=0; $x<10; $x++}{$x}{forelse}else{/for}', '0123456789', 'T2', $i++),
|
||||||
|
array('{for $x=10;$x<10;$x++}{$x}{forelse}else{/for}', 'else', 'T3', $i++),
|
||||||
|
array('{for $x=9;$x>=0;$x--}{$x}{forelse}else{/for}', '9876543210', 'T4', $i++),
|
||||||
|
array('{for $x=-1;$x>=0;$x--}{$x}{forelse}else{/for}', 'else', 'T5', $i++),
|
||||||
|
array('{for $x=0,$y=10;$x<$y;$x++}{$x}{forelse}else{/for}', '0123456789', 'T6', $i++),
|
||||||
|
array('{for $x=0;$x<10;$x=$x+2}{$x}{/for}', '02468', 'T7', $i++),
|
||||||
|
array('{for $x=0 to 8}{$x}{/for}', '012345678', 'T8', $i++),
|
||||||
|
array('{for $x=0 to 8 step=2}{$x}{/for}', '02468', 'T9', $i++),
|
||||||
|
array('{for $x=0 to 8 step=2}{if $x@first}{$x} {$x@total}{/if}{/for}', '0 5', 'T10', $i++),
|
||||||
|
array('{for $x=0 to 8 step=2}{if $x@last}{$x} {$x@iteration}{/if}{/for}', '8 5', 'T11', $i++),
|
||||||
|
array('{for $x=8 to 0 step=-2}{$x}{/for}', '86420', 'T12', $i++),
|
||||||
|
array('{for $x=8 to 0 step=2}{$x}{forelse}step error{/for}', 'step error', 'T13', $i++),
|
||||||
|
array('{for $x=8 to 0 step -1 max=3}{$x}{/for}', '876', 'T14', $i++),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFor3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=10;$x<10;$x++}{$x}{forelse}else{/for}');
|
|
||||||
$this->assertEquals("else", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=9;$x>=0;$x--}{$x}{forelse}else{/for}');
|
|
||||||
$this->assertEquals("9876543210", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor5()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=-1;$x>=0;$x--}{$x}{forelse}else{/for}');
|
|
||||||
$this->assertEquals("else", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor6()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0,$y=10;$x<$y;$x++}{$x}{forelse}else{/for}');
|
|
||||||
$this->assertEquals("0123456789", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor7()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0;$x<10;$x=$x+2}{$x}{/for}');
|
|
||||||
$this->assertEquals("02468", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor8()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0 to 8}{$x}{/for}');
|
|
||||||
$this->assertEquals("012345678", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor9()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0 to 8 step=2}{$x}{/for}');
|
|
||||||
$this->assertEquals("02468", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor10()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0 to 8 step=2}{if $x@first}{$x} {$x@total}{/if}{/for}');
|
|
||||||
$this->assertEquals("0 5", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor11()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=0 to 8 step=2}{if $x@last}{$x} {$x@iteration}{/if}{/for}');
|
|
||||||
$this->assertEquals("8 5", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor12()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=8 to 0 step=-2}{$x}{/for}');
|
|
||||||
$this->assertEquals("86420", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor13()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=8 to 0 step=2}{$x}{forelse}step error{/for}');
|
|
||||||
$this->assertEquals("step error", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFor14()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{for $x=8 to 0 step -1 max=3}{$x}{/for}');
|
|
||||||
$this->assertEquals("876", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test for and nocache
|
* test for and nocache
|
||||||
@@ -187,4 +150,51 @@ class CompileForTest extends PHPUnit_Smarty
|
|||||||
$this->assertTrue($this->smarty->isCached($tpl));
|
$this->assertTrue($this->smarty->isCached($tpl));
|
||||||
$this->assertEquals("1 2 ", $this->smarty->fetch($tpl));
|
$this->assertEquals("1 2 ", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('buh', 'buh');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"Spacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{for \$bar = 1 to 2}{\$bar}{/for}C", "A12C", 'T1', $i++),
|
||||||
|
array("A{for \$bar = 1 to 2}\n{\$bar}{/for}C", "A12C", 'T2', $i++),
|
||||||
|
array("A{for \$bar = 1 to 2}{\$bar}\n{/for}C", "A1\n2\nC", 'T3', $i++),
|
||||||
|
array("A{for \$bar = 1 to 2}\n{\$bar}\n{/for}C", "A1\n2\nC", 'T4', $i++),
|
||||||
|
array("A\n{for \$bar = 1 to 2}{\$bar}{/for}C", "A\n12C", 'T5', $i++),
|
||||||
|
array("A{for \$bar = 1 to 2}{\$bar}{/for}\nC", "A12C", 'T6', $i++),
|
||||||
|
array("A{for \$bar = 1 to 2}{\$bar}{forelse}D{/for}C", "A12C", 'T7', $i++),
|
||||||
|
array("A{for \$bar = 1 to 2}{\$bar}\n{forelse}D{/for}C", "A1\n2\nC", 'T8', $i++),
|
||||||
|
array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}A{\$buh}B{/for}", "AbuhB", 'T9', $i++),
|
||||||
|
array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}\nA{\$buh}B{/for}", "AbuhB", 'T10', $i++),
|
||||||
|
array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}A{\$buh}\nB{/for}", "Abuh\nB", 'T11', $i++),
|
||||||
|
array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}\nA{\$buh}\nB{/for}", "Abuh\nB", 'T12', $i++),
|
||||||
|
array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}{\$buh}\nB{/for}", "buh\nB", 'T13', $i++),
|
||||||
|
array("{for \$x=-1;\$x>=0;\$x--}{\$x}{forelse}{\$buh}{/for}", "buh", 'T14', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -47,7 +47,7 @@ class CompileForeachTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "testForeach - {$code} - {$testName}");
|
$this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -119,7 +119,7 @@ class CompileForeachTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "testForeach - {$code} - {$testName}");
|
$this->assertEquals($result, $this->smarty->fetch($file), "testForeach - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -297,4 +297,90 @@ class CompileForeachTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals("false",
|
$this->assertEquals("false",
|
||||||
$this->smarty->fetch('037_foreach.tpl'));
|
$this->smarty->fetch('037_foreach.tpl'));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', array(1,2));
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"Spacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{foreach from=\$foo item='bar'}{\$bar}{/foreach}C", "A12C", 'Newline1', $i++),
|
||||||
|
array("A{foreach from=\$foo item='bar'}\n{\$bar}{/foreach}C", "A12C", 'Newline2', $i++),
|
||||||
|
array("A{foreach from=\$foo item='bar'}{\$bar}\n{/foreach}C", "A1\n2\nC", 'Newline3', $i++),
|
||||||
|
array("A{foreach from=\$foo item='bar'}\n{\$bar}\n{/foreach}C", "A1\n2\nC", 'Newline4', $i++),
|
||||||
|
array("A\n{foreach from=\$foo item='bar'}{\$bar}{/foreach}C", "A\n12C", 'Newline5', $i++),
|
||||||
|
array("A{foreach from=\$foo item='bar'}{\$bar}{/foreach}\nC", "A12C", 'Newline6', $i++),
|
||||||
|
array("A{foreach from=\$foo item='bar'}{\$bar}{foreachelse}D{/foreach}C", "A12C", 'Newline7', $i++),
|
||||||
|
array("A{foreach from=\$foo item='bar'}{\$bar}\n{foreachelse}D{/foreach}C", "A1\n2\nC", 'Newline8', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A{\$smarty.foreach.buh.total}C", "12A2C", 'Newline9', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A\n{\$smarty.foreach.buh.total}C", "12A\n2C", 'Newline10', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar' name='buh'}{\$bar}{/foreach}A{\$smarty.foreach.buh.total}\nC", "12A2\nC", 'Newline11', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestElseSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testElseSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_Else_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', array());
|
||||||
|
$this->smarty->assign('buh', 'buh');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"Spacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestElseSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}A{\$buh}B{/foreach}", "AbuhB", 'Newline1', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}\nA{\$buh}B{/foreach}", "AbuhB", 'Newline2', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}A{\$buh}\nB{/foreach}", "Abuh\nB", 'Newline3', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}\nA{\$buh}\nB{/foreach}", "Abuh\nB", 'Newline4', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}{\$buh}\nB{/foreach}", "buh\nB", 'Newline5', $i++),
|
||||||
|
array("{foreach from=\$foo item='bar'}{\$bar}{foreachelse}{\$buh}{/foreach}", "buh", 'Newline6', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -63,7 +63,7 @@ class CompileFunctionPluginTest extends PHPUnit_Smarty
|
|||||||
public function testFunctionPluginRegisteredFunction()
|
public function testFunctionPluginRegisteredFunction()
|
||||||
{
|
{
|
||||||
$this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'plugintest', 'myplugintest');
|
$this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'plugintest', 'myplugintest');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{plugintest foo=bar}', $this->smarty);
|
$tpl = $this->smarty->createTemplate('string:{plugintest foo=bar}', $this->smarty);
|
||||||
$this->assertEquals("plugin test called bar", $this->smarty->fetch($tpl));
|
$this->assertEquals("plugin test called bar", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class CompileFunctionPluginTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testMultiLineTags()
|
public function testMultiLineTags()
|
||||||
{
|
{
|
||||||
$this->assertEquals("10", $this->smarty->fetch("eval:{counter\n\tstart=10}"));
|
$this->assertEquals("10", $this->smarty->fetch("string:{counter\n\tstart=10}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ class CompileIfTest extends PHPUnit_Smarty
|
|||||||
$this->makeTemplateFile($file, $code);
|
$this->makeTemplateFile($file, $code);
|
||||||
$this->smarty->assignGlobal('file', $file);
|
$this->smarty->assignGlobal('file', $file);
|
||||||
$this->smarty->assign('bar', 'buh');
|
$this->smarty->assign('bar', 'buh');
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)),
|
$this->assertEquals($result, $this->smarty->fetch($file),
|
||||||
"testIf - {$code} - {$name}");
|
"testIf - {$code} - {$name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class CompileIfTest extends PHPUnit_Smarty
|
|||||||
array('{if 2<1}yes{else}no{/if}', 'no', '', $i ++),
|
array('{if 2<1}yes{else}no{/if}', 'no', '', $i ++),
|
||||||
array('{if 2<1}yes{elseif 4<5}yes1{else}no{/if}', 'yes1', '', $i ++),
|
array('{if 2<1}yes{elseif 4<5}yes1{else}no{/if}', 'yes1', '', $i ++),
|
||||||
array('{if 2<1}yes{elseif 6<5}yes1{else}no{/if}', 'no', '', $i ++),
|
array('{if 2<1}yes{elseif 6<5}yes1{else}no{/if}', 'no', '', $i ++),
|
||||||
array('{if true}yes{else}no{/if}', 'yes', '', $i ++),
|
array('{if false}false{elseif true}yes{else}no{/if}', 'yes', '', $i ++),
|
||||||
array('{if false}yes{else}no{/if}', 'no', '', $i ++),
|
array('{if false}yes{else}no{/if}', 'no', '', $i ++),
|
||||||
array('{if !(1<2)}yes{else}no{/if}', 'no', '', $i ++),
|
array('{if !(1<2)}yes{else}no{/if}', 'no', '', $i ++),
|
||||||
array('{if not (true)}yes{else}no{/if}', 'no', '', $i ++),
|
array('{if not (true)}yes{else}no{/if}', 'no', '', $i ++),
|
||||||
@@ -73,10 +73,11 @@ class CompileIfTest extends PHPUnit_Smarty
|
|||||||
array('{$foo=true}{if $foo!==true}yes{else}no{/if}', 'no', '', $i ++),
|
array('{$foo=true}{if $foo!==true}yes{else}no{/if}', 'no', '', $i ++),
|
||||||
array('{if 1 > 0}yes{else}no{/if}', 'yes', '', $i ++),
|
array('{if 1 > 0}yes{else}no{/if}', 'yes', '', $i ++),
|
||||||
array('{if $x=1}yes{else}no{/if}{$x}', 'yes1', '', $i ++),
|
array('{if $x=1}yes{else}no{/if}{$x}', 'yes1', '', $i ++),
|
||||||
array('{$x=0}{if $x++}yes{else}no{/if} {$x}', 'no1', '', $i ++),
|
array('{$x=0}{if $x++}yes{else}no{/if} {$x}', 'no 1', '', $i ++),
|
||||||
array('{$x=[1,2]}{if $x[] = 7}{$x|var_export:true}{else}no{/if}', 'array(0=>1,1=>2,2=>7,)', '',
|
array('{$x=[1,2]}{if $x[] = 7}{$x|var_export:true}{else}no{/if}', var_export(array(0=>1,1=>2,2=>7,),true), '',
|
||||||
$i ++), array('{$x=[1,2]}{if $x[][\'a\'] = 7}{$x|var_export:true}{else}no{/if}',
|
$i ++),
|
||||||
'array(0=>1,1=>2,2=>array(\'a\'=>7,),)', '', $i ++),
|
array('{$x=[1,2]}{if $x[][\'a\'] = 7}{$x|var_export:true}{else}no{/if}',
|
||||||
|
var_export(array(0=>1,1=>2,2=>array('a'=>7,),),true), '', $i ++),
|
||||||
array('{$foo=\'foo\'}{$bar=\'bar\'}{if $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}',
|
array('{$foo=\'foo\'}{$bar=\'bar\'}{if $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}',
|
||||||
'yes-new_foo', '', $i ++),
|
'yes-new_foo', '', $i ++),
|
||||||
array('{$foo=\'foo\'}{$bar=\'bar\'}{if false}false{elseif $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}',
|
array('{$foo=\'foo\'}{$bar=\'bar\'}{if false}false{elseif $bar = "new_{$foo|default:\'\'}"}yes-{else}no{/if}{$bar}',
|
||||||
@@ -106,9 +107,43 @@ class CompileIfTest extends PHPUnit_Smarty
|
|||||||
array('{$foo=3}{$bar=3}{if 3+$bar is not odd by $foo}yes{else}no{/if}', 'yes', 'ExprIsNotOddByVar', $i ++),
|
array('{$foo=3}{$bar=3}{if 3+$bar is not odd by $foo}yes{else}no{/if}', 'yes', 'ExprIsNotOddByVar', $i ++),
|
||||||
array('{$foo=2}{$bar=6}{if (3+$bar) is not odd by ($foo+1)}yes{else}no{/if}', 'no', 'ExprIsNotOddByExpr', $i ++),
|
array('{$foo=2}{$bar=6}{if (3+$bar) is not odd by ($foo+1)}yes{else}no{/if}', 'no', 'ExprIsNotOddByExpr', $i ++),
|
||||||
array('{if strlen("hello world") === 11}yes{else}no{/if}', 'yes', 'FuncCmp', $i ++),
|
array('{if strlen("hello world") === 11}yes{else}no{/if}', 'yes', 'FuncCmp', $i ++),
|
||||||
|
array('{if 0>1}yes{else}no{/if}', 'no', 'GT2', $i ++),
|
||||||
|
array('{if 1 GT 0}yes{else}no{/if}', 'yes', 'GT3', $i ++),
|
||||||
|
array('{if 0 gt 1}yes{else}no{/if}', 'no', 'GT4', $i ++),
|
||||||
|
array('{if 1 >= 0}yes{else}no{/if}', 'yes', 'GE1', $i ++),
|
||||||
|
array('{if 1>=1}yes{else}no{/if}', 'yes', 'GE2', $i ++),
|
||||||
|
array('{if 1 GE 1}yes{else}no{/if}', 'yes', 'GE3', $i ++),
|
||||||
|
array('{if 0 ge 1}yes{else}no{/if}', 'no', 'GE4', $i ++),
|
||||||
|
array('{if 0 < 0}yes{else}no{/if}', 'no', 'LT1', $i ++),
|
||||||
|
array('{if 0<1}yes{else}no{/if}', 'yes', 'LT2', $i ++),
|
||||||
|
array('{if 0 <= 0}yes{else}no{/if}', 'yes', 'LE1', $i ++),
|
||||||
|
array('{if 0<=1}yes{else}no{/if}', 'yes', 'LE2', $i ++),
|
||||||
|
array('{if 1 LE 0}yes{else}no{/if}', 'no', 'LE3', $i ++),
|
||||||
|
array('{if 0 le 1}yes{else}no{/if}', 'yes', 'LE4', $i ++),
|
||||||
|
array('{if 1 != 1}yes{else}no{/if}', 'no', 'NE1', $i ++),
|
||||||
|
array('{if 1!=2}yes{else}no{/if}', 'yes', 'NE2', $i ++),
|
||||||
|
array('{if 1 NE 1}yes{else}no{/if}', 'no', 'NE3', $i ++),
|
||||||
|
array('{if 1 ne 2}yes{else}no{/if}', 'yes', 'NE4', $i ++),
|
||||||
|
array('{if 1 === "1"}yes{else}no{/if}', 'no', 'Ident1', $i ++),
|
||||||
|
array('{if "1" === "1"}yes{else}no{/if}', 'yes', 'Ident2', $i ++),
|
||||||
|
array('{if 1 > 0 && 5 < 6}yes{else}no{/if}', 'yes', 'And1', $i ++),
|
||||||
|
array('{if 1 > 0&&5 < 6}yes{else}no{/if}', 'yes', 'And2', $i ++),
|
||||||
|
array('{if 1 > 0 AND 5 > 6}yes{else}no{/if}', 'no', 'And3', $i ++),
|
||||||
|
array('{if (1 > 0) and (5 < 6)}yes{else}no{/if}', 'yes', 'And4', $i ++),
|
||||||
|
array('{if 1 > 0 || 7 < 6}yes{else}no{/if}', 'yes', 'Or1', $i ++),
|
||||||
|
array('{if 1 > 0||5 < 6}yes{else}no{/if}', 'yes', 'Or2', $i ++),
|
||||||
|
array('{if 1 > 0 OR 5 > 6}yes{else}no{/if}', 'yes', 'Or3', $i ++),
|
||||||
|
array('{if (0 > 0) or (9 < 6)}yes{else}no{/if}', 'no', 'Or4', $i ++),
|
||||||
|
array('{if ((7>8)||(1 > 0)) and (5 < 6)}yes{else}no{/if}', 'yes', 'AndOr1', $i ++),
|
||||||
|
array('{if {counter start=1} == 1}yes{else}no{/if}', 'yes', 'Tag1', $i ++),
|
||||||
|
array('{if false}false{elseif {counter start=1} == 1}yes{else}no{/if}', 'yes', 'Tag2', $i ++),
|
||||||
|
array('{if {counter start=1} == 0}false{elseif {counter} == 2}yes{else}no{/if}', 'yes', 'Tag3', $i ++),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if nocache tags
|
* Test if nocache tags
|
||||||
*
|
*
|
||||||
@@ -128,7 +163,7 @@ class CompileIfTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('file', $file, true);
|
$this->smarty->assign('file', $file, true);
|
||||||
$this->smarty->assign($var, $value, true);
|
$this->smarty->assign($var, $value, true);
|
||||||
$this->smarty->assign($var . '2', $value);
|
$this->smarty->assign($var . '2', $value);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('run_code_caching.tpl')),
|
$this->assertEquals($result, $this->strip($this->smarty->fetch('run_code_caching.tpl')),
|
||||||
"testIfNocahe - {$code} - {$testName}");
|
"testIfNocahe - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,184 +201,60 @@ class CompileIfTest extends PHPUnit_Smarty
|
|||||||
array('bar', 0, false, 'yes3', '', $i ++, 'testIfNoCache_Var4.tpl'),);
|
array('bar', 0, false, 'yes3', '', $i ++, 'testIfNoCache_Var4.tpl'),);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIfGT2()
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0>1}yes{else}no{/if}');
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('bar', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIfGT3()
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 GT 0}yes{else}no{/if}');
|
$i = 1;
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
/*
|
||||||
}
|
* Code
|
||||||
|
* result
|
||||||
public function testIfGT4()
|
* test name
|
||||||
{
|
* test number
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 gt 1}yes{else}no{/if}');
|
*/
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
return array(array("A{if false}false{elseif true}{\$bar}{/if}C", "AbarC", 'T1', $i++),
|
||||||
}
|
array("A{if false}false{elseif true}\n{\$bar}{/if}C", "AbarC", 'T2', $i++),
|
||||||
|
array("A{if false}false{elseif true}{\$bar}\n{/if}C", "Abar\nC", 'T3', $i++),
|
||||||
public function testIfGE1()
|
array("A{if false}false{elseif true}\n{\$bar}\n{/if}C", "Abar\nC", 'T4', $i++),
|
||||||
{
|
array("A\n{if false}false{elseif true}{\$bar}{/if}C", "A\nbarC", 'T5', $i++),
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 >= 0}yes{else}no{/if}');
|
array("A{if false}false{elseif true}{\$bar}{/if}\nC", "AbarC", 'T6', $i++),
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
array("A{if false}false{elseif true}{\$bar}{else}D{/if}C", "AbarC", 'T7', $i++),
|
||||||
}
|
array("A{if false}false{elseif true}{\$bar}\n{else}D{/if}C", "Abar\nC", 'T8', $i++),
|
||||||
|
array("{if false}false{else}A{\$bar}B{/if}", "AbarB", 'T9', $i++),
|
||||||
public function testIfGE2()
|
array("{if false}false{else}\nA{\$bar}B{/if}", "AbarB", 'T10', $i++),
|
||||||
{
|
array("{if false}false{else}A{\$bar}\nB{/if}", "Abar\nB", 'T11', $i++),
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1>=1}yes{else}no{/if}');
|
array("{if false}false{else}\nA{\$bar}\nB{/if}", "Abar\nB", 'T12', $i++),
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
array("{if false}false{else}{\$bar}\nB{/if}", "bar\nB", 'T13', $i++),
|
||||||
}
|
array("{if false}false{else}{\$bar}{/if}", "bar", 'T14', $i++),
|
||||||
|
array("A{if false}false{elseif true}{\$bar}{/if}C", "AbarC", 'T15', $i++),
|
||||||
public function testIfGE3()
|
array("A{if false}false{elseif true}\n{\$bar}{/if}C", "AbarC", 'T16', $i++),
|
||||||
{
|
array("A{if false}false{elseif true}{\$bar}\n{/if}C", "Abar\nC", 'T17', $i++),
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 GE 1}yes{else}no{/if}');
|
array("A{if false}false{elseif true}\n{\$bar}\n{/if}C", "Abar\nC", 'T18', $i++),
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
array("A\n{if false}false{elseif true}{\$bar}{/if}C", "A\nbarC", 'T19', $i++),
|
||||||
}
|
array("A{if false}false{elseif true}{\$bar}{/if}\nC", "AbarC", 'T20', $i++),
|
||||||
|
array("A{if false}false{elseif true}{\$bar}{else}D{/if}C", "AbarC", 'T21', $i++),
|
||||||
public function testIfGE4()
|
array("A{if false}false{elseif true}{\$bar}\n{else}D{/if}C", "Abar\nC", 'T22', $i++),
|
||||||
{
|
);
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 ge 1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLT1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 < 0}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLT2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0<1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLT3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 LT 1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLT4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 lt 1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLE1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 <= 0}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLE2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0<=1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLE3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 LE 0}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfLE4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 0 le 1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfNE1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 != 1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfNE2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1!=2}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfNE3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 NE 1}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfNE4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 ne 2}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfIdent1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 === "1"}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfIdent2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if "1" === "1"}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfAnd1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 > 0 && 5 < 6}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfAnd2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 > 0&&5 < 6}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfAnd3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 > 0 AND 5 > 6}}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfAnd4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if (1 > 0) and (5 < 6)}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfOr1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 > 0 || 7 < 6}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfOr2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 > 0||5 < 6}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfOr3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if 1 > 0 OR 5 > 6}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfOr4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if (0 > 0) or (9 < 6)}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("no", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIfAndOR4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{if ((7>8)||(1 > 0)) and (5 < 6)}yes{else}no{/if}');
|
|
||||||
$this->assertEquals("yes", $this->smarty->fetch($tpl));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -98,7 +98,7 @@ class CompileIncludeTest extends PHPUnit_Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test standard output nocache var
|
* test standard output var
|
||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
@@ -241,4 +241,87 @@ class CompileIncludeTest extends PHPUnit_Smarty
|
|||||||
array('merged'),
|
array('merged'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Test Include spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testIncludeSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->addTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testIncludeSpacingNocache($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('1');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->addTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar',true);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testIncludeSpacingNocache2($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('1');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->addTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo',true);
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testSpacing - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array('A{include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text1', $i++),
|
||||||
|
array('A {include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text2', $i++),
|
||||||
|
array('A{include file=\'include_spacing2.tpl\'}B', 'A barB', '2_Text3', $i++),
|
||||||
|
array("A{include file='include_spacing2.tpl'}\nB", "A barB", '2_Newline1', $i++),
|
||||||
|
array("A\n{include file='include_spacing2.tpl'}\nB", "A\n barB", '2_Newline2', $i++),
|
||||||
|
array("A{include file='include_spacing2.tpl'}B\nC", "A barB\nC", '2_Newline3', $i++),
|
||||||
|
array('A{include file=\'include_spacing3.tpl\'}B', "AbarB", '3_Text1', $i++),
|
||||||
|
array('A {include file=\'include_spacing3.tpl\'}B', "A barB", '3_Text2', $i++),
|
||||||
|
array('A{include file=\'include_spacing3.tpl\'}B', "AbarB", '3_Text3', $i++),
|
||||||
|
array("A{include file='include_spacing3.tpl'}\nB", "AbarB", '3_Newline1', $i++),
|
||||||
|
array("A\n{include file='include_spacing3.tpl'}\nB", "A\nbarB", '3_Newline2', $i++),
|
||||||
|
array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
bar
|
@@ -0,0 +1 @@
|
|||||||
|
{$foo}
|
@@ -0,0 +1 @@
|
|||||||
|
{$foo}
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -57,7 +57,7 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
|
|||||||
public function testIncludePhpVariableFileName()
|
public function testIncludePhpVariableFileName()
|
||||||
{
|
{
|
||||||
$this->smartyBC->disableSecurity();
|
$this->smartyBC->disableSecurity();
|
||||||
$tpl = $this->smartyBC->createTemplate('eval:start {include_php file=$filename once=false} end');
|
$tpl = $this->smartyBC->createTemplate('string:start {include_php file=$filename once=false} end');
|
||||||
$tpl->assign('filename', 'scripts/test_include_php.php');
|
$tpl->assign('filename', 'scripts/test_include_php.php');
|
||||||
$result = $this->smartyBC->fetch($tpl);
|
$result = $this->smartyBC->fetch($tpl);
|
||||||
$this->assertContains("test include php", $result);
|
$this->assertContains("test include php", $result);
|
||||||
@@ -66,7 +66,7 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
|
|||||||
public function testIncludePhpVariableFileNameShortag()
|
public function testIncludePhpVariableFileNameShortag()
|
||||||
{
|
{
|
||||||
$this->smartyBC->disableSecurity();
|
$this->smartyBC->disableSecurity();
|
||||||
$tpl = $this->smartyBC->createTemplate('eval:start {include_php $filename once=false} end');
|
$tpl = $this->smartyBC->createTemplate('string:start {include_php $filename once=false} end');
|
||||||
$tpl->assign('filename', 'scripts/test_include_php.php');
|
$tpl->assign('filename', 'scripts/test_include_php.php');
|
||||||
$result = $this->smartyBC->fetch($tpl);
|
$result = $this->smartyBC->fetch($tpl);
|
||||||
$this->assertContains("test include php", $result);
|
$this->assertContains("test include php", $result);
|
||||||
|
@@ -28,26 +28,47 @@ class CompileInsertTest extends PHPUnit_Smarty
|
|||||||
$this->cleanDirs();
|
$this->cleanDirs();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* test inserted function
|
* Test For
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestInsert
|
||||||
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
public function testInsertFunctionSingle()
|
public function testInsert($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:start {insert name='test' foo='bar'} end");
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
$this->assertEquals("start insert function parameter value bar end", $this->smarty->fetch($tpl));
|
$file = "Insert_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->assign('variable', 'test');
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInsertFunctionDouble()
|
/*
|
||||||
|
* Data provider für testInsert
|
||||||
|
*/
|
||||||
|
public function dataTestInsert()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:start {insert name=\"test\" foo='bar'} end");
|
$i = 1;
|
||||||
$this->assertEquals("start insert function parameter value bar end", $this->smarty->fetch($tpl));
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array('start {insert name=\'test\' foo=\'bar\'} end', 'start insert function parameter value bar end', 'T1', $i++),
|
||||||
|
array('start {insert name="test" foo=\'bar\'} end', 'start insert function parameter value bar end', 'T2', $i++),
|
||||||
|
array('start {insert name=$variable foo=\'bar\'} end', 'start insert function parameter value bar end', 'T3', $i++),
|
||||||
|
array("start {insert name='test' foo='bar' assign=blar} end {\$blar}", 'start end insert function parameter value bar', 'T4', $i++),
|
||||||
|
array("start {insert name='test' foo='bar' assign=blar} end", 'start end', 'T5', $i++),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInsertFunctionVariableName()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:start {insert name=\$variable foo='bar'} end");
|
|
||||||
$tpl->assign('variable', 'test');
|
|
||||||
$this->assertEquals("start insert function parameter value bar end", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test insert plugin
|
* test insert plugin
|
||||||
@@ -132,13 +153,11 @@ class CompileInsertTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
global $insertglobal;
|
global $insertglobal;
|
||||||
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
|
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
|
||||||
if (true) { //disabled
|
|
||||||
$insertglobal = 'changed global 4';
|
$insertglobal = 'changed global 4';
|
||||||
$this->smarty->caching = 1;
|
$this->smarty->caching = 1;
|
||||||
$this->smarty->assign('foo', 'buh', true);
|
$this->smarty->assign('foo', 'buh', true);
|
||||||
$this->assertTrue($this->smarty->isCached('insertplugintest.tpl'));
|
$this->assertTrue($this->smarty->isCached('insertplugintest.tpl'));
|
||||||
$this->assertEquals('param foo buh globalvar changed global 4', $this->smarty->fetch('insertplugintest.tpl'));
|
$this->assertEquals('param foo buh globalvar changed global 4', $this->smarty->fetch('insertplugintest.tpl'));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* test insert plugin caching 2
|
* test insert plugin caching 2
|
||||||
@@ -170,35 +189,6 @@ class CompileInsertTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals('param foo bar globalvar global 2', $this->smarty->fetch($tpl));
|
$this->assertEquals('param foo bar globalvar global 2', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* test inserted function with assign
|
|
||||||
*/
|
|
||||||
public function testInsertFunctionAssign()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:start {insert name='test' foo='bar' assign=blar} end {\$blar}");
|
|
||||||
$this->assertEquals("start end insert function parameter value bar", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test insertfunction with assign no output
|
|
||||||
*/
|
|
||||||
public function testInsertFunctionAssignNoOutput()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:start {insert name='test' foo='bar' assign=blar} end");
|
|
||||||
$this->assertEquals("start end", $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test insert plugin with assign
|
|
||||||
*/
|
|
||||||
public function testInsertPluginAssign()
|
|
||||||
{
|
|
||||||
global $insertglobal;
|
|
||||||
$insertglobal = 'global';
|
|
||||||
$tpl = $this->smarty->createTemplate("eval:start {insert name='insertplugintest' foo='bar' assign=blar} end {\$blar}");
|
|
||||||
$tpl->assign('foo', 'bar');
|
|
||||||
$this->assertEquals('start end param foo bar globalvar global', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test inserted function none existing function
|
* test inserted function none existing function
|
||||||
@@ -238,7 +228,7 @@ class CompileInsertTest extends PHPUnit_Smarty
|
|||||||
/**
|
/**
|
||||||
* test function
|
* test function
|
||||||
*/
|
*/
|
||||||
function insert_test($params)
|
function insert_test($params, $template)
|
||||||
{
|
{
|
||||||
return "insert function parameter value $params[foo]";
|
return "insert function parameter value $params[foo]";
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -30,7 +30,7 @@ class LiteralTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testLiteralTag()
|
public function testLiteralTag()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval:{literal} {\$foo} {/literal}");
|
$tpl = $this->smarty->createTemplate("string:{literal} {\$foo} {/literal}");
|
||||||
$this->assertEquals(' {$foo} ', $this->smarty->fetch($tpl));
|
$this->assertEquals(' {$foo} ', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ class LiteralTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testAutoLiteralSpace()
|
public function testAutoLiteralSpace()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval: { \$foo} ");
|
$tpl = $this->smarty->createTemplate("string: { \$foo} ");
|
||||||
$tpl->assign('foo', 'literal');
|
$tpl->assign('foo', 'literal');
|
||||||
$this->assertEquals(' { $foo} ', $this->smarty->fetch($tpl));
|
$this->assertEquals(' { $foo} ', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class LiteralTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testAutoLiteralLineBreak()
|
public function testAutoLiteralLineBreak()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate("eval: {\n\$foo} ");
|
$tpl = $this->smarty->createTemplate("string: {\n\$foo} ");
|
||||||
$tpl->assign('foo', 'literal');
|
$tpl->assign('foo', 'literal');
|
||||||
$this->assertEquals(" {\n\$foo} ", $this->smarty->fetch($tpl));
|
$this->assertEquals(" {\n\$foo} ", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
@@ -60,8 +60,8 @@ class LiteralTest extends PHPUnit_Smarty
|
|||||||
public function testAutoLiteralDisabled()
|
public function testAutoLiteralDisabled()
|
||||||
{
|
{
|
||||||
$this->smarty->setAutoLiteral(false);
|
$this->smarty->setAutoLiteral(false);
|
||||||
$tpl = $this->smarty->createTemplate("eval: { \$foo} ");
|
$tpl = $this->smarty->createTemplate("string: { \$foo} ");
|
||||||
$tpl->assign('foo', 'literal');
|
$tpl->assign('foo', 'literal');
|
||||||
$this->assertEquals(' literal ', $this->smarty->fetch($tpl));
|
$this->assertEquals(' literal ', $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
if ($foo) {
|
if ($foo) {
|
||||||
$this->smarty->assign('foo', $foo);
|
$this->smarty->assign('foo', $foo);
|
||||||
}
|
}
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return array(array(1, '#001_test_foo.tpl:$foo=1'), array(2, '#001_test_foo.tpl:$foo=2'),
|
return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =2'),
|
||||||
array(null, '#001_test_foo.tpl:$foo=>unassigned<'),);
|
array(null, '#001_test_foo.tpl:$foo =>unassigned<'),);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +72,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
if ($foo) {
|
if ($foo) {
|
||||||
$this->smarty->assign('foo', $foo);
|
$this->smarty->assign('foo', $foo);
|
||||||
}
|
}
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,14 +87,14 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return array(array(1, '#001_test_foo.tpl:$foo=1'), array(2, '#001_test_foo.tpl:$foo=1'),
|
return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =1'),
|
||||||
array(null, '#001_test_foo.tpl:$foo=1'),);
|
array(null, '#001_test_foo.tpl:$foo =1'),);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {make_nocache} cached tags existing nocahe variable
|
* Test {make_nocache} cached tags existing nocahe variable
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestMakeNocache001_2
|
* @dataProvider dataTestMakeNocache001_2
|
||||||
*/
|
*/
|
||||||
@@ -104,7 +104,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
if ($foo) {
|
if ($foo) {
|
||||||
$this->smarty->assign('foo', $foo, true);
|
$this->smarty->assign('foo', $foo, true);
|
||||||
}
|
}
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,14 +119,14 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return array(array(1, '#001_test_foo.tpl:$foo=1'), array(2, '#001_test_foo.tpl:$foo=2'),
|
return array(array(1, '#001_test_foo.tpl:$foo =1'), array(2, '#001_test_foo.tpl:$foo =2'),
|
||||||
array(null, '#001_test_foo.tpl:$foo=1'),);
|
array(null, '#001_test_foo.tpl:$foo =1'),);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {make_nocache} cached tags reassign
|
* Test {make_nocache} cached tags reassign
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestMakeNocache001_3
|
* @dataProvider dataTestMakeNocache001_3
|
||||||
*/
|
*/
|
||||||
@@ -137,7 +137,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('foo', $foo);
|
$this->smarty->assign('foo', $foo);
|
||||||
}
|
}
|
||||||
$this->smarty->assign('bar', $foo + 4, true);
|
$this->smarty->assign('bar', $foo + 4, true);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo_assign.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo_assign.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,14 +152,14 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return array(array(1, '#001_test_foo_assign.tpl:$foo=5'), array(2, '#001_test_foo_assign.tpl:$foo=6'),
|
return array(array(1, '#001_test_foo_assign.tpl:$foo =5'), array(2, '#001_test_foo_assign.tpl:$foo =6'),
|
||||||
array(null, '#001_test_foo_assign.tpl:$foo=4'),);
|
array(null, '#001_test_foo_assign.tpl:$foo =4'),);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {make_nocache} cached tags {if}
|
* Test {make_nocache} cached tags {if}
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestMakeNocache001_4
|
* @dataProvider dataTestMakeNocache001_4
|
||||||
*/
|
*/
|
||||||
@@ -168,7 +168,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->setCaching(true);
|
$this->smarty->setCaching(true);
|
||||||
$this->smarty->assign('foo', $foo);
|
$this->smarty->assign('foo', $foo);
|
||||||
$this->smarty->assign('bar', $bar);
|
$this->smarty->assign('bar', $bar);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo_if.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo_if.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
/**
|
/**
|
||||||
* Test {make_nocache} cached tags {if} nocache
|
* Test {make_nocache} cached tags {if} nocache
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestMakeNocache001_5
|
* @dataProvider dataTestMakeNocache001_5
|
||||||
*/
|
*/
|
||||||
@@ -201,7 +201,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('foo', $foo);
|
$this->smarty->assign('foo', $foo);
|
||||||
}
|
}
|
||||||
$this->smarty->assign('bar', $bar, true);
|
$this->smarty->assign('bar', $bar, true);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo_if.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo_if.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
/**
|
/**
|
||||||
* Test {make_nocache} cached tags {foreach}
|
* Test {make_nocache} cached tags {foreach}
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestMakeNocache001_6
|
* @dataProvider dataTestMakeNocache001_6
|
||||||
*/
|
*/
|
||||||
@@ -232,7 +232,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->setCaching(true);
|
$this->smarty->setCaching(true);
|
||||||
$this->smarty->assign('foo', $foo, true);
|
$this->smarty->assign('foo', $foo, true);
|
||||||
$this->smarty->assign('bar', $bar);
|
$this->smarty->assign('bar', $bar);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo_foreach.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo_foreach.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,13 +248,13 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return array(array(2, array(1, 2, 3, 4), '12match34'), array(3, array(7, 8, 9), '123match4'),);
|
return array(array(2, array(1, 2, 3, 4), ' 1 2match 3 4'), array(3, array(7, 8, 9), ' 1 2 3match 4'),);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test {make_nocache} cached tags {foreach} nocache
|
* Test {make_nocache} cached tags {foreach} nocache
|
||||||
*
|
*
|
||||||
* @not runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider dataTestMakeNocache001_7
|
* @dataProvider dataTestMakeNocache001_7
|
||||||
*/
|
*/
|
||||||
@@ -264,7 +264,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->compile_id = 1;
|
$this->smarty->compile_id = 1;
|
||||||
$this->smarty->assign('foo', $foo, true);
|
$this->smarty->assign('foo', $foo, true);
|
||||||
$this->smarty->assign('bar', $bar, true);
|
$this->smarty->assign('bar', $bar, true);
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('001_test_foo_foreach.tpl')),
|
$this->assertEquals($result, $this->smarty->fetch('001_test_foo_foreach.tpl'),
|
||||||
"foo = {$foo}");
|
"foo = {$foo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
return array(array(2, array(1, 2, 3, 4), '12match34'), array(7, array(7, 8, 9), '7match89'),);
|
return array(array(2, array(1, 2, 3, 4), ' 1 2match 3 4'), array(7, array(7, 8, 9), ' 7match 8 9'),);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Test {make_nocache} with values containing '\'
|
* Test {make_nocache} with values containing '\'
|
||||||
@@ -291,7 +291,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->setCaching(true);
|
$this->smarty->setCaching(true);
|
||||||
$this->smarty->assign('foo', 'uwe\'s');
|
$this->smarty->assign('foo', 'uwe\'s');
|
||||||
$this->assertEquals($this->strip('uwe\'s'), $this->strip($this->smarty->fetch('002_test_backslash.tpl')));
|
$this->assertEquals($this->strip('uwe\'s'), $this->smarty->fetch('002_test_backslash.tpl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,7 +303,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->setCaching(true);
|
$this->smarty->setCaching(true);
|
||||||
$this->smarty->assign('foo', 'the Smarty template engine');
|
$this->smarty->assign('foo', 'the Smarty template engine');
|
||||||
$this->assertEquals($this->strip('the Smarty template engine'), $this->strip($this->smarty->fetch('003_test_spaces.tpl')));
|
$this->assertEquals('the Smarty template engine', $this->smarty->fetch('003_test_spaces.tpl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ class CompilePhpTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test
|
* Test
|
||||||
* @runInSeparateProcess
|
* @run InSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @dataProvider data
|
* @dataProvider data
|
||||||
*
|
*
|
||||||
@@ -43,6 +43,7 @@ class CompilePhpTest extends PHPUnit_Smarty
|
|||||||
public function testPHP($phpHandling, $templateFile, $result, $testName)
|
public function testPHP($phpHandling, $templateFile, $result, $testName)
|
||||||
{
|
{
|
||||||
$result = str_replace("\r", '', $result);
|
$result = str_replace("\r", '', $result);
|
||||||
|
$this->smartyBC->force_compile = true;
|
||||||
$this->smartyBC->php_handling = $phpHandling;
|
$this->smartyBC->php_handling = $phpHandling;
|
||||||
$this->smartyBC->compile_id = $testName.$this->smartyBC->php_handling ;
|
$this->smartyBC->compile_id = $testName.$this->smartyBC->php_handling ;
|
||||||
$tpl = $this->smartyBC->createTemplate($templateFile);
|
$tpl = $this->smartyBC->createTemplate($templateFile);
|
||||||
|
@@ -24,113 +24,113 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = "\n\nThis is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n";
|
$result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "\n\nThis is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n";
|
$result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndent()
|
public function testIndent()
|
||||||
{
|
{
|
||||||
$result = "\n\n This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n";
|
$result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentWithoutMbstring()
|
public function testIndentWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "\n\n This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n";
|
$result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentFirst()
|
public function testIndentFirst()
|
||||||
{
|
{
|
||||||
$result = "\n\n This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n";
|
$result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentFirstWithoutMbstring()
|
public function testIndentFirstWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "\n\n This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n";
|
$result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentchar()
|
public function testIndentchar()
|
||||||
{
|
{
|
||||||
$result = "\n\n####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n";
|
$result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentcharWithoutMbstring()
|
public function testIndentcharWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "\n\n####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n";
|
$result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentcharFirst()
|
public function testIndentcharFirst()
|
||||||
{
|
{
|
||||||
$result = "\n\n########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n";
|
$result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndentcharFirstWithoutMbstring()
|
public function testIndentcharFirstWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "\n\n########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n";
|
$result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrapchar()
|
public function testWrapchar()
|
||||||
{
|
{
|
||||||
$result = "## This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##";
|
$result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWrapcharWithoutMbstring()
|
public function testWrapcharWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "## This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##";
|
$result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStyleEmail()
|
public function testStyleEmail()
|
||||||
{
|
{
|
||||||
$result = "\n\nThis is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n";
|
$result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat style="email"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStyleEmailWithoutMbstring()
|
public function testStyleEmailWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$result = "\n\nThis is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n";
|
$result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{textformat style="email"}' . $this->string . '{/textformat}');
|
$tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($this->smarty->fetch($tpl)));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1002 => 'Jane Johnson',
|
1002 => 'Jane Johnson',
|
||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparateArrays()
|
public function testSeparateArrays()
|
||||||
@@ -59,7 +59,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
'Charlie Brown',
|
'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIterator()
|
public function testIterator()
|
||||||
@@ -80,7 +80,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
'Charlie Brown',
|
'Charlie Brown',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNoLabels()
|
public function testNoLabels()
|
||||||
@@ -100,7 +100,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithId()
|
public function testWithId()
|
||||||
@@ -120,7 +120,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
'work s ä' => 'Charlie Brown',
|
'work s ä' => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullString()
|
public function testNullString()
|
||||||
@@ -142,7 +142,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullValue()
|
public function testNullValue()
|
||||||
@@ -164,7 +164,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroValue()
|
public function testZeroValue()
|
||||||
@@ -186,7 +186,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroStringValue()
|
public function testZeroStringValue()
|
||||||
@@ -208,7 +208,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringValue()
|
public function testEmptyStringValue()
|
||||||
@@ -230,7 +230,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObject()
|
public function testObject()
|
||||||
@@ -250,7 +250,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObjectList()
|
public function testObjectList()
|
||||||
@@ -270,7 +270,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1003 => new _object_toString('Charlie Brown'),
|
1003 => new _object_toString('Charlie Brown'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $_errors = array();
|
protected $_errors = array();
|
||||||
@@ -351,7 +351,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisabledStrict1()
|
public function testDisabledStrict1()
|
||||||
@@ -371,7 +371,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
public function testDisabledStrict2()
|
public function testDisabledStrict2()
|
||||||
{
|
{
|
||||||
@@ -410,6 +410,6 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparateArrays()
|
public function testSeparateArrays()
|
||||||
@@ -60,7 +60,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
'Charlie Brown',
|
'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIterator()
|
public function testIterator()
|
||||||
@@ -80,7 +80,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptgroup()
|
public function testOptgroup()
|
||||||
@@ -112,7 +112,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullString()
|
public function testNullString()
|
||||||
@@ -146,7 +146,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullValue()
|
public function testNullValue()
|
||||||
@@ -184,7 +184,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroValue()
|
public function testZeroValue()
|
||||||
@@ -218,7 +218,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroStringValue()
|
public function testZeroStringValue()
|
||||||
@@ -252,7 +252,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringValue()
|
public function testEmptyStringValue()
|
||||||
@@ -286,7 +286,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringValues()
|
public function testEmptyStringValues()
|
||||||
@@ -324,7 +324,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObject()
|
public function testObject()
|
||||||
@@ -344,7 +344,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObjectList()
|
public function testObjectList()
|
||||||
@@ -364,7 +364,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => new _object_toString('Charlie Brown'),
|
2003 => new _object_toString('Charlie Brown'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $_errors = array();
|
protected $_errors = array();
|
||||||
@@ -443,7 +443,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisabledStrict()
|
public function testDisabledStrict()
|
||||||
@@ -463,7 +463,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
|
|
||||||
$n = "\n";
|
$n = "\n";
|
||||||
$expected = '<select name="foo" disabled="disabled">'
|
$expected = '<select name="foo" disabled="disabled">'
|
||||||
@@ -480,7 +480,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
|
|
||||||
$n = "\n";
|
$n = "\n";
|
||||||
$expected = '<select name="foo" disabled="disabled">'
|
$expected = '<select name="foo" disabled="disabled">'
|
||||||
@@ -497,6 +497,6 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
|
|||||||
2003 => 'Charlie Brown',
|
2003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSeparateArrays()
|
public function testSeparateArrays()
|
||||||
@@ -59,7 +59,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
'Charlie Brown',
|
'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIterator()
|
public function testIterator()
|
||||||
@@ -80,7 +80,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
'Charlie Brown',
|
'Charlie Brown',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNoLabels()
|
public function testNoLabels()
|
||||||
@@ -100,7 +100,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithId()
|
public function testWithId()
|
||||||
@@ -120,7 +120,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
'work s ä' => 'Charlie Brown',
|
'work s ä' => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullString()
|
public function testNullString()
|
||||||
@@ -142,7 +142,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullValue()
|
public function testNullValue()
|
||||||
@@ -164,7 +164,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroValue()
|
public function testZeroValue()
|
||||||
@@ -186,7 +186,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroStringValue()
|
public function testZeroStringValue()
|
||||||
@@ -208,7 +208,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringValue()
|
public function testEmptyStringValue()
|
||||||
@@ -230,7 +230,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
2 => 'two',
|
2 => 'two',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObject()
|
public function testObject()
|
||||||
@@ -250,7 +250,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObjectList()
|
public function testObjectList()
|
||||||
@@ -270,7 +270,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => new _object_toString('Charlie Brown'),
|
1003 => new _object_toString('Charlie Brown'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $_errors = array();
|
protected $_errors = array();
|
||||||
@@ -351,7 +351,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisabledStrict()
|
public function testDisabledStrict()
|
||||||
@@ -371,7 +371,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
|
|
||||||
$n = "\n";
|
$n = "\n";
|
||||||
$expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />'
|
$expected = '<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />'
|
||||||
@@ -388,7 +388,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
|
|
||||||
$n = "\n";
|
$n = "\n";
|
||||||
$expected = '<label><input type="radio" name="id" value="1000" disabled="disabled" />Joe Schmoe</label><br />'
|
$expected = '<label><input type="radio" name="id" value="1000" disabled="disabled" />Joe Schmoe</label><br />'
|
||||||
@@ -405,6 +405,6 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
|
|||||||
1003 => 'Charlie Brown',
|
1003 => 'Charlie Brown',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals($this->normalizeString($expected), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($expected, $tpl->fetch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -255,7 +255,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . '}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . '}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPrefix()
|
public function testPrefix()
|
||||||
@@ -265,7 +265,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="foobar_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="foobar_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="foobar_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="foobar_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' prefix="foobar_"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' prefix="foobar_"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFieldArray()
|
public function testFieldArray()
|
||||||
@@ -275,13 +275,13 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="namorized[Date_Day]">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="namorized[Date_Day]">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="namorized[Date_Year]">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="namorized[Date_Year]">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="namorized[foobar_Month]">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="namorized[foobar_Month]">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="namorized[foobar_Day]">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="namorized[foobar_Day]">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="namorized[foobar_Year]">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="namorized[foobar_Year]">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized" prefix="foobar_"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_array="namorized" prefix="foobar_"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtra()
|
public function testExtra()
|
||||||
@@ -291,19 +291,19 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day" data-foo="xy">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day" data-foo="xy">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year" data-foo="xy">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year" data-foo="xy">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_extra="data-foo=\"xy\""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_extra="data-foo=\"xy\""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month" data-foo="month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month" data-foo="month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day" data-foo="day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day" data-foo="day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year" data-foo="year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year" data-foo="year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_extra="data-foo=\"day\"" month_extra="data-foo=\"month\"" year_extra="data-foo=\"year\""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_extra="data-foo=\"day\"" month_extra="data-foo=\"month\"" year_extra="data-foo=\"year\""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month" data_foo="foo">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month" data_foo="foo">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day" data_foo="foo">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day" data_foo="foo">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year" data_foo="foo">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year" data_foo="foo">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' data_foo="foo"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' data_foo="foo"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFieldOrder()
|
public function testFieldOrder()
|
||||||
@@ -313,13 +313,13 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
. $n . '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'
|
$result = '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
. $n . '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>';
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFieldSeparator()
|
public function testFieldSeparator()
|
||||||
@@ -329,13 +329,13 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. ' - <select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
. ' - <select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. ' - <select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. ' - <select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY" field_separator=" - "}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="DMY" field_separator=" - "}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'
|
$result = '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>'
|
||||||
. ' / <select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
. ' / <select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. ' / <select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>';
|
. ' / <select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD" field_separator=" / "}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' field_order="YMD" field_separator=" / "}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmpty()
|
public function testEmpty()
|
||||||
@@ -345,25 +345,25 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . '<option value=""></option>' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . '<option value=""></option>' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty=""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty=""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . '<option value="">all</option>' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . '<option value="">all</option>' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . '<option value="">all</option>' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . '<option value="">all</option>' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value="">all</option>' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value="">all</option>' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty="all"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_empty="all"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty=""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty=""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . '<option value="">month</option>' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . '<option value="">month</option>' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . '<option value="">day</option>' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . '<option value="">day</option>' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value="">year</option>' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value="">year</option>' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty="year" month_empty="month" day_empty="day"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_empty="year" month_empty="month" day_empty="day"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyUnset()
|
public function testEmptyUnset()
|
||||||
@@ -373,25 +373,25 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . '<option value=""></option>' . $n . $this->days['none'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . '<option value=""></option>' . $n . $this->days['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['none'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['none'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty=""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty=""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . '<option value="">all</option>' . $n . $this->months['none'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . '<option value="">all</option>' . $n . $this->months['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . '<option value="">all</option>' . $n . $this->days['none'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . '<option value="">all</option>' . $n . $this->days['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value="">all</option>' . $n . $this->years['none'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value="">all</option>' . $n . $this->years['none'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty="all"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null all_empty="all"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . $this->months['none'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . $this->months['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . $this->days['none'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['none'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value=""></option>' . $n . $this->years['none'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty=""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty=""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . '<option value="">month</option>' . $n . $this->months['none'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . '<option value="">month</option>' . $n . $this->months['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . '<option value="">day</option>' . $n . $this->days['none'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . '<option value="">day</option>' . $n . $this->days['none'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . '<option value="">year</option>' . $n . $this->years['none'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . '<option value="">year</option>' . $n . $this->years['none'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty="year" month_empty="month" day_empty="day"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=null year_empty="year" month_empty="month" day_empty="day"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testId()
|
public function testId()
|
||||||
@@ -401,19 +401,19 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day" id="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day" id="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year" id="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year" id="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id=""}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id=""}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month" id="all-Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month" id="all-Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day" id="all-Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day" id="all-Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year" id="all-Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year" id="all-Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id="all-"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' all_id="all-"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month" id="month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month" id="month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day" id="day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day" id="day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year" id="year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year" id="year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_id="year" month_id="month" day_id="day"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_id="year" month_id="month" day_id="day"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStartYearAbsolute()
|
public function testStartYearAbsolute()
|
||||||
@@ -423,7 +423,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['start_2005'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['start_2005'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStartYearRelative()
|
public function testStartYearRelative()
|
||||||
@@ -433,7 +433,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['start_+5'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['start_+5'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStartYearRelativeNegative()
|
public function testStartYearRelativeNegative()
|
||||||
@@ -443,7 +443,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['start_-5'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['start_-5'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="-5"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="-5"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEndYearAbsolute()
|
public function testEndYearAbsolute()
|
||||||
@@ -453,7 +453,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['end_2005'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['end_2005'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year=2005}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year=2005}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEndYearRelative()
|
public function testEndYearRelative()
|
||||||
@@ -463,7 +463,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['end_+5'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['end_+5'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="+5"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="+5"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEndYearRelativeNegative()
|
public function testEndYearRelativeNegative()
|
||||||
@@ -473,7 +473,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['end_-5'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['end_-5'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="-5"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' end_year="-5"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisplayDaysMonthYear()
|
public function testDisplayDaysMonthYear()
|
||||||
@@ -482,17 +482,17 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_days=false}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_days=false}');
|
||||||
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_months=false}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_months=false}');
|
||||||
$result = '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
$result = '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_years=false}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' display_years=false}');
|
||||||
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>';
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>';
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYearsReversed()
|
public function testYearsReversed()
|
||||||
@@ -502,13 +502,13 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->reverse($this->years['start_2005']) . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->reverse($this->years['start_2005']) . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005 reverse_years=true}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year=2005 reverse_years=true}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
$result = '<select name="Date_Month">' . $n . $this->months['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->reverse($this->years['start_+5']) . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->reverse($this->years['start_+5']) . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5" reverse_years=true}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' start_year="+5" reverse_years=true}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYearText()
|
public function testYearText()
|
||||||
@@ -525,7 +525,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="foo_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="foo_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . "<input type=\"text\" name=\"foo_Year\" value=\"{$year}\" size=\"4\" maxlength=\"4\" />";
|
. $n . "<input type=\"text\" name=\"foo_Year\" value=\"{$year}\" size=\"4\" maxlength=\"4\" />";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_as_text=true prefix="foo_"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' year_as_text=true prefix="foo_"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMonthFormat()
|
public function testMonthFormat()
|
||||||
@@ -535,7 +535,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_format="%b"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_format="%b"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMonthFormatValue()
|
public function testMonthFormatValue()
|
||||||
@@ -545,7 +545,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_value_format="%b"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' month_value_format="%b"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMonthNames()
|
public function testMonthNames()
|
||||||
@@ -555,7 +555,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['default'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$names = [1 => "alpha","bravo","charlie","delta","echo","foxtrot","golf","hotel","india","juliet","kilo","lima"]}{html_select_date time=' . $this->now . ' month_names=$names}');
|
$tpl = $this->smarty->createTemplate('eval:{$names = [1 => "alpha","bravo","charlie","delta","echo","foxtrot","golf","hotel","india","juliet","kilo","lima"]}{html_select_date time=' . $this->now . ' month_names=$names}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDayFormat()
|
public function testDayFormat()
|
||||||
@@ -565,7 +565,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['format_%03d'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['format_%03d'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_format="%03d"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_format="%03d"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDayFormatValue()
|
public function testDayFormatValue()
|
||||||
@@ -575,7 +575,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
. $n . '<select name="Date_Day">' . $n . $this->days['format_value_%03d'] . $n . '</select>'
|
. $n . '<select name="Date_Day">' . $n . $this->days['format_value_%03d'] . $n . '</select>'
|
||||||
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
. $n . '<select name="Date_Year">' . $n . $this->years['default'] . $n . '</select>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_value_format="%03d"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=' . $this->now . ' day_value_format="%03d"}');
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTimeArray()
|
public function testTimeArray()
|
||||||
@@ -595,10 +595,10 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array.namorized field_array="namorized" prefix="foobar_"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array.namorized field_array="namorized" prefix="foobar_"}');
|
||||||
$tpl->assign('date_array', $date_array);
|
$tpl->assign('date_array', $date_array);
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array field_array="namorized" prefix="foobar_"}');
|
$tpl = $this->smarty->createTemplate('eval:{html_select_date time=$date_array field_array="namorized" prefix="foobar_"}');
|
||||||
$tpl->assign('date_array', $date_array);
|
$tpl->assign('date_array', $date_array);
|
||||||
$this->assertEquals($this->normalizeString($result), $this->normalizeString($tpl->fetch()));
|
$this->assertEquals($result, $tpl->fetch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,38 +10,41 @@
|
|||||||
* class for modifier tests
|
* class for modifier tests
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcess
|
* @runTestsInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @backupStaticAttributes enabled
|
* @backupStaticAttributes enabled
|
||||||
*/
|
*/
|
||||||
class PluginModifierCapitalizeTest extends PHPUnit_Smarty
|
class PluginModifierCapitalizeTest extends PHPUnit_Smarty
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize}');
|
||||||
$this->assertEquals("Next X-Men FiLm, x3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, x3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDigits()
|
public function testDigits()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true}');
|
||||||
$this->assertEquals("Next X-Men FiLm, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTrueCaptials()
|
public function testTrueCaptials()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed. ümlauts äre cööl."|capitalize:true:true}');
|
||||||
$this->assertEquals("Next X-Men Film, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men Film, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, delayed."|capitalize}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize}');
|
||||||
$this->assertEquals("Next X-Men FiLm, x3, Delayed.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, x3, Delayed.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -49,7 +52,8 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
|
|||||||
public function testDigitsWithoutMbstring()
|
public function testDigitsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, delayed."|capitalize:true}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true}');
|
||||||
$this->assertEquals("Next X-Men FiLm, X3, Delayed.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, X3, Delayed.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -57,79 +61,92 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
|
|||||||
public function testTrueCaptialsWithoutMbstring()
|
public function testTrueCaptialsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, delayed."|capitalize:true:true}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true:true}');
|
||||||
$this->assertEquals("Next X-Men Film, X3, Delayed.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men Film, X3, Delayed.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotes()
|
public function testQuotes()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}');
|
||||||
$this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}');
|
||||||
$this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesWithoutMbstring()
|
public function testQuotesWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}');
|
||||||
$this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}');
|
||||||
$this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesDigits()
|
public function testQuotesDigits()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}');
|
||||||
$this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}');
|
||||||
$this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesDigitsWithoutMbstring()
|
public function testQuotesDigitsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}');
|
||||||
$this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}');
|
||||||
$this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesTrueCapitals()
|
public function testQuotesTrueCapitals()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}');
|
||||||
$this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}');
|
||||||
$this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesTrueCapitalsWithoutMbstring()
|
public function testQuotesTrueCapitalsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}');
|
||||||
$this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}');
|
$tpl =
|
||||||
|
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}');
|
||||||
$this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesBeginning()
|
public function testQuotesBeginning()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"\"delayed. umlauts\" foo."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}');
|
||||||
$this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"\'delayed. umlauts\' foo."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}');
|
||||||
$this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuotesBeginningWithoutMbstring()
|
public function testQuotesBeginningWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"\"delayed. umlauts\" foo."|capitalize}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}');
|
||||||
$this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"\'delayed. umlauts\' foo."|capitalize}');
|
$tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}');
|
||||||
$this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
$this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
* class for modifier tests
|
* class for modifier tests
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcess
|
* @runTestsInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @backupStaticAttributes enabled
|
* @backupStaticAttributes enabled
|
||||||
*/
|
*/
|
||||||
class PluginModifierCharsetTest extends PHPUnit_Smarty
|
class PluginModifierCharsetTest extends PHPUnit_Smarty
|
||||||
@@ -24,16 +24,17 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$encoded = "hällö wörld 1";
|
$encoded = "hällö wörld 1";
|
||||||
$result = utf8_decode($encoded);
|
$result = utf8_decode($encoded);
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|to_charset}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testToLatin1WithoutMbstring()
|
public function testToLatin1WithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId('mb');
|
||||||
$encoded = "hällö wörld 2";
|
$encoded = "hällö wörld 2";
|
||||||
$result = utf8_decode($encoded);
|
$result = utf8_decode($encoded);
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|to_charset}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}');
|
||||||
$this->assertEquals($encoded, $tpl->fetch());
|
$this->assertEquals($encoded, $tpl->fetch());
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -42,16 +43,17 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$result = "hällö wörld 3";
|
$result = "hällö wörld 3";
|
||||||
$encoded = utf8_decode($result);
|
$encoded = utf8_decode($result);
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|from_charset}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFromLatin1WithoutMbstring()
|
public function testFromLatin1WithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId('mb');
|
||||||
$result = "hällö wörld 4";
|
$result = "hällö wörld 4";
|
||||||
$encoded = utf8_decode($result);
|
$encoded = utf8_decode($result);
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|from_charset}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}');
|
||||||
$this->assertEquals($encoded, $tpl->fetch());
|
$this->assertEquals($encoded, $tpl->fetch());
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -60,16 +62,17 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$result = "hällö wörld 5";
|
$result = "hällö wörld 5";
|
||||||
$encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8");
|
$encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8");
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|from_charset:"UTF-32LE"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFromUtf32leWithoutMbstring()
|
public function testFromUtf32leWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId('mb');
|
||||||
$result = "hällö wörld 6";
|
$result = "hällö wörld 6";
|
||||||
$encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8");
|
$encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8");
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|from_charset:"UTF-32LE"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}');
|
||||||
$this->assertEquals($encoded, $tpl->fetch());
|
$this->assertEquals($encoded, $tpl->fetch());
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -78,16 +81,17 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$encoded = "hällö wörld 7";
|
$encoded = "hällö wörld 7";
|
||||||
$result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8");
|
$result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8");
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|to_charset:"UTF-32LE"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testToUtf32leWithoutMbstring()
|
public function testToUtf32leWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId('mb');
|
||||||
$encoded = "hällö wörld 8";
|
$encoded = "hällö wörld 8";
|
||||||
$result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8");
|
$result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8");
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|to_charset:"UTF-32LE"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}');
|
||||||
$this->assertEquals($encoded, $tpl->fetch());
|
$this->assertEquals($encoded, $tpl->fetch());
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
* class for modifier tests
|
* class for modifier tests
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcess
|
* @runTestsInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @backupStaticAttributes enabled
|
* @backupStaticAttributes enabled
|
||||||
*/
|
*/
|
||||||
class PluginModifierCountCharactersTest extends PHPUnit_Smarty
|
class PluginModifierCountCharactersTest extends PHPUnit_Smarty
|
||||||
@@ -23,15 +23,16 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
|
|||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = "29";
|
$result = "29";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wave Linked to Temperatures."|count_characters}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId ('mb');
|
||||||
$result = "29";
|
$result = "29";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wave Linked to Temperatures."|count_characters}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -39,15 +40,16 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
|
|||||||
public function testSpaces()
|
public function testSpaces()
|
||||||
{
|
{
|
||||||
$result = "33";
|
$result = "33";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wave Linked to Temperatures."|count_characters:true}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSpacesWithoutMbstring()
|
public function testSpacesWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId ('mb');
|
||||||
$result = "33";
|
$result = "33";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wave Linked to Temperatures."|count_characters:true}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -55,15 +57,16 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
|
|||||||
public function testUmlauts()
|
public function testUmlauts()
|
||||||
{
|
{
|
||||||
$result = "29";
|
$result = "29";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wäve Linked tö Temperatures."|count_characters}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlautsWithoutMbstring()
|
public function testUmlautsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId ('mb');
|
||||||
$result = "29";
|
$result = "29";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wäve Linked tö Temperatures."|count_characters}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -71,15 +74,16 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
|
|||||||
public function testUmlautsSpaces()
|
public function testUmlautsSpaces()
|
||||||
{
|
{
|
||||||
$result = "33";
|
$result = "33";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wäve Linked tö Temperatures."|count_characters:true}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlautsSpacesWithoutMbstring()
|
public function testUmlautsSpacesWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
|
$this->smarty->setCompileId ('mb');
|
||||||
$result = "33";
|
$result = "33";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Cold Wäve Linked tö Temperatures."|count_characters:true}');
|
$tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}');
|
||||||
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ class PluginModifierCountSentencesTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}');
|
||||||
$this->assertEquals("1", $this->smarty->fetch($tpl));
|
$this->assertEquals("1", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello world. I\'m another? Sentence!"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}');
|
||||||
$this->assertEquals("3", $this->smarty->fetch($tpl));
|
$this->assertEquals("3", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}');
|
||||||
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
||||||
@@ -37,27 +37,27 @@ class PluginModifierCountSentencesTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello world."|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}');
|
||||||
$this->assertEquals("1", $this->smarty->fetch($tpl));
|
$this->assertEquals("1", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello world. I\'m another? Sentence!"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}');
|
||||||
$this->assertEquals("3", $this->smarty->fetch($tpl));
|
$this->assertEquals("3", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello world.wrong"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}');
|
||||||
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlauts()
|
public function testUmlauts()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello worldä."|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello worldä."|count_sentences}');
|
||||||
$this->assertEquals("1", $this->smarty->fetch($tpl));
|
$this->assertEquals("1", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello worldü. ä\'m another? Sentence!"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello worldü. ä\'m another? Sentence!"|count_sentences}');
|
||||||
$this->assertEquals("3", $this->smarty->fetch($tpl));
|
$this->assertEquals("3", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello worlä.ärong"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello worlä.ärong"|count_sentences}');
|
||||||
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello worlä.wrong"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello worlä.wrong"|count_sentences}');
|
||||||
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello world.ärong"|count_sentences}');
|
$tpl = $this->smarty->createTemplate('string:{"hello world.ärong"|count_sentences}');
|
||||||
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
$this->assertEquals("0", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,15 +23,15 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty
|
|||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = "7";
|
$result = "7";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Dealers Will Hear Car Talk at Noon."|count_words}');
|
$tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "7";
|
$result = "7";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Dealers Will Hear Car Talk at Noon."|count_words}');
|
$tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -39,15 +39,15 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty
|
|||||||
public function testDashes()
|
public function testDashes()
|
||||||
{
|
{
|
||||||
$result = "7";
|
$result = "7";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}');
|
$tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDashesWithoutMbstring()
|
public function testDashesWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "7";
|
$result = "7";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}');
|
$tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -55,15 +55,15 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty
|
|||||||
public function testUmlauts()
|
public function testUmlauts()
|
||||||
{
|
{
|
||||||
$result = "7";
|
$result = "7";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Dealers Will Hear Cär Talk at Nöön."|count_words}');
|
$tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlautsWithoutMbstring()
|
public function testUmlautsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "7";
|
$result = "7";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Dealers Will Hear Cär Talk at Nöön."|count_words}');
|
$tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}');
|
||||||
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -22,98 +22,98 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testHtml()
|
public function testHtml()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html"}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html"}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlWithoutMbstring()
|
public function testHtmlWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html"}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html"}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlDouble()
|
public function testHtmlDouble()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html":null:false}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html":null:false}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlDoubleWithoutMbstring()
|
public function testHtmlDoubleWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html":null:false}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"html":null:false}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlall()
|
public function testHtmlall()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall"}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall"}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlallWithoutMbstring()
|
public function testHtmlallWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall"}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall"}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlallDouble()
|
public function testHtmlallDouble()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall":null:false}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall":null:false}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlallDoubleWithoutMbstring()
|
public function testHtmlallDoubleWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall":null:false}');
|
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or ©"|escape:"htmlall":null:false}');
|
||||||
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUrl()
|
public function testUrl()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"http://some.encoded.com/url?parts#foo"|escape:"url"}');
|
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}');
|
||||||
$this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl));
|
$this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUrlWithoutMbstring()
|
public function testUrlWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"http://some.encoded.com/url?parts#foo"|escape:"url"}');
|
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}');
|
||||||
$this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl));
|
$this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUrlpathinfo()
|
public function testUrlpathinfo()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}');
|
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}');
|
||||||
$this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl));
|
$this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUrlpathinfoWithoutMbstring()
|
public function testUrlpathinfoWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}');
|
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}');
|
||||||
$this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl));
|
$this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHex()
|
public function testHex()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"a/cäa"|escape:"hex"}');
|
$tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}');
|
||||||
$this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl));
|
$this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHexWithoutMbstring()
|
public function testHexWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"a/cäa"|escape:"hex"}');
|
$tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}');
|
||||||
$this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl));
|
$this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -122,22 +122,22 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$q = "aäЗдравсствуйте";
|
$q = "aäЗдравсствуйте";
|
||||||
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $r . '"|escape:"hexentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}');
|
||||||
$this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
$this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"abc"|escape:"hexentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}');
|
||||||
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHexentityWithoutMbstring()
|
public function testHexentityWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$q = "aäЗдравсствуйте";
|
$q = "aäЗдравсствуйте";
|
||||||
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $r . '"|escape:"hexentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}');
|
||||||
$this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
$this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"abc"|escape:"hexentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}');
|
||||||
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -146,64 +146,64 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$q = "aäЗдравсствуйте";
|
$q = "aäЗдравсствуйте";
|
||||||
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $r . '"|escape:"decentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}');
|
||||||
$this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
$this->assertEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"abc"|escape:"decentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}');
|
||||||
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDecentityWithoutMbstring()
|
public function testDecentityWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$q = "aäЗдравсствуйте";
|
$q = "aäЗдравсствуйте";
|
||||||
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $r . '"|escape:"decentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}');
|
||||||
$this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
$this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"abc"|escape:"decentity"}');
|
$tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}');
|
||||||
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
$this->assertEquals("abc", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testJavascript()
|
public function testJavascript()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}');
|
$tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}');
|
||||||
$this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl));
|
$this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testJavascriptWithoutMbstring()
|
public function testJavascriptWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}');
|
$tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}');
|
||||||
$this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl));
|
$this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMail()
|
public function testMail()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"smarty@example.com"|escape:"mail"}');
|
$tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}');
|
||||||
$this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl));
|
$this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMailWithoutMbstring()
|
public function testMailWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"smarty@example.com"|escape:"mail"}');
|
$tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}');
|
||||||
$this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl));
|
$this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonstd()
|
public function testNonstd()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"sma\'rty|»example«.com"|escape:"nonstd"}');
|
$tpl = $this->smarty->createTemplate('string:{"sma\'rty|»example«.com"|escape:"nonstd"}');
|
||||||
$this->assertEquals("sma'rty|»example«.com", $this->smarty->fetch($tpl));
|
$this->assertEquals("sma'rty|»example«.com", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonstdWithoutMbstring()
|
public function testNonstdWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . utf8_decode('sma\'rty@»example«.com') . '"|escape:"nonstd"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . utf8_decode('sma\'rty@»example«.com') . '"|escape:"nonstd"}');
|
||||||
$this->assertEquals("sma'rty@»example«.com", $this->smarty->fetch($tpl));
|
$this->assertEquals("sma'rty@»example«.com", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -22,15 +22,15 @@ class PluginModifierLowerTest extends PHPUnit_Smarty
|
|||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = "two convicts evade noose, jury hung.";
|
$result = "two convicts evade noose, jury hung.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Convicts Evade Noose, Jury Hung."|lower}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "two convicts evade noose, jury hung.";
|
$result = "two convicts evade noose, jury hung.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Convicts Evade Noose, Jury Hung."|lower}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -38,15 +38,15 @@ class PluginModifierLowerTest extends PHPUnit_Smarty
|
|||||||
public function testUmlauts()
|
public function testUmlauts()
|
||||||
{
|
{
|
||||||
$result = "two convicts eväde nööse, jury hung.";
|
$result = "two convicts eväde nööse, jury hung.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlautsWithoutMbstring()
|
public function testUmlautsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "two convicts eväde nööse, jury hung.";
|
$result = "two convicts eväde nööse, jury hung.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}');
|
||||||
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -22,24 +22,24 @@ class PluginModifierRegexReplaceTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}');
|
$tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}');
|
||||||
$this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}');
|
$tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}');
|
||||||
$this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlauts()
|
public function testUmlauts()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Infertility unlikely tö\näe passed on, experts say."|regex_replace:"/[\r\t\n]/u":" "}');
|
$tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tö\näe passed on, experts say."|regex_replace:"/[\r\t\n]/u":" "}');
|
||||||
$this->assertEquals("Infertility unlikely tö äe passed on, experts say.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Infertility unlikely tö äe passed on, experts say.", $this->smarty->fetch($tpl));
|
||||||
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Infertility unlikely tä be passed on, experts say."|regex_replace:"/[ä]/ue":"ae"}');
|
$tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tä be passed on, experts say."|regex_replace:"/[ä]/ue":"ae"}');
|
||||||
$this->assertEquals("Infertility unlikely tae be passed on, experts say.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Infertility unlikely tae be passed on, experts say.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,14 +23,14 @@ class PluginModifierSpacifyTest extends PHPUnit_Smarty
|
|||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = 'h e l l o w ö r l d';
|
$result = 'h e l l o w ö r l d';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello wörld"|spacify}');
|
$tpl = $this->smarty->createTemplate('string:{"hello wörld"|spacify}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCharacter()
|
public function testCharacter()
|
||||||
{
|
{
|
||||||
$result = 'h##e##l##l##o## ##w##ö##r##l##d';
|
$result = 'h##e##l##l##o## ##w##ö##r##l##d';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"hello wörld"|spacify:"##"}');
|
$tpl = $this->smarty->createTemplate('string:{"hello wörld"|spacify:"##"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ class PluginModifierStripTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{" hello spaced words "|strip}');
|
$tpl = $this->smarty->createTemplate('string:{" hello spaced words "|strip}');
|
||||||
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,13 +31,13 @@ class PluginModifierStripTest extends PHPUnit_Smarty
|
|||||||
// Some Unicode Spaces
|
// Some Unicode Spaces
|
||||||
$string = " hello spaced       words ";
|
$string = " hello spaced       words ";
|
||||||
$string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES");
|
$string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES");
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $string . '"|strip}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}');
|
||||||
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLinebreak()
|
public function testLinebreak()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{" hello
|
$tpl = $this->smarty->createTemplate('string:{" hello
|
||||||
spaced words "|strip}');
|
spaced words "|strip}');
|
||||||
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
@@ -23,15 +23,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.';
|
$result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.';
|
$result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -39,15 +39,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testLength()
|
public function testLength()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Reunite after...';
|
$result = 'Two Sisters Reunite after...';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLengthWithoutMbstring()
|
public function testLengthWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Reunite after...';
|
$result = 'Two Sisters Reunite after...';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -55,15 +55,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testEtc()
|
public function testEtc()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Reunite after';
|
$result = 'Two Sisters Reunite after';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEtcWithoutMbstring()
|
public function testEtcWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Reunite after';
|
$result = 'Two Sisters Reunite after';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -71,15 +71,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testEtc2()
|
public function testEtc2()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Reunite after---';
|
$result = 'Two Sisters Reunite after---';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEtc2WithoutMbstring()
|
public function testEtc2WithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Reunite after---';
|
$result = 'Two Sisters Reunite after---';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -87,15 +87,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testBreak()
|
public function testBreak()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Reunite after Eigh';
|
$result = 'Two Sisters Reunite after Eigh';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBreakWithoutMbstring()
|
public function testBreakWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Reunite after Eigh';
|
$result = 'Two Sisters Reunite after Eigh';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -103,15 +103,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testBreak2()
|
public function testBreak2()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Reunite after E...';
|
$result = 'Two Sisters Reunite after E...';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBreak2WithoutMbstring()
|
public function testBreak2WithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Reunite after E...';
|
$result = 'Two Sisters Reunite after E...';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -119,15 +119,15 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
|
|||||||
public function testMiddle()
|
public function testMiddle()
|
||||||
{
|
{
|
||||||
$result = 'Two Sisters Re..ckout Counter.';
|
$result = 'Two Sisters Re..ckout Counter.';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMiddleWithoutMbstring()
|
public function testMiddleWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = 'Two Sisters Re..ckout Counter.';
|
$result = 'Two Sisters Re..ckout Counter.';
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}');
|
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -24,16 +24,16 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
||||||
$result = "aäЗдра><&ääвсствуйте";
|
$result = "aäЗдра><&ääвсствуйте";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|unescape:"html"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}');
|
||||||
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlWithoutMbstring()
|
public function testHtmlWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
||||||
$result = "aäЗдра><&ääвсствуйте";
|
$result = "aäЗдра><&ääвсствуйте";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|unescape:"html"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}');
|
||||||
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -42,16 +42,16 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
||||||
$result = "aäЗдра><&ääвсствуйте";
|
$result = "aäЗдра><&ääвсствуйте";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|unescape:"htmlall"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}');
|
||||||
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHtmlallWithoutMbstring()
|
public function testHtmlallWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
$encoded = "aäЗдра><&amp;ääвсствуйте";
|
||||||
$result = "aäЗдра><&ääвсствуйте";
|
$result = "aäЗдра><&ääвсствуйте";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|unescape:"htmlall"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}');
|
||||||
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$encoded = "a%C3%A4%D0%97%D0%B4%D1%80%D0%B0%3E%3C%26amp%3B%C3%A4%C3%A4%D0%B2%D1%81%D1%81%D1%82%D0%B2%3F%3D%2B%D1%83%D0%B9%D1%82%D0%B5";
|
$encoded = "a%C3%A4%D0%97%D0%B4%D1%80%D0%B0%3E%3C%26amp%3B%C3%A4%C3%A4%D0%B2%D1%81%D1%81%D1%82%D0%B2%3F%3D%2B%D1%83%D0%B9%D1%82%D0%B5";
|
||||||
$result = "aäЗдра><&ääвсств?=+уйте";
|
$result = "aäЗдра><&ääвсств?=+уйте";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $encoded . '"|unescape:"url"}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"url"}');
|
||||||
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,15 +23,15 @@ class PluginModifierUpperTest extends PHPUnit_Smarty
|
|||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.";
|
$result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}');
|
$tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.";
|
$result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}');
|
$tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
@@ -39,15 +39,15 @@ class PluginModifierUpperTest extends PHPUnit_Smarty
|
|||||||
public function testUmlauts()
|
public function testUmlauts()
|
||||||
{
|
{
|
||||||
$result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE.";
|
$result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}');
|
$tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}');
|
||||||
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUmlautsWithoutMbstring()
|
public function testUmlautsWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
|
||||||
$result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE.";
|
$result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE.";
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}');
|
$tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}');
|
||||||
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
@@ -22,125 +22,132 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function testDefault()
|
public function testDefault()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}');
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}');
|
||||||
$this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultWithoutMbstring()
|
public function testDefaultWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}');
|
||||||
$this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultUmlauts()
|
public function testDefaultUmlauts()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"äöüßñ woman ñsä new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
$tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsä new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals("äöüßñ woman ñsä new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
|
$this->assertEquals("äöüßñ woman ñsä new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLength()
|
public function testLength()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLengthWithoutMbstring()
|
public function testLengthWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBreak()
|
public function testBreak()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}');
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}');
|
||||||
$this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBreakWithoutMbstring()
|
public function testBreakWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}');
|
||||||
$this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLong()
|
public function testLong()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}');
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}');
|
||||||
$this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongWithoutMbstring()
|
public function testLongWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}');
|
||||||
$this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongUmlauts()
|
public function testLongUmlauts()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26}');
|
$tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26}');
|
||||||
$this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongCut()
|
public function testLongCut()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
|
||||||
$this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongCutWithoutMbstring()
|
public function testLongCutWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
|
||||||
$this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLongCutUmlauts()
|
public function testLongCutUmlauts()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
|
$tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
|
||||||
$this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñä\nöüßñäöüßñßñ gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("äöüßñ woman\nñsääöüßñameorsoäöüßñäöüßñä\nöüßñäöüßñßñ gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLinebreaks()
|
public function testLinebreaks()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLinebreaksWithoutMbstring()
|
public function testLinebreaksWithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl));
|
$this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLinebreaks2()
|
public function testLinebreaks2()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman
|
||||||
gets
|
gets
|
||||||
new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals($this->normalizeString("Blind woman
|
$this->assertEquals("Blind woman
|
||||||
gets
|
gets
|
||||||
new kidney from\ndad she hasn't seen in years."), $this->smarty->fetch($tpl));
|
new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLinebreaks2WithoutMbstring()
|
public function testLinebreaks2WithoutMbstring()
|
||||||
{
|
{
|
||||||
Smarty::$_MBSTRING = false;
|
Smarty::$_MBSTRING = false;
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"Blind woman
|
$this->smarty->setCompileId('mb');
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{"Blind woman
|
||||||
gets
|
gets
|
||||||
new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
|
||||||
$this->assertEquals($this->normalizeString("Blind woman
|
$this->assertEquals("Blind woman
|
||||||
gets
|
gets
|
||||||
new kidney from\ndad she hasn't seen in years."), $this->smarty->fetch($tpl));
|
new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl));
|
||||||
Smarty::$_MBSTRING = true;
|
Smarty::$_MBSTRING = true;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -149,7 +156,7 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
|
|||||||
// Some Unicode Spaces
|
// Some Unicode Spaces
|
||||||
$string = " hello spaced       words ";
|
$string = " hello spaced       words ";
|
||||||
$string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES");
|
$string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES");
|
||||||
$tpl = $this->smarty->createTemplate('eval:{"' . $string . '"|strip}');
|
$tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}');
|
||||||
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@@ -62,5 +62,90 @@ class CompileSectionTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9));
|
$this->smarty->assign('foo', array(0,1,2,3,4,5,6,7,8,9));
|
||||||
$this->assertEquals("011223344556677889910", $this->smarty->fetch('007_section.tpl'));
|
$this->assertEquals("011223344556677889910", $this->smarty->fetch('007_section.tpl'));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', array(1,2));
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{section name=bar loop=\$foo}{\$foo[bar]}{/section}C", "A12C", 'T1', $i++),
|
||||||
|
array("A{section name=bar loop=\$foo}\n{\$foo[bar]}{/section}C", "A12C", 'T2', $i++),
|
||||||
|
array("A{section name=bar loop=\$foo}{\$foo[bar]}\n{/section}C", "A1\n2\nC", 'T3', $i++),
|
||||||
|
array("A{section name=bar loop=\$foo}\n{\$foo[bar]}\n{/section}C", "A1\n2\nC", 'T4', $i++),
|
||||||
|
array("A\n{section name=bar loop=\$foo}{\$foo[bar]}{/section}C", "A\n12C", 'T5', $i++),
|
||||||
|
array("A{section name=bar loop=\$foo}{\$foo[bar]}{/section}\nC", "A12C", 'T6', $i++),
|
||||||
|
array("A{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}D{/section}C", "A12C", 'T7', $i++),
|
||||||
|
array("A{section name=bar loop=\$foo}{\$foo[bar]}\n{sectionelse}D{/section}C", "A1\n2\nC", 'T8', $i++),
|
||||||
|
array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A{\$smarty.section.bar.total}C", "12A2C", 'T9', $i++),
|
||||||
|
array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A\n{\$smarty.section.bar.total}C", "12A\n2C", 'T10', $i++),
|
||||||
|
array("{section loop=\$foo name='bar'}{\$foo[bar]}{/section}A{\$smarty.section.bar.total}\nC", "12A2\nC", 'T11', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestElseSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testElseSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_Else_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', array());
|
||||||
|
$this->smarty->assign('bar', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestElseSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}A{\$bar}B{/section}", "AbarB", 'T1', $i++),
|
||||||
|
array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}\nA{\$bar}B{/section}", "AbarB", 'T2', $i++),
|
||||||
|
array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}A{\$bar}\nB{/section}", "Abar\nB", 'T3', $i++),
|
||||||
|
array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}\nA{\$bar}\nB{/section}", "Abar\nB", 'T4', $i++),
|
||||||
|
array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}{\$bar}\nB{/section}", "bar\nB", 'T5', $i++),
|
||||||
|
array("{section name=bar loop=\$foo}{\$foo[bar]}{sectionelse}{\$bar}{/section}", "bar", 'T6', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
{section name=bar loop=$foo}{$foo[bar]}{/section}
|
|
@@ -1 +0,0 @@
|
|||||||
{section name=bar loop=$foo start=$i}{$foo[bar]}{sectionelse} else {/section}
|
|
@@ -1 +0,0 @@
|
|||||||
{section name=bar loop=$foo}{$foo[bar]}{sectionelse}else{/section}
|
|
@@ -1 +0,0 @@
|
|||||||
{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}
|
|
@@ -1 +0,0 @@
|
|||||||
{section name=bar loop=$foo}{$foo[bar]}{sectionelse} else {/section}total{$smarty.section.bar.total}
|
|
@@ -1 +0,0 @@
|
|||||||
{section name=bar loop=$foo}{$smarty.section.bar.index}{$smarty.section.bar.iteration}{sectionelse} else {/section}
|
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -26,11 +26,22 @@ class CompileSetfilterTest extends PHPUnit_Smarty
|
|||||||
$this->cleanDirs();
|
$this->cleanDirs();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* test nested setfilter
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
*/
|
*/
|
||||||
public function testNestedSetfilter()
|
public function testNestedSetfilter()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo}{setfilter htmlspecialchars} {$foo}{setfilter escape:"mail"} {$foo}{/setfilter} {$foo}{/setfilter} {$foo}');
|
$tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{setfilter escape:"mail"} {$foo}{/setfilter} {$foo}{/setfilter} {$foo}');
|
||||||
|
$tpl->assign('foo', '<a@b.c>');
|
||||||
|
$this->assertEquals("<a@b.c> <a@b.c> <a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
*/
|
||||||
|
public function testNestedSetfilter2()
|
||||||
|
{
|
||||||
|
$tpl = $this->smarty->createTemplate('string:{$foo}{setfilter htmlspecialchars} {$foo}{setfilter escape:"mail"} {$foo}{/setfilter} {$foo}{/setfilter} {$foo}');
|
||||||
$tpl->assign('foo', '<a@b.c>');
|
$tpl->assign('foo', '<a@b.c>');
|
||||||
$this->assertEquals("<a@b.c> <a@b.c> <a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl));
|
$this->assertEquals("<a@b.c> <a@b.c> <a [AT] b [DOT] c> <a@b.c> <a@b.c>", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
@@ -54,8 +54,8 @@ class CompileStripTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
return array(array(" foo\n bar buh\n\n", 'foobar buh', '', $i ++),
|
return array(array(" foo\n bar buh\n\n", 'foobar buh', '', $i ++),
|
||||||
array("\n <div style=\"float: right; cursor: url;\">[<a\n onmouseover=\"this.style.cursor='pointer'\"\n onmouseup=\"document.getElementById('screenEdit_(\$screen.id)').style.display='none'\";>X</a>]</div>\n\n\n foo\n bar\n",
|
array("\n <div style=\"float: right; cursor: url;\">[<a\n onmouseover=\"this.style.cursor='pointer'\"\n onmouseup=\"document.getElementById('screenEdit_(\$screen.id)').style.display='none'\">X</a>]</div>\n\n\n foo\n bar\n",
|
||||||
'<div style="float: right; cursor: url;">[<a onmouseover="this.style.cursor=\'pointer\'" onmouseup="document.getElementById(\'screenEdit_($screen.id)\').style.display=\'none\'";>X</a>]</div>foobar',
|
'<div style="float: right; cursor: url;">[<a onmouseover="this.style.cursor=\'pointer\'" onmouseup="document.getElementById(\'screenEdit_($screen.id)\').style.display=\'none\'">X</a>]</div>foobar',
|
||||||
'', $i ++),
|
'', $i ++),
|
||||||
array("\n <ul>\n <li>\n <a href=\"#\">BlaBla</a>\n </li>\n <li>\n <a href=\"#\">BlaBla</a>\n </li>\n </ul>\n",
|
array("\n <ul>\n <li>\n <a href=\"#\">BlaBla</a>\n </li>\n <li>\n <a href=\"#\">BlaBla</a>\n </li>\n </ul>\n",
|
||||||
'<ul><li><a href="#">BlaBla</a></li><li><a href="#">BlaBla</a></li></ul>', '', $i ++),
|
'<ul><li><a href="#">BlaBla</a></li><li><a href="#">BlaBla</a></li></ul>', '', $i ++),
|
||||||
|
@@ -348,4 +348,90 @@ class CompileFunctionTest extends PHPUnit_Smarty
|
|||||||
array(true, 'cached call'),
|
array(true, 'cached call'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->addTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar');
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacingNocache($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('VarNocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->addTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'bar',true);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testVarNocache - {$file}");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test Output nocache spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacingNocache2($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->smarty->setCompileId('VarNocache');
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->addTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 'foo',true);
|
||||||
|
$this->assertEquals(str_replace('bar','foo',$result),
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
"testVarNocache1 - {$file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("{include 'simple_function_lib.tpl'}A{call name='simple' bar=\$foo}C", "AbarC", 'T1', $i++),
|
||||||
|
array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}C", "A\nbarC", 'T2', $i++),
|
||||||
|
array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}\nC", "A\nbar\nC", 'T3', $i++),
|
||||||
|
array("{include 'simple_function_lib.tpl'}A\n{call name='simple' bar=\$foo}\nC", "A\nbar\nC", 'T4', $i++),
|
||||||
|
array("{include 'simple_function_lib.tpl'}A\n\n{call name='simple' bar=\$foo}\n\nC", "A\n\nbar\n\nC", 'T5', $i++),
|
||||||
|
array("{function name=simple}{\$bar}{/function}{call name='simple' bar=\$foo}", "bar", 'T6', $i++),
|
||||||
|
array("{function name=simple}A{\$bar}C{/function}{call name='simple' bar=\$foo}", "AbarC", 'T7', $i++),
|
||||||
|
array("{function name=simple}A\n{\$bar}C{/function}{call name='simple' bar=\$foo}", "A\nbarC", 'T8', $i++),
|
||||||
|
array("{function name=simple}A{\$bar}\nC{/function}{call name='simple' bar=\$foo}", "Abar\nC", 'T9', $i++),
|
||||||
|
array("{function name=simple}A\n{\$bar}\nC{/function}{call name='simple' bar=\$foo}", "A\nbar\nC", 'T10', $i++),
|
||||||
|
array("{function name=simple}{\$foo}{/function}{call name='simple'}", "bar", 'T11', $i++),
|
||||||
|
array("{function name=simple}A{\$foo}C{/function}{call name='simple'}", "AbarC", 'T12', $i++),
|
||||||
|
array("{function name=simple}A\n{\$foo}C{/function}{call name='simple'}", "A\nbarC", 'T13', $i++),
|
||||||
|
array("{function name=simple}A{\$foo}\nC{/function}{call name='simple'}", "Abar\nC", 'T14', $i++),
|
||||||
|
array("{function name=simple}A\n{\$foo}\nC{/function}{call name='simple'}", "A\nbar\nC", 'T15', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
{function name=simple}{$bar}{/function}
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -39,7 +39,116 @@ class CompileWhileTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testWhileStatement()
|
public function testWhileStatement()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('string:{$y=5}{while $y=$y-1}{$y}{/while}');
|
$tpl = $this->smarty->createTemplate('string:{$x=5}{while $x=$x-1}{$x}{/while}');
|
||||||
$this->assertEquals("4321", $this->smarty->fetch($tpl));
|
$this->assertEquals("4321", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test spacings
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestSpacing
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testSpacing($code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Spacing_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 3);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testSpacing
|
||||||
|
*/
|
||||||
|
public function dataTestSpacing()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
* test number
|
||||||
|
*/
|
||||||
|
return array(array("A{while \$foo=\$foo-1}{\$foo}{/while}C", "A21C", 'T1', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}\n{\$foo}{/while}C", "A21C", 'T2', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}\n{/while}C", "A2\n1\nC", 'T3', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}\n{\$foo}\n{/while}C", "A2\n1\nC", 'T4', $i++),
|
||||||
|
array("A\n{while \$foo=\$foo-1}{\$foo}{/while}C", "A\n21C", 'T5', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}{/while}\nC", "A21\nC", 'T6', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}{break}{/while}C", "A2C", 'T7', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}\n{break}{/while}C", "A2\nC", 'T8', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}{break}\n{/while}C", "A2C", 'T9', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{if \$foo === 2}{continue}{/if}{\$foo}{/while}C", "A1C", 'T10', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{if \$foo === 2}{continue}\n{/if}{\$foo}{/while}C", "A1C", 'T11', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{if \$foo === 2}\n{continue}\n{/if}{\$foo}{/while}C", "A1C", 'T12', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}\n{continue}{\$foo}{/while}C", "AC", 'T13', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{continue}\n{\$foo}{/while}C", "AC", 'T14', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{break}\n{\$foo}{/while}C", "AC", 'T15', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}{continue}{/while}C", "A21C", 'T16', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}{continue}\n{/while}C", "A21C", 'T17', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo}\n{continue}\n{/while}C", "A2\n1\nC", 'T18', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1}{\$foo} {continue} {/while}C", "A2 1 C", 'T19', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1} {continue}{\$foo}{/while}C", "A C", 'T20', $i++),
|
||||||
|
array("A{while \$foo=\$foo-1} {/while}C", "A C", 'T21', $i++),
|
||||||
|
array("A{while !isset(\$x)}{\$foo}{\$x=1}{/while}C", "A3C", 'T22', $i++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test nocache
|
||||||
|
*
|
||||||
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestNocache
|
||||||
|
*/
|
||||||
|
public function testNocache($value, $nocache, $code, $result, $testName, $testNumber)
|
||||||
|
{
|
||||||
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
|
$file = "Nocache_{$name}.tpl";
|
||||||
|
if ($code) {
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
}
|
||||||
|
$this->smarty->setCaching(1);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', $value, $nocache);
|
||||||
|
$this->assertEquals($result, $this->smarty->fetch($file),
|
||||||
|
"{$file} - {$testNumber}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data provider für testNocache
|
||||||
|
*/
|
||||||
|
public function dataTestNocache()
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
/*
|
||||||
|
* var
|
||||||
|
* value
|
||||||
|
* Code
|
||||||
|
* result
|
||||||
|
* test name
|
||||||
|
*/
|
||||||
|
return array(array(3,false, "{while \$foo=\$foo-1}\n{\$foo}{/while}", '21', 'T1', $i ++),
|
||||||
|
array(0,false, false, '21', 'T1', $i ++),
|
||||||
|
array(3,false, "{while \$foo=\$foo-1 nocache}\n{\$foo}{/while}", '21', 'T2', $i ++),
|
||||||
|
array(4,false, false, '321', 'T2', $i ++),
|
||||||
|
array(4,true, "{while \$foo=\$foo-1}\n{\$foo}{/while}", '321', 'T3', $i ++),
|
||||||
|
array(5,true, false, '4321', 'T3', $i ++),
|
||||||
|
array(array(1,2,3),false, "{\$x=1}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T4', $i ++),
|
||||||
|
array(array(3,4,5),false, false, '2132', 'T4', $i ++),
|
||||||
|
array(array(1,2,3),false, "{\$x=1 nocache}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T5', $i ++),
|
||||||
|
array(array(3,4,5),false, false, '4152', 'T5', $i ++),
|
||||||
|
array(array(1,2,3),true, "{\$x=1 nocache}{while isset(\$foo[\$x])}\n{\$foo[\$x]}{\$x++}{/while}", '2132', 'T6', $i ++),
|
||||||
|
array(array(3,4,5),true, false, '4152', 'T6', $i ++),
|
||||||
|
array(array(1,2,3,4,5),true, "{\$x=0 nocache}{while \$foo[\$x] <= 3}\n{\$foo[\$x]}{\$x++}{/while}", '102132', 'T7', $i ++),
|
||||||
|
array(array(2,3,4,5),true, false, '2031', 'T7', $i ++),
|
||||||
|
array(array(1,2,false,4,5),true, "{\$x=0 nocache}{while \$foo[\$x]}\n{\$foo[\$x]}{\$x++}{/while}", '1021', 'T8', $i ++),
|
||||||
|
array(array(2,false,4,5),true, false, '20', 'T8', $i ++),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -24,112 +24,52 @@ class ArrayTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->cleanDirs();
|
$this->cleanDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test simple array definition
|
* Test array access
|
||||||
|
*
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
* @dataProvider dataTestArray
|
||||||
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
public function testSimpleArrayDefinition()
|
public function testArray($code, $result, $testName, $testNumber)
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,3,4,5]}{foreach $foo as $bar}{$bar}{/foreach}');
|
$name = empty($testName) ? $testNumber : $testName;
|
||||||
$this->assertEquals('12345', $this->smarty->fetch($tpl));
|
$file = "Array_{$name}.tpl";
|
||||||
|
$this->makeTemplateFile($file, $code);
|
||||||
|
$this->smarty->setTemplateDir('./templates_tmp');
|
||||||
|
$this->smarty->assign('foo', 3);
|
||||||
|
$this->assertEquals($result,
|
||||||
|
$this->smarty->fetch($file),
|
||||||
|
$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* test smarty2 array access
|
* Data provider für testArray
|
||||||
*/
|
*/
|
||||||
public function testSmarty2ArrayAccess()
|
public function dataTestArray()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,3,4,5]}{$foo.0}{$foo.1}{$foo.2}');
|
$i = 1;
|
||||||
$this->assertEquals('123', $this->smarty->fetch($tpl));
|
/*
|
||||||
}
|
* Code
|
||||||
|
* result
|
||||||
/**
|
* test name
|
||||||
* test smarty3 array access
|
* test number
|
||||||
*/
|
*/
|
||||||
public function testSmarty3ArrayAccess()
|
return array(array('{$foo=[1,2,3,4,5]}{foreach $foo as $bar}{$bar}{/foreach}', '12345', 'T1', $i++),
|
||||||
{
|
array('{$foo=[1,2,3,4,5]}{$foo.0}{$foo.1}{$foo.2}', '123', 'T2', $i++),
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,3,4,5]}{$foo[0]}{$foo[1]}{$foo[2]}');
|
array('{$foo=[1,2,3,4,5]}{$foo[0]}{$foo[1]}{$foo[2]}', '123', 'T3', $i++),
|
||||||
$this->assertEquals('123', $this->smarty->fetch($tpl));
|
array('{$x=\'d\'}{$foo=[a=>1,\'b\'=>2,"c"=>3,$x=>4]}{$foo[\'a\']}{$foo[\'b\']}{$foo[\'c\']}{$foo[\'d\']}', '1234', 'T4', $i++),
|
||||||
}
|
array('{$foo=[1,2,[a,b,c],4,5]}{$foo[2][1]}', 'b', 'T5', $i++),
|
||||||
|
array('{$foo=[1,2,[7,8,9],4,5]}{$foo[2][1]+1}', '9', 'T6', $i++),
|
||||||
/**
|
array('{$foo=[1,2,[7,8,9],4,5]}{$foo.2.1+1}', '9', 'T7', $i++),
|
||||||
* test indexed array definition
|
array('{$foo=[1,2,[7,8,9],4,5]}{2+$foo[2][1]}', '10', 'T8', $i++),
|
||||||
*/
|
array('{$foo=[1,2,[7,8,9],4,5]}{2+$foo.2.1}', '10', 'T9', $i++),
|
||||||
public function testIndexedArrayDefinition()
|
array('{$foo=[1,2,[7,8,9],4,5]}{$foo[2][0]+$foo[2][1]}', '15', 'T10', $i++),
|
||||||
{
|
array('{$foo=[1,2,[7,8,9],4,5]}{$foo.2.0+$foo.2.1}', '15', 'T11', $i++),
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$x=\'d\'}{$foo=[a=>1,\'b\'=>2,"c"=>3,$x=>4]}{$foo[\'a\']}{$foo[\'b\']}{$foo[\'c\']}{$foo[\'d\']}');
|
array('{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$y=0}{$foo.$x.$y}', '7', 'T12', $i++),
|
||||||
$this->assertEquals('1234', $this->smarty->fetch($tpl));
|
array('{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$foo.$x.0}', '7', 'T13', $i++),
|
||||||
}
|
array('{$foo=[1,2,[7,8,9],4,5]}{$x=0}{$foo.2.$x}', '7', 'T14', $i++),
|
||||||
|
array('{$foo=[1,2,[7,8,9],4,5]}{$x=[1,0]}{$foo.2.{$x.1}}', '7', 'T15', $i++),
|
||||||
/**
|
);
|
||||||
* test nested array
|
|
||||||
*/
|
|
||||||
public function testNestedArray()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[a,b,c],4,5]}{$foo[2][1]}');
|
|
||||||
$this->assertEquals('b', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test array math
|
|
||||||
*/
|
|
||||||
public function testArrayMath1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$foo[2][1]+1}');
|
|
||||||
$this->assertEquals('9', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayMath2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$foo.2.1+1}');
|
|
||||||
$this->assertEquals('9', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayMath3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{2+$foo[2][1]}');
|
|
||||||
$this->assertEquals('10', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayMath4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{2+$foo.2.1}');
|
|
||||||
$this->assertEquals('10', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayMath5()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$foo[2][0]+$foo[2][1]}');
|
|
||||||
$this->assertEquals('15', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayMath6()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$foo.2.0+$foo.2.1}');
|
|
||||||
$this->assertEquals('15', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayVariableIndex1()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$y=0}{$foo.$x.$y}');
|
|
||||||
$this->assertEquals('7', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayVariableIndex2()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$x=2}{$foo.$x.0}');
|
|
||||||
$this->assertEquals('7', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayVariableIndex3()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$x=0}{$foo.2.$x}');
|
|
||||||
$this->assertEquals('7', $this->smarty->fetch($tpl));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testArrayVariableIndex4()
|
|
||||||
{
|
|
||||||
$tpl = $this->smarty->createTemplate('eval:{$foo=[1,2,[7,8,9],4,5]}{$x=[1,0]}{$foo.2.{$x.1}}');
|
|
||||||
$this->assertEquals('7', $this->smarty->fetch($tpl));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
dummy
|
@@ -41,7 +41,7 @@ class DoubleQuotedStringTest extends PHPUnit_Smarty
|
|||||||
$this->makeTemplateFile($file, $code);
|
$this->makeTemplateFile($file, $code);
|
||||||
$this->smarty->assignGlobal('file', $file);
|
$this->smarty->assignGlobal('file', $file);
|
||||||
$this->smarty->assign('bar', 'buh');
|
$this->smarty->assign('bar', 'buh');
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)),
|
$this->assertEquals($result, $this->smarty->fetch($file),
|
||||||
"testDoubleQuoted - {$code} - {$name}");
|
"testDoubleQuoted - {$code} - {$name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ class ModifierTest extends PHPUnit_Smarty
|
|||||||
$this->makeTemplateFile($file, $code);
|
$this->makeTemplateFile($file, $code);
|
||||||
$this->smarty->assignGlobal('file', $file);
|
$this->smarty->assignGlobal('file', $file);
|
||||||
$this->smarty->assign('bar', 'buh');
|
$this->smarty->assign('bar', 'buh');
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)),
|
$this->assertEquals($result, $this->smarty->fetch($file),
|
||||||
"testModifier - {$code} - {$name}");
|
"testModifier - {$code} - {$name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
$data = $this->smarty->createData($data1);
|
$data = $this->smarty->createData($data1);
|
||||||
$data1->assign('foo', 'data1');
|
$data1->assign('foo', 'data1');
|
||||||
$data->assign('foo', 'data');
|
$data->assign('foo', 'data');
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('scope_tag.tpl', $data)),
|
$this->assertEquals($result, $this->smarty->fetch('scope_tag.tpl', $data),
|
||||||
"test - {$code} - {$testName}");
|
"test - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,14 +63,16 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
return array(array('{$foo[] = \'newvar\' scope=tpl_root}', true,
|
return array(array('{$foo[] = \'newvar\' scope=tpl_root}', true,
|
||||||
'#testAppendScope_0.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'#testAppendScope_0.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,), array('{append var=foo value=\'newvar\' scope=tpl_root}', true,
|
'', $i ++,),
|
||||||
'#testAppendScope_1.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
array('{append var=foo value=\'newvar\' scope=tpl_root}', true,
|
||||||
'', $i ++,), array('{append var=foo value=\'newvar\' scope=global}', true,
|
'#testAppendScope_1.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'#testAppendScope_2.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=\'smarty\'#global:$foo=array(0=>\'data\',1=>\'newvar\',)',
|
'', $i ++,),
|
||||||
|
array('{append var=foo value=\'newvar\' scope=global}', true,
|
||||||
|
'#testAppendScope_2.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =\'smarty\'#global:$foo =array(0=>\'data\',1=>\'newvar\',)',
|
||||||
'', $i ++,),
|
'', $i ++,),
|
||||||
array('{append var=foo value=\'newvar\' scope=smarty}', true,
|
array('{append var=foo value=\'newvar\' scope=smarty}', true,
|
||||||
'#testAppendScope_3.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo=array(0=>\'data\',1=>\'newvar\',)#data:$foo=\'data\'#data:$foo=\'data1\'#Smarty:$foo=array(0=>\'data\',1=>\'newvar\',)#global:$foo=\'global\'',
|
'#testAppendScope_3.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_include.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#scope_tag.tpl:$foo =array(0=>\'data\',1=>\'newvar\',)#data:$foo =\'data\'#data:$foo =\'data1\'#Smarty:$foo =array(0=>\'data\',1=>\'newvar\',)#global:$foo =\'global\'',
|
||||||
'', $i ++,),);
|
'', $i ++,),);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +92,8 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assignGlobal('foo', 'global');
|
$this->smarty->assignGlobal('foo', 'global');
|
||||||
$data = $this->smarty->createData($useSmarty ? $this->smarty : null);
|
$data = $this->smarty->createData($useSmarty ? $this->smarty : null);
|
||||||
$data->assign('foo', 'data');
|
$data->assign('foo', 'data');
|
||||||
$this->assertEquals($this->strip('#' . $file . $result),
|
$this->assertEquals('#' . $file . $result,
|
||||||
$this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}");
|
$this->smarty->fetch('scope_tag.tpl', $data), "test - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -107,30 +109,30 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
return array(array('{$foo = \'newvar\'}', true,
|
return array(array('{$foo = \'newvar\'}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,), array('{assign var=foo value=\'newvar\'}', true,
|
'', $i ++,), array('{assign var=foo value=\'newvar\'}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,), array('{$foo = \'newvar\' scope=local}', true,
|
'', $i ++,), array('{$foo = \'newvar\' scope=local}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,),
|
'', $i ++,),
|
||||||
array('{assign var=foo value=\'newvar\' scope=local}', true,
|
array('{assign var=foo value=\'newvar\' scope=local}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,), array('{$foo = \'newvar\' scope=parent}', true,
|
'', $i ++,), array('{$foo = \'newvar\' scope=parent}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,), array('{assign var=foo value=\'newvar\' scope=parent}', true,
|
'', $i ++,), array('{assign var=foo value=\'newvar\' scope=parent}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,),
|
'', $i ++,),
|
||||||
array('{$foo = \'newvar\' scope=tpl_root}', true,
|
array('{$foo = \'newvar\' scope=tpl_root}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,), array('{$foo = \'newvar\' scope=global}', true,
|
'', $i ++,), array('{$foo = \'newvar\' scope=global}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'',
|
||||||
'', $i ++,), array('{$foo = \'newvar\' scope=root}', true,
|
'', $i ++,), array('{$foo = \'newvar\' scope=root}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++,),
|
'', $i ++,),
|
||||||
array('{$foo = \'newvar\' scope=root}', false,
|
array('{$foo = \'newvar\' scope=root}', false,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'no smarty', $i ++,), array('{$foo = \'newvar\' scope=smarty}', false,
|
'no smarty', $i ++,), array('{$foo = \'newvar\' scope=smarty}', false,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'#global:$foo =\'global\'',
|
||||||
'no smarty', $i ++,),);
|
'no smarty', $i ++,),);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +150,7 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('buh', $var);
|
$this->smarty->assign('buh', $var);
|
||||||
$this->smarty->assign('foo', 'smarty');
|
$this->smarty->assign('foo', 'smarty');
|
||||||
$this->smarty->assignGlobal('foo', 'global');
|
$this->smarty->assignGlobal('foo', 'global');
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch($file)), "test - {$file} {$var}");
|
$this->assertEquals($result, $this->smarty->fetch($file), "test - {$file} {$var}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -161,13 +163,13 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
* result
|
* result
|
||||||
*/
|
*/
|
||||||
return array(array('b1', 'test_scope_assignbar.tpl',
|
return array(array('b1', 'test_scope_assignbar.tpl',
|
||||||
'#test_scope_assignbar.tpl:$foo=\'b1\'#Smarty:$foo=\'smarty\'#global:$foo=\'b1\'',),
|
'#test_scope_assignbar.tpl:$foo =\'b1\'#Smarty:$foo =\'smarty\'#global:$foo =\'b1\'',),
|
||||||
array('b2', 'test_scope_assignbar.tpl',
|
array('b2', 'test_scope_assignbar.tpl',
|
||||||
'#test_scope_assignbar.tpl:$foo=\'b2\'#Smarty:$foo=\'smarty\'#global:$foo=\'b2\'',),
|
'#test_scope_assignbar.tpl:$foo =\'b2\'#Smarty:$foo =\'smarty\'#global:$foo =\'b2\'',),
|
||||||
array('b1', 'test_scope_assignnocache.tpl',
|
array('b1', 'test_scope_assignnocache.tpl',
|
||||||
'#test_scope_assignnocache.tpl:$foo=\'b1\'#Smarty:$foo=\'smarty\'#global:$foo=\'b1\'',),
|
'#test_scope_assignnocache.tpl:$foo =\'b1\'#Smarty:$foo =\'smarty\'#global:$foo =\'b1\'',),
|
||||||
array('b2', 'test_scope_assignnocache.tpl',
|
array('b2', 'test_scope_assignnocache.tpl',
|
||||||
'#test_scope_assignnocache.tpl:$foo=\'b2\'#Smarty:$foo=\'smarty\'#global:$foo=\'b2\'',),);
|
'#test_scope_assignnocache.tpl:$foo =\'b2\'#Smarty:$foo =\'smarty\'#global:$foo =\'b2\'',),);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,7 +191,7 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
if (!$useSmarty) {
|
if (!$useSmarty) {
|
||||||
$testName .= 'no smarty';
|
$testName .= 'no smarty';
|
||||||
}
|
}
|
||||||
$this->assertEquals($this->strip($result), $this->strip($this->smarty->fetch('test_scope.tpl', $data)),
|
$this->assertEquals($result, $this->smarty->fetch('test_scope.tpl', $data),
|
||||||
"test - {$code} - {$testName}");
|
"test - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,36 +208,36 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
array('{include \'test_scope_assign.tpl\'}', true,
|
array('{include \'test_scope_assign.tpl\'}', true,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'data\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=parent}', true,
|
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=parent}', true,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++),
|
'', $i ++),
|
||||||
array('{include \'test_scope_assign.tpl\' scope=tpl_root}', true,
|
array('{include \'test_scope_assign.tpl\' scope=tpl_root}', true,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', true,
|
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', true,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', false,
|
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=root}', false,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' .
|
||||||
$i .
|
$i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++),
|
'', $i ++),
|
||||||
array('{include \'test_scope_assign.tpl\' scope=smarty}', true,
|
array('{include \'test_scope_assign.tpl\' scope=smarty}', true,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'#global:$foo =\'global\'',
|
||||||
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=global}', true,
|
'', $i ++), array('{include \'test_scope_assign.tpl\' scope=global}', true,
|
||||||
'#test_scope_assign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'',
|
||||||
'', $i ++),
|
'', $i ++),
|
||||||
array('{include \'test_scope_pluginassign.tpl\' scope=global}', true,
|
array('{include \'test_scope_pluginassign.tpl\' scope=global}', true,
|
||||||
'#test_scope_pluginassign.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_pluginassign.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'newvar\'#test_scope.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'newvar\'',
|
'.tpl:$foo =\'newvar\'#test_scope.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'newvar\'',
|
||||||
'', $i ++), array('{include \'test_scope_assign_noscope.tpl\' scope=root}', true,
|
'', $i ++), array('{include \'test_scope_assign_noscope.tpl\' scope=root}', true,
|
||||||
'#test_scope_assign_noscope.tpl:$foo=\'newvar\'#testIncludeScope_' . $i .
|
'#test_scope_assign_noscope.tpl:$foo =\'newvar\'#testIncludeScope_' . $i .
|
||||||
'.tpl:$foo=\'data\'#test_scope.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'#global:$foo=\'global\'',
|
'.tpl:$foo =\'data\'#test_scope.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'#global:$foo =\'global\'',
|
||||||
'', $i ++),);
|
'', $i ++),);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,8 +256,8 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->configLoad('smarty.conf');
|
$this->smarty->configLoad('smarty.conf');
|
||||||
$data = $this->smarty->createData($useSmarty ? $this->smarty : null);
|
$data = $this->smarty->createData($useSmarty ? $this->smarty : null);
|
||||||
$data->configLoad('data.conf');
|
$data->configLoad('data.conf');
|
||||||
$this->assertEquals($this->strip('#' . $file . $result),
|
$this->assertEquals('#' . $file . $result,
|
||||||
$this->strip($this->smarty->fetch('scope_tag.tpl', $data)), "test - {$code} - {$testName}");
|
$this->smarty->fetch('scope_tag.tpl', $data), "test - {$code} - {$testName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -271,21 +273,21 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
* test name
|
* test name
|
||||||
*/
|
*/
|
||||||
return array(array('{config_load \'template.conf\'}', true,
|
return array(array('{config_load \'template.conf\'}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'',
|
||||||
'', $i ++,), array('{config_load \'template.conf\' scope=local}', true,
|
'', $i ++,), array('{config_load \'template.conf\' scope=local}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'data\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'data\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'',
|
||||||
'', $i ++,), array('{config_load \'template.conf\' scope=parent}', true,
|
'', $i ++,), array('{config_load \'template.conf\' scope=parent}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'data\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'data\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'',
|
||||||
'', $i ++,),
|
'', $i ++,),
|
||||||
array('{config_load \'template.conf\' scope=tpl_root}', true,
|
array('{config_load \'template.conf\' scope=tpl_root}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'smarty\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'smarty\'',
|
||||||
'', $i ++,), array('{config_load \'template.conf\' scope=root}', true,
|
'', $i ++,), array('{config_load \'template.conf\' scope=root}', true,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'',
|
||||||
'', $i ++,), array('{config_load \'template.conf\' scope=root}', false,
|
'', $i ++,), array('{config_load \'template.conf\' scope=root}', false,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'newvar\'#Smarty:$foo=\'smarty\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'newvar\'#Smarty:$foo =\'smarty\'',
|
||||||
'no smarty', $i ++,),
|
'no smarty', $i ++,),
|
||||||
array('{config_load \'template.conf\' scope=smarty}', false,
|
array('{config_load \'template.conf\' scope=smarty}', false,
|
||||||
':$foo=\'newvar\'#scope_include.tpl:$foo=\'newvar\'#scope_tag.tpl:$foo=\'newvar\'#data:$foo=\'data\'#Smarty:$foo=\'newvar\'',
|
':$foo =\'newvar\'#scope_include.tpl:$foo =\'newvar\'#scope_tag.tpl:$foo =\'newvar\'#data:$foo =\'data\'#Smarty:$foo =\'newvar\'',
|
||||||
'no smarty', $i ++,),);
|
'no smarty', $i ++,),);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin params
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PHPunitPlugin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty {getparams}
|
||||||
|
*
|
||||||
|
* @param array $params parameter array
|
||||||
|
* @param object $template template object
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
class smarty_compiler_getparamsshort extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Smarty_Internal_CompileBase
|
||||||
|
*/
|
||||||
|
public $required_attributes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Smarty_Internal_CompileBase
|
||||||
|
*/
|
||||||
|
public $optional_attributes = array('_any');
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Smarty_Internal_CompileBase
|
||||||
|
*/
|
||||||
|
public $shorttag_order = array('s1', 's2', 's3');
|
||||||
|
|
||||||
|
public function compile($args, $compiler)
|
||||||
|
{
|
||||||
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
$output = '<?php echo "array(';
|
||||||
|
foreach ($_attr as $key => $value) {
|
||||||
|
$output .= "'{$key}'=>\" . ";
|
||||||
|
$output .= is_string($value) ? "({$value})" : ("'" . var_export($value, true). "'");
|
||||||
|
$output .= ' . ",';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= ")\";?>\n";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user