mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-29 19:31:36 +01:00
* Removed unneeded files and replace dummy.txt with .gitignore files * Synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config * fix php7.4 deprecation and remove php7.4 from travis allow_failures since php7.4 is current stable Co-authored-by: Uwe Tews <uwe.tews@googlemail.com> Co-authored-by: Uwe Tews <uwe.tews@gmail.com> Co-authored-by: AnrDaemon <anrdaemon@yandex.ru>
91 lines
2.5 KiB
PHP
91 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* Smarty PHPunit tests of delimiter
|
|
*
|
|
* @package PHPunit
|
|
* @author Uwe Tews
|
|
*/
|
|
|
|
/**
|
|
* class for delimiter tests
|
|
*
|
|
* @preserveGlobalState disabled
|
|
* @backupStaticAttributes enabled
|
|
*/
|
|
class AutoliteralTest extends PHPUnit_Smarty
|
|
{
|
|
public function setUp()
|
|
{
|
|
$this->setUpSmarty(dirname(__FILE__));
|
|
$this->smarty->addPluginsDir("../../__shared/PHPunitplugins/");
|
|
}
|
|
|
|
public function testInit()
|
|
{
|
|
$this->cleanDirs();
|
|
}
|
|
|
|
/**
|
|
* test '{ ' delimiter
|
|
*/
|
|
public function testSetAutoliteral()
|
|
{
|
|
$this->smarty->setAutoLiteral(true);
|
|
$this->smarty->assign('i','foo');
|
|
$this->assertEquals('{ $i}foo', $this->smarty->fetch('autoliteral.tpl'));
|
|
}
|
|
|
|
public function testSetAutoliteral2()
|
|
{
|
|
$this->smarty->setAutoLiteral(false);
|
|
$this->smarty->setCompileId(1);
|
|
$this->smarty->assign('i','bar');
|
|
$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()
|
|
{
|
|
$this->smarty->setAutoLiteral(true);
|
|
$this->assertEquals('{ dummyblock}foo{ /dummyblock}', $this->smarty->fetch('autoliteralblock.tpl'));
|
|
}
|
|
public function testSetAutoliteralBlock1()
|
|
{
|
|
$this->smarty->setAutoLiteral(false);
|
|
$this->smarty->setCompileId(1);
|
|
$this->assertEquals('foo', $this->smarty->fetch('autoliteralblock.tpl'));
|
|
}
|
|
|
|
}
|