2020-04-13 15:30:52 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Smarty PHPunit tests of delimiter
|
|
|
|
|
*
|
2023-01-05 23:06:02 +01:00
|
|
|
|
2020-04-13 15:30:52 +02:00
|
|
|
* @author Uwe Tews
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* class for delimiter tests
|
|
|
|
|
*
|
2023-01-05 23:06:02 +01:00
|
|
|
*
|
|
|
|
|
*
|
2020-04-13 15:30:52 +02:00
|
|
|
*/
|
|
|
|
|
class AutoliteralTest extends PHPUnit_Smarty
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
public function setUp(): void
|
2020-04-13 15:30:52 +02:00
|
|
|
{
|
2022-09-27 13:03:34 +03:00
|
|
|
$this->setUpSmarty(__DIR__);
|
2020-04-13 15:30:52 +02:00
|
|
|
$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
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
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'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|