mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
modified tests for custom delimiters
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
/**
|
/**
|
||||||
* class for delimiter tests
|
* class for delimiter tests
|
||||||
*
|
*
|
||||||
* @runTestsInSeparateProcess
|
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
* @backupStaticAttributes enabled
|
* @backupStaticAttributes enabled
|
||||||
*/
|
*/
|
||||||
@@ -40,8 +39,40 @@ class AutoliteralTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->setAutoLiteral(false);
|
$this->smarty->setAutoLiteral(false);
|
||||||
$this->smarty->setCompileId(1);
|
$this->smarty->setCompileId(1);
|
||||||
$this->smarty->assign('i','foo');
|
$this->smarty->assign('i','bar');
|
||||||
$this->assertEquals('foofoo', $this->smarty->fetch('autoliteral.tpl'));
|
$this->assertEquals('barbar', $this->smarty->fetch('autoliteral.tpl'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* test '{ ' delimiter in double quotes auto_literal true
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testSetAutoliteralDoublequote()
|
||||||
|
{
|
||||||
|
$this->smarty->setAutoLiteral(true);
|
||||||
|
$this->assertEquals(' output: double { counter} 1 quote', $this->smarty->fetch('autoliteraldoublequote.tpl'));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* test '{ ' delimiter in double quotes auto_literal false
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testSetAutoliteralDoublequote2()
|
||||||
|
{
|
||||||
|
$this->smarty->setAutoLiteral(false);
|
||||||
|
$this->smarty->setCompileId(1);
|
||||||
|
$this->assertEquals(' output: double 1 2 quote', $this->smarty->fetch('autoliteraldoublequote.tpl'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test '{{ ' delimiter in double quotes auto_literal true
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function testSetAutoliteralDoublequote3()
|
||||||
|
{
|
||||||
|
$this->smarty->setAutoLiteral(true);
|
||||||
|
$this->assertEquals(' output: double {{ counter} {{ counter}} quote', $this->smarty->fetch('autoliteraldoublequote2.tpl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetAutoliteralBlock()
|
public function testSetAutoliteralBlock()
|
||||||
|
@@ -32,8 +32,8 @@ class DelimiterTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->left_delimiter = '<{';
|
$this->smarty->left_delimiter = '<{';
|
||||||
$this->smarty->right_delimiter = '}>';
|
$this->smarty->right_delimiter = '}>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:<{* comment *}><{if true}><{"hello world"}><{/if}>');
|
$tpl = $this->smarty->createTemplate('eval:start <{* comment *}>hello <{if true}><{"world"}><{/if}> end');
|
||||||
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
$this->assertEquals("start hello world end", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* test <{ }> delimiter
|
* test <{ }> delimiter
|
||||||
@@ -42,8 +42,8 @@ class DelimiterTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->left_delimiter = '<';
|
$this->smarty->left_delimiter = '<';
|
||||||
$this->smarty->right_delimiter = '>';
|
$this->smarty->right_delimiter = '>';
|
||||||
$tpl = $this->smarty->createTemplate('eval:<* comment *><if 1 < 2><"hello world"></if>');
|
$tpl = $this->smarty->createTemplate('eval:start <* comment *>hello <if 1 < 2><"world"></if> end');
|
||||||
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
$this->assertEquals("start hello world end", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,8 +53,8 @@ class DelimiterTest extends PHPUnit_Smarty
|
|||||||
{
|
{
|
||||||
$this->smarty->left_delimiter = '<-{';
|
$this->smarty->left_delimiter = '<-{';
|
||||||
$this->smarty->right_delimiter = '}->';
|
$this->smarty->right_delimiter = '}->';
|
||||||
$tpl = $this->smarty->createTemplate('eval:<-{* comment *}-><-{if true}-><-{"hello world"}-><-{/if}->');
|
$tpl = $this->smarty->createTemplate('eval:<-<-{* comment *}-><-{if true}-><-{"hello world"}-><-{/if}->->');
|
||||||
$this->assertEquals("hello world", $this->smarty->fetch($tpl));
|
$this->assertEquals("<-hello world->", $this->smarty->fetch($tpl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -63,4 +63,10 @@ class UserliteralTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->setLiterals(array('<--','-->'));
|
$this->smarty->setLiterals(array('<--','-->'));
|
||||||
$this->assertEquals('<- 1 -> <--1-->', $this->smarty->fetch('userliteral2.tpl'));
|
$this->assertEquals('<- 1 -> <--1-->', $this->smarty->fetch('userliteral2.tpl'));
|
||||||
}
|
}
|
||||||
|
public function testUserLiteral5()
|
||||||
|
{
|
||||||
|
$this->smarty->setAutoLiteral(true);
|
||||||
|
$this->smarty->setLiterals(array('{%'));
|
||||||
|
$this->assertEquals(' output: double {%counter} quote', $this->smarty->fetch('userliteraldoublequote.tpl'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
{$foo="double { counter} {counter} quote"} output: {$foo}
|
@@ -0,0 +1 @@
|
|||||||
|
{$foo="double {{ counter} {{ counter}} quote"} output: {$foo}
|
@@ -0,0 +1 @@
|
|||||||
|
{$foo="double {%counter} quote"} output: {$foo}
|
Reference in New Issue
Block a user