modified tests for custom delimiters

This commit is contained in:
Uwe Tews
2017-10-21 12:35:08 +02:00
parent 507b96a571
commit 51c813556c
6 changed files with 49 additions and 9 deletions

View File

@@ -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()

View File

@@ -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));
} }
/** /**

View File

@@ -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'));
}
} }

View File

@@ -0,0 +1 @@
{$foo="double { counter} {counter} quote"} output: {$foo}

View File

@@ -0,0 +1 @@
{$foo="double {{ counter} {{ counter}} quote"} output: {$foo}

View File

@@ -0,0 +1 @@
{$foo="double {%counter} quote"} output: {$foo}