diff options
| author | Simon Wisselink <wisskid@users.noreply.github.com> | 2020-04-13 15:30:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-13 15:30:52 +0200 |
| commit | 17d4d43624f9cd183ae0395854f4409c410e3ce9 (patch) | |
| tree | e0e6e3a63b8012267e02240e259da56542e1a911 /tests/UnitTests/SmartyMethodsTests/ClearAssign | |
| parent | 61e741280786d6dbe106fc14690a00d87019de96 (diff) | |
| download | smarty-17d4d43624f9cd183ae0395854f4409c410e3ce9.tar.gz smarty-17d4d43624f9cd183ae0395854f4409c410e3ce9.tar.bz2 smarty-17d4d43624f9cd183ae0395854f4409c410e3ce9.zip | |
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>
Diffstat (limited to 'tests/UnitTests/SmartyMethodsTests/ClearAssign')
4 files changed, 104 insertions, 0 deletions
diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php new file mode 100644 index 00000000..17a0ed5f --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignBCTest.php @@ -0,0 +1,47 @@ +<?php +/** + * Smarty PHPunit tests clearing assigned variables + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for clearing assigned variables tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ClearAssignBCTest extends PHPUnit_Smarty +{ + public $loadSmartyBC = true; + public $loadSmarty = false; + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + + $this->smartyBC->assign('foo', 'foo'); + $this->smartyBC->assign('bar', 'bar'); + $this->smartyBC->assign('blar', 'blar'); + } + + + public function testInit() + { + $this->cleanDirs(); + } + public function testSmarty2ClearAssign() + { + $this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smartyBC->clear_assign('blar'); + $this->assertEquals('foobar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}')); + } + + public function testSmarty2ArrayClearAssign() + { + $this->smartyBC->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smartyBC->clear_assign(array('blar', 'foo')); + $this->assertEquals('bar', $this->smartyBC->fetch('eval:{$foo}{$bar}{$blar}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php new file mode 100644 index 00000000..d47e9da6 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Smarty PHPunit tests clearing assigned variables + * + * @package PHPunit + * @author Uwe Tews + */ + +/** + * class for clearing assigned variables tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class ClearAssignTest extends PHPUnit_Smarty +{ + public function setUp() + { + $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->assign('foo', 'foo'); + $this->smarty->assign('bar', 'bar'); + $this->smarty->assign('blar', 'blar'); + } + + /** + * test all variables accessable + */ + public function testAllVariablesAccessable() + { + $this->assertEquals('foobarblar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}')); + } + + /** + * test simple clear assign + */ + public function testClearAssign() + { + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smarty->clearAssign('blar'); + $this->assertEquals('foobar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}')); + } + + /** + * test clear assign array of variables + */ + public function testArrayClearAssign() + { + $this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE)); + $this->smarty->clearAssign(array('blar', 'foo')); + $this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}{$bar}{$blar}')); + } +} diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/cache/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore new file mode 100644 index 00000000..d88cc144 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/templates_c/.gitignore @@ -0,0 +1,2 @@ +# Ignore anything in here, but keep this directory +* |
