diff options
| author | Simon Wisselink <wisskid@users.noreply.github.com> | 2026-04-13 21:36:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-13 21:36:33 +0200 |
| commit | ff2ef3b0cb07fd584946254f145f0509a7685f58 (patch) | |
| tree | 30115da294cadea9dbbfd62416ff8649628826f5 /tests/UnitTests/TemplateSource/_Issues | |
| parent | aa2dcd82cf6a5caac9b1ed51e4bd0283f4dcced7 (diff) | |
| download | smarty-ff2ef3b0cb07fd584946254f145f0509a7685f58.tar.gz smarty-ff2ef3b0cb07fd584946254f145f0509a7685f58.tar.bz2 smarty-ff2ef3b0cb07fd584946254f145f0509a7685f58.zip | |
Redirect test temp dirs to system temp directory
* Redirect test temp dirs to system temp directory. Fixes #1178
Move all test-generated output (compiled templates, cache files, and
temporary template sources) from per-test-directory folders inside the
working tree to a parallel structure under sys_get_temp_dir()/smarty-tests/.
This removes 215 boilerplate .gitignore files from the repo and ensures
running the test suite leaves zero uncommitted files in the working tree.
All 2296 tests continue to pass with identical behavior.
* Isolate each test class in a unique temp directory
getTempDir() now appends a per-class uniqid token to the temp path, so
concurrent or sequential test runs never share compiled/cached output.
The token is generated lazily on first use and reset in
tearDownAfterClass(), giving every test class a fresh isolated directory.
As a result, the Bootstrap.php pre-run cleanup of smarty-tests/ is no
longer needed for correctness (stale paths are unreachable) and was
harmful to concurrent runs, so it has been removed.
* Remove individualFolders dead code and spurious assertTrue from cleanDirs()
- Remove the never-active individualFolders code path from setUpSmarty()
(the constant was always true, making the branch unreachable)
- Remove define('individualFolders') from Config.php and the constructor
- Remove $this->assertTrue(true) from cleanDirs(): it existed solely to
make testInit() count as a passing test; now that cleanDirs() is called
from setUpSmarty() and from test methods directly, the assertion was
spuriously inflating assertion counts
- Add tests/**/templates_c/, cache/, templates_tmp/ to .gitignore to
prevent stale test output from appearing as untracked files
* Clean up each test class's unique temp dir in tearDownAfterClass()
Add a private static removeDir() helper and call it from
tearDownAfterClass() to recursively delete the per-class unique temp
directory after each test class finishes. Cleanup failures are silently
ignored (@ suppression) so they never cause test failures.
Set KEEP_SMARTY_TEST_ARTIFACTS=1 in the environment to skip cleanup and
keep the artifacts on disk for debugging.
* cleanup of unused template files, non-shared files stored in __shared folder, no longer required calls to add template folders et cetera
* fixed the unit tests
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* remove useless resetting of static properties in tearDownAfterClass
* changed an incorrect doc and formatted some code.
* add changelog
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'tests/UnitTests/TemplateSource/_Issues')
19 files changed, 3 insertions, 50 deletions
diff --git a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php index c9ba0d26..b75dd7ff 100644 --- a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php @@ -21,10 +21,6 @@ class ModifierIssue327Test extends PHPUnit_Smarty $this->smarty->registerPlugin('modifier', 'substr', 'substr'); } - public function testInit() - { - $this->cleanDirs(); - } public function testModifier327() { diff --git a/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/327/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/327/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php index 9f6d8164..2a5f3ae2 100644 --- a/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php @@ -20,10 +20,6 @@ class ExtendsIssue419Test extends PHPUnit_Smarty $this->setUpSmarty(__DIR__); } - public function testInit() - { - $this->cleanDirs(); - } public function testextends419() { diff --git a/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/419/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/419/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php index 03a48e1f..ccdadcfd 100644 --- a/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php @@ -22,10 +22,6 @@ class NestedLoopIssue422Test extends PHPUnit_Smarty $this->setUpSmarty(__DIR__); } - public function testInit() - { - $this->cleanDirs(); - } public function testnested422() { diff --git a/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/422/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/422/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php index c880bcb2..ada6c39e 100644 --- a/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php @@ -22,10 +22,6 @@ class SectionPropertiesShortSyntaxIssue428Test extends PHPUnit_Smarty $this->setUpSmarty(__DIR__); } - public function testInit() - { - $this->cleanDirs(); - } public function testSection_001() { diff --git a/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/428/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/428/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/549/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/549/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/549/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/549/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/549/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/549/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php b/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php index cfe55752..50f16a28 100644 --- a/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/TooManyShorthandAttributes949Test.php @@ -4,12 +4,12 @@ class TooManyShorthandAttributes949Test extends PHPUnit_Smarty { public function testPregMatchAll() { - $smarty = new \Smarty\Smarty(); - $smarty->registerPlugin('modifier', 'var_dump', 'var_dump'); + $this->setUpSmarty(__DIR__); + $this->smarty->registerPlugin('modifier', 'var_dump', 'var_dump'); $templateStr = "eval:{\$a = 'blah'}{\$b = array()}{if var_dump('', \$a, \$b, 2)|noprint}blah{else}nah{/if}"; $this->assertEquals( 'nah', - $smarty->fetch($templateStr) + $this->smarty->fetch($templateStr) ); } diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php index 6de26639..f394b68a 100644 --- a/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php @@ -20,10 +20,6 @@ class NewlineSpacing extends PHPUnit_Smarty $this->setUpSmarty(__DIR__); } - public function testInit() - { - $this->cleanDirs(); - } /** * Test spacings @@ -37,7 +33,6 @@ class NewlineSpacing extends PHPUnit_Smarty $name = empty($testName) ? $testNumber : $testName; $file = "Spacing_{$name}.tpl"; $this->makeTemplateFile($file, $code); - $this->smarty->setTemplateDir('./templates_tmp'); $this->smarty->assign('file', $file); $this->smarty->assign('foo', 'bar'); $this->assertEquals($result, diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/topic26878/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/_Issues/topic26878/templates_tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* |
