From 268368f2a4cfafe9ece555c5cb1a12659d7a2e26 Mon Sep 17 00:00:00 2001 From: uwetews Date: Mon, 19 Sep 2016 07:36:20 +0200 Subject: [PATCH] Updates because new release update checks --- tests/PHPUnit_Smarty.php | 21 ++++++++++++++----- .../A_1/ProtectedFolderVars/cach/dummy.txt | 0 .../A_1/ProtectedFolderVars/comp/dummy.txt | 0 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 tests/UnitTests/A_1/ProtectedFolderVars/cach/dummy.txt create mode 100644 tests/UnitTests/A_1/ProtectedFolderVars/comp/dummy.txt diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index 9c4b9275..ba2decd9 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -280,10 +280,13 @@ KEY `expire` (`expire`) */ public function cleanCacheDir() { - if (isset($this->smarty)) { - $this->cleanDir($this->smarty->getCacheDir()); - } elseif (isset($this->smartyBC)) { - $this->cleanDir($this->smartyBC->getCacheDir()); + $smarty = $this->getSmartyObj(); + if (isset($smarty)) { + $dir = $smarty->getCacheDir(); + $this->cleanDir($dir); + if (method_exists($smarty, '_isNewRelease')) { + $smarty->_isNewRelease($dir); + } } } @@ -297,7 +300,7 @@ KEY `expire` (`expire`) $di = new RecursiveDirectoryIterator($dir); $ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST); foreach ($ri as $file) { - if (substr(basename($file->getPathname()), 0, 1) == '.') { + if (substr(basename($file->getPathname()), 0, 1) === '.' || substr((string)$file,-4) === '.txt') { continue; } // directory ? @@ -618,6 +621,14 @@ KEY `expire` (`expire`) $source); } + /** + * Gat Smarty object + * @return null|\Smarty|\SmartyBC + */ + public function getSmartyObj(){ + return isset($this->smarty) ? $this->smarty : isset($this->smartyBC) ? $this->smartyBC : null; + } + /** * Tears down the fixture * This method is called after a test is executed. diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/cach/dummy.txt b/tests/UnitTests/A_1/ProtectedFolderVars/cach/dummy.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/comp/dummy.txt b/tests/UnitTests/A_1/ProtectedFolderVars/comp/dummy.txt new file mode 100644 index 00000000..e69de29b