Files
smarty/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php
Simon Wisselink 17d4d43624 Feature/merge smarty-phpunit into tests subfolder (#580)
* 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>
2020-04-13 15:30:52 +02:00

74 lines
1.9 KiB
PHP

<?php
/**
* Smarty PHPunit tests clearing all assigned variables
*
* @package PHPunit
* @author Uwe Tews
*/
/**
* class for clearing all assigned variables tests
*
* @runTestsInSeparateProcess
* @preserveGlobalState disabled
* @backupStaticAttributes enabled
*/
class ClearAllAssignTest extends PHPUnit_Smarty
{
protected $_data = null;
protected $_tpl = null;
public function setUp()
{
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->assign('foo', 'foo');
$this->_data = $this->smarty->createData($this->smarty);
$this->_data->assign('bar', 'bar');
$this->_tpl = $this->smarty->createTemplate('eval:{$foo}{$bar}{$blar}', null, null, $this->_data);
$this->_tpl->assign('blar', 'blar');
}
public function testInit()
{
$this->cleanDirs();
}
/**
* test all variables accessable
*/
public function testAllVariablesAccessable()
{
$this->assertEquals('foobarblar', $this->smarty->fetch($this->_tpl));
}
/**
* test clear all assign in template
*/
public function testClearAllAssignInTemplate()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
$this->_tpl->clearAllAssign();
$this->assertEquals('foobar', $this->smarty->fetch($this->_tpl));
}
/**
* test clear all assign in data
*/
public function testClearAllAssignInData()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
$this->_data->clearAllAssign();
$this->assertEquals('fooblar', $this->smarty->fetch($this->_tpl));
}
/**
* test clear all assign in Smarty object
*/
public function testClearAllAssignInSmarty()
{
error_reporting((error_reporting() & ~(E_NOTICE | E_USER_NOTICE)));
$this->smarty->clearAllAssign();
$this->assertEquals('barblar', $this->smarty->fetch($this->_tpl));
}
}