From 02968a82b5f23ee4a16c1cbb121d5b9df5d5ce9d Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Tue, 16 Aug 2022 22:43:47 +0200 Subject: [PATCH 01/30] Update SECURITY.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed comment that still indicated v4 wasn’t released yet. --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index d98ea018..ae9d5dc8 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,7 +2,7 @@ ## Supported Versions -Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. (Smarty 4 has not been released yet.) +Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. | Version | Supported | | ------- | ------------------ | From 1bc7c722a39598bdbbd273f5d9d6b61764bb193a Mon Sep 17 00:00:00 2001 From: Mark Fettig Date: Fri, 9 Sep 2022 16:39:24 -0400 Subject: [PATCH 02/30] address PHP 8.1 'explode', 'number_format', and 'replace' deprecations (#755) --- libs/plugins/modifier.explode.php | 25 ++++++++ libs/plugins/modifier.number_format.php | 26 ++++++++ libs/plugins/shared.mb_str_replace.php | 2 +- .../PluginModifierExplodeTest.php | 55 +++++++++++++++++ .../PluginModifierNumberFormatTest.php | 59 +++++++++++++++++++ .../PluginModifierReplaceTest.php | 54 +++++++++++++++++ 6 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 libs/plugins/modifier.explode.php create mode 100644 libs/plugins/modifier.number_format.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNumberFormatTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierReplaceTest.php diff --git a/libs/plugins/modifier.explode.php b/libs/plugins/modifier.explode.php new file mode 100644 index 00000000..5186fde3 --- /dev/null +++ b/libs/plugins/modifier.explode.php @@ -0,0 +1,25 @@ +=8.1 + return explode($separator, $string ?? '', $limit ?? PHP_INT_MAX); +} diff --git a/libs/plugins/modifier.number_format.php b/libs/plugins/modifier.number_format.php new file mode 100644 index 00000000..8c612601 --- /dev/null +++ b/libs/plugins/modifier.number_format.php @@ -0,0 +1,26 @@ +=8.1 + return number_format($num ?? 0.0, $decimals, $decimal_separator, $thousands_separator); +} diff --git a/libs/plugins/shared.mb_str_replace.php b/libs/plugins/shared.mb_str_replace.php index c6079c12..7e85f7aa 100644 --- a/libs/plugins/shared.mb_str_replace.php +++ b/libs/plugins/shared.mb_str_replace.php @@ -62,7 +62,7 @@ if (!function_exists('smarty_mb_str_replace')) { $replace = mb_convert_encoding($replace, $current_charset, Smarty::$_CHARSET); } - $parts = mb_split(preg_quote($search), $subject) ?: array(); + $parts = mb_split(preg_quote($search), $subject ?? "") ?: array(); // If original regex encoding was not unicode... if(!$reg_is_unicode) { // ...restore original regex encoding to avoid breaking the system. diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php new file mode 100644 index 00000000..b3b9d50e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php @@ -0,0 +1,55 @@ +setUpSmarty(__DIR__); + } + + /** + * @return void + * @throws \SmartyException + * + * @dataProvider explodeDataProvider + */ + public function testExplode($template, $subject, $expectedString) + { + $this->smarty->assign('subject', $subject); + + $tpl = $this->smarty->createTemplate($template); + $res = $this->smarty->fetch($tpl); + + $this->assertEquals($expectedString, $res); + } + + public function explodeDataProvider() + { + return [ + 'default' => [ + 'template' => 'string:{","|explode:$subject|json_encode}', + 'subject' => 'a,b,c,d', + 'expectedString' => '["a","b","c","d"]', + ], + 'withNoDelimiterFound' => [ + 'template' => 'string:{","|explode:$subject|json_encode}', + 'subject' => 'abcd', + 'expectedString' => '["abcd"]', + ], + 'withNull' => [ + 'template' => 'string:{","|explode:$subject|json_encode}', + 'subject' => null, + 'expectedString' => '[""]', + ], + ]; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNumberFormatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNumberFormatTest.php new file mode 100644 index 00000000..27feeac3 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNumberFormatTest.php @@ -0,0 +1,59 @@ +setUpSmarty(__DIR__); + } + + /** + * @return void + * @throws \SmartyException + * + * @dataProvider numberFormatDataProvider + */ + public function testNumberFormat($template, $subject, $expectedString) + { + $this->smarty->assign('subject', $subject); + + $tpl = $this->smarty->createTemplate($template); + + $this->assertEquals($expectedString, $this->smarty->fetch($tpl)); + } + + public function numberFormatDataProvider() + { + return [ + 'default' => [ + 'template' => 'string:{$subject|number_format}', + 'subject' => 12345, + 'expectedString' => "12,345", + ], + 'withDecimalDefault' => [ + 'template' => 'string:{$subject|number_format}', + 'subject' => 12345.6789, + 'expectedString' => "12,346", + ], + 'withDecimalAndExtras' => [ + 'template' => 'string:{$subject|number_format:2:"-":"~"}', + 'subject' => 12345.6789, + 'expectedString' => "12~345-68", + ], + 'withNull' => [ + 'template' => 'string:{$subject|number_format}', + 'subject' => null, + 'expectedString' => 0, + ], + ]; + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierReplaceTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierReplaceTest.php new file mode 100644 index 00000000..a4b6a12e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierReplaceTest.php @@ -0,0 +1,54 @@ +setUpSmarty(__DIR__); + } + + /** + * @return void + * @throws \SmartyException + * + * @dataProvider replaceDataProvider + */ + public function testReplace($template, $subject, $expectedString) + { + $this->smarty->assign('subject', $subject); + + $tpl = $this->smarty->createTemplate($template); + + $this->assertEquals($expectedString, $this->smarty->fetch($tpl)); + } + + public function replaceDataProvider() + { + return [ + 'default' => [ + 'template' => 'string:{$subject|replace:",":"-"}', + 'subject' => "a,b,c,d", + 'expectedString' => "a-b-c-d", + ], + 'doNothing' => [ + 'template' => 'string:{$subject|replace:"":""}', + 'subject' => "a,b,c,d", + 'expectedString' => "a,b,c,d", + ], + 'withNull' => [ + 'template' => 'string:{$subject|replace:"":""}', + 'subject' => null, + 'expectedString' => "", + ], + ]; + } +} From f8f97b4e2d0eedcc5b24acbec2d456447b556398 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Sat, 10 Sep 2022 12:34:20 +0200 Subject: [PATCH 03/30] Fixed PHP8.1 deprecation errors in upper modifier #788 --- CHANGELOG.md | 3 +++ libs/plugins/modifiercompiler.upper.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c58ff21..492defd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed PHP8.1 deprecation errors in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) + ## [4.2.0] - 2022-08-01 ### Fixed diff --git a/libs/plugins/modifiercompiler.upper.php b/libs/plugins/modifiercompiler.upper.php index e12ae676..31a90a05 100644 --- a/libs/plugins/modifiercompiler.upper.php +++ b/libs/plugins/modifiercompiler.upper.php @@ -21,8 +21,8 @@ function smarty_modifiercompiler_upper($params) { if (Smarty::$_MBSTRING) { - return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')'; } // no MBString fallback - return 'strtoupper(' . $params[ 0 ] . ')'; + return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')'; } From 5479e3362ca66d1e485d7585f08f439c6fdeb20b Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 12 Sep 2022 12:13:42 +0200 Subject: [PATCH 04/30] Fixed use of `rand()` without a parameter in math function (#795) * Fixed use of `rand()` without a parameter in math function Fixes #794 --- CHANGELOG.md | 1 + libs/plugins/function.math.php | 2 +- .../UnitTests/TemplateSource/ValueTests/Math/MathTest.php | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 492defd4..0f73fe82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed PHP8.1 deprecation errors in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) +- Fixed use of `rand()` without a parameter in math function [#794](https://github.com/smarty-php/smarty/issues/794) ## [4.2.0] - 2022-08-01 diff --git a/libs/plugins/function.math.php b/libs/plugins/function.math.php index 8560e944..f9cf67fe 100644 --- a/libs/plugins/function.math.php +++ b/libs/plugins/function.math.php @@ -70,7 +70,7 @@ function smarty_function_math($params, $template) $number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number $functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))'; $operators = '[,+\/*\^%-]'; // Allowed math operators - $regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/'; + $regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)*\)|\((?1)*\)))(?:'.$operators.'(?1))?)+$/'; if (!preg_match($regexp, $equation)) { trigger_error("math: illegal characters", E_USER_WARNING); diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php index 82255644..3be6ad2e 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php @@ -156,4 +156,12 @@ class MathTest extends PHPUnit_Smarty $this->assertEquals($expected, $this->smarty->fetch($tpl)); } + public function testRand() + { + $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{math equation="x * rand()" x=$x}'); + // this assertion may seem silly, but it serves to prove that using rand() without a parameter + // will not trigger a security error (see https://github.com/smarty-php/smarty/issues/794) + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } + } From 6872e78238e967fe06657658245079bffc73db03 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 12 Sep 2022 15:49:37 +0200 Subject: [PATCH 05/30] Utility script for running unit tests on all PHP versions locally --- docker-compose.yml | 1 + run_tests_for_all_php_versions.sh | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100755 run_tests_for_all_php_versions.sh diff --git a/docker-compose.yml b/docker-compose.yml index 8ba90328..86a45378 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: base: build: context: . + dockerfile: ./utilities/testrunners/php71/Dockerfile volumes: - .:/app working_dir: /app diff --git a/run_tests_for_all_php_versions.sh b/run_tests_for_all_php_versions.sh new file mode 100755 index 00000000..b95166fc --- /dev/null +++ b/run_tests_for_all_php_versions.sh @@ -0,0 +1,7 @@ +# Runs tests for all supported PHP versions +docker-compose run php71 && \ +docker-compose run php72 && \ +docker-compose run php73 && \ +docker-compose run php74 && \ +docker-compose run php80 && \ +docker-compose run php81 From 50d5890eaca5192a7352f1906a556341890db0ce Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 12 Sep 2022 15:52:32 +0200 Subject: [PATCH 06/30] Exclude unit test files from git export --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index ca0450d8..81586365 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,6 +12,7 @@ /utilities export-ignore /docker-compose.yml export-ignore /.github export-ignore +/run_tests_for_all_php_versions.sh export-ignore /.gitattributes export-ignore /.gitignore export-ignore /make-release.sh export-ignore From 749481843422c72a016a111a85d090bfbe77dbd3 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Mon, 12 Sep 2022 16:02:42 +0200 Subject: [PATCH 07/30] prevent double CI workflows in PRs --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e27b60bf..2f70582f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,10 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions on: - - pull_request - - push + pull_request: + push: + branches: + - 'master' name: CI From d304d349b4deb19c84742b29b53bb3f8e59413fc Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Tue, 13 Sep 2022 12:19:44 +0200 Subject: [PATCH 08/30] Fixed PHP8.1 deprecation errors in capitalize modifier Fixes #789 --- CHANGELOG.md | 1 + libs/plugins/modifier.capitalize.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f73fe82..2d4389cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed PHP8.1 deprecation errors in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) +- Fixed PHP8.1 deprecation errors in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789) - Fixed use of `rand()` without a parameter in math function [#794](https://github.com/smarty-php/smarty/issues/794) ## [4.2.0] - 2022-08-01 diff --git a/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php index c5fc400a..b7da0898 100644 --- a/libs/plugins/modifier.capitalize.php +++ b/libs/plugins/modifier.capitalize.php @@ -22,6 +22,8 @@ */ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false) { + $string = (string) $string; + if (Smarty::$_MBSTRING) { if ($lc_rest) { // uppercase (including hyphenated words) From 55ea25d1f50f0406fb1ccedd212c527977793fc9 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 14 Sep 2022 11:38:18 +0200 Subject: [PATCH 09/30] Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks Fixes #454 --- CHANGELOG.md | 3 ++ libs/plugins/function.mailto.php | 28 ++++++++++++------- .../PluginFunctionMailtoTest.php | 21 ++++++++++++-- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d4389cd..2ff747ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Security +- Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks [#454](https://github.com/smarty-php/smarty/issues/454) + ### Fixed - Fixed PHP8.1 deprecation errors in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) - Fixed PHP8.1 deprecation errors in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789) diff --git a/libs/plugins/function.mailto.php b/libs/plugins/function.mailto.php index 834d0535..671ac069 100644 --- a/libs/plugins/function.mailto.php +++ b/libs/plugins/function.mailto.php @@ -48,8 +48,13 @@ */ function smarty_function_mailto($params) { - static $_allowed_encoding = - array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); + static $_allowed_encoding = [ + 'javascript' => true, + 'javascript_charcode' => true, + 'hex' => true, + 'none' => true + ]; + $extra = ''; if (empty($params[ 'address' ])) { trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); @@ -57,19 +62,19 @@ function smarty_function_mailto($params) } else { $address = $params[ 'address' ]; } + $text = $address; + // netscape and mozilla do not decode %40 (@) in BCC field (bug?) // so, don't encode it. - $search = array('%40', '%2C'); - $replace = array('@', ','); - $mail_parms = array(); + $mail_parms = []; foreach ($params as $var => $value) { switch ($var) { case 'cc': case 'bcc': case 'followupto': if (!empty($value)) { - $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); + $mail_parms[] = $var . '=' . str_replace(['%40', '%2C'], ['@', ','], rawurlencode($value)); } break; case 'subject': @@ -83,6 +88,7 @@ function smarty_function_mailto($params) default: } } + if ($mail_parms) { $address .= '?' . join('&', $mail_parms); } @@ -94,19 +100,21 @@ function smarty_function_mailto($params) ); return; } + + $string = '' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) . ''; + if ($encode === 'javascript') { - $string = '' . $text . ''; $js_encode = ''; for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { $js_encode .= '%' . bin2hex($string[ $x ]); } return ''; } elseif ($encode === 'javascript_charcode') { - $string = '' . $text . ''; for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { $ord[] = ord($string[ $x ]); } - return ''; + return ''; } elseif ($encode === 'hex') { preg_match('!^(.*)(\?.*)$!', $address, $match); if (!empty($match[ 2 ])) { @@ -129,6 +137,6 @@ function smarty_function_mailto($params) return '' . $text_encode . ''; } else { // no encoding - return '' . $text . ''; + return $string; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php index bc5152a2..52b18ecc 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php @@ -150,7 +150,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testUmlauts() { - $result = 'me+smtpext@example.com'; + $result = 'me+smtpext@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); } @@ -158,9 +158,26 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testUmlautsWithoutMbstring() { Smarty::$_MBSTRING = false; - $result = 'me+smtpext@example.com'; + $result = 'me+smtpext@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); Smarty::$_MBSTRING = true; } + + public function testJavascriptChars() + { + $result = ''; + $this->smarty->assign('address', 'me@example.com">me@example.com\'); alert("injection"); //'); + $tpl = $this->smarty->createTemplate('eval:{mailto address=$address encode=javascript}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + + public function testHtmlChars() + { + $result = ''; + $this->smarty->assign('address', 'me@example.com">

'); + $tpl = $this->smarty->createTemplate('eval:{mailto address=$address extra=\'class="email"\'}'); + $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); + } + } From 813c83f7a3c3344f64b8e4b634612a2aebfaf4c0 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 14 Sep 2022 12:44:37 +0200 Subject: [PATCH 10/30] Fixed unselected year/month/day not working in html_select_date Fixes #395 --- CHANGELOG.md | 1 + libs/plugins/function.html_select_date.php | 69 ++++++++++--------- .../PluginFunctionHtmlSelectDateTest.php | 30 +++++++- 3 files changed, 68 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff747ab..784d5b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed PHP8.1 deprecation errors in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) - Fixed PHP8.1 deprecation errors in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789) - Fixed use of `rand()` without a parameter in math function [#794](https://github.com/smarty-php/smarty/issues/794) +- Fixed unselected year/month/day not working in html_select_date [#395](https://github.com/smarty-php/smarty/issues/395) ## [4.2.0] - 2022-08-01 diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php index 763fc60f..a396046b 100644 --- a/libs/plugins/function.html_select_date.php +++ b/libs/plugins/function.html_select_date.php @@ -101,6 +101,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem $field_separator = "\n"; $option_separator = "\n"; $time = null; + // $all_empty = null; // $day_empty = null; // $month_empty = null; @@ -113,17 +114,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem foreach ($params as $_key => $_value) { switch ($_key) { case 'time': - if (!is_array($_value) && $_value !== null) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_make_timestamp', - 'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php' - ) - ) - ); - $time = smarty_make_timestamp($_value); - } + $$_key = $_value; // we'll handle conversion below break; case 'month_names': if (is_array($_value) && count($_value) === 12) { @@ -178,43 +169,59 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem } // Note: date() is faster than strftime() // Note: explode(date()) is faster than date() date() date() - if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) { - if (isset($params[ 'time' ][ $prefix . 'Year' ])) { + + if (isset($time) && is_array($time)) { + if (isset($time[$prefix . 'Year'])) { // $_REQUEST[$field_array] given - foreach (array( - 'Y' => 'Year', - 'm' => 'Month', - 'd' => 'Day' - ) as $_elementKey => $_elementName) { + foreach ([ + 'Y' => 'Year', + 'm' => 'Month', + 'd' => 'Day' + ] as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); $$_variableName = - isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] : + isset($time[$prefix . $_elementName]) ? $time[$prefix . $_elementName] : date($_elementKey); } - } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) { + } elseif (isset($time[$field_array][$prefix . 'Year'])) { // $_REQUEST given - foreach (array( - 'Y' => 'Year', - 'm' => 'Month', - 'd' => 'Day' - ) as $_elementKey => $_elementName) { + foreach ([ + 'Y' => 'Year', + 'm' => 'Month', + 'd' => 'Day' + ] as $_elementKey => $_elementName) { $_variableName = '_' . strtolower($_elementName); - $$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ? - $params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey); + $$_variableName = isset($time[$field_array][$prefix . $_elementName]) ? + $time[$field_array][$prefix . $_elementName] : date($_elementKey); } } else { // no date found, use NOW - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); + [$_year, $_month, $_day] = explode('-', date('Y-m-d')); } + } elseif (isset($time) && preg_match("/(\d*)-(\d*)-(\d*)/", $time, $matches)) { + $_year = $_month = $_day = null; + if ($matches[1] > '') $_year = (int) $matches[1]; + if ($matches[2] > '') $_month = (int) $matches[2]; + if ($matches[3] > '') $_day = (int) $matches[3]; } elseif ($time === null) { if (array_key_exists('time', $params)) { - $_year = $_month = $_day = $time = null; + $_year = $_month = $_day = null; } else { - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); + [$_year, $_month, $_day] = explode('-', date('Y-m-d')); } } else { - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time)); + $template->_checkPlugins( + array( + array( + 'function' => 'smarty_make_timestamp', + 'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php' + ) + ) + ); + $time = smarty_make_timestamp($time); + [$_year, $_month, $_day] = explode('-', date('Y-m-d', $time)); } + // make syntax "+N" or "-N" work with $start_year and $end_year // Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr foreach (array( diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php index 26ea6faa..0cf4f9ba 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php @@ -210,7 +210,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(dirname(__FILE__)); - $this->smarty->setErrorReporting(E_ALL & ~E_DEPRECATED); + $this->smarty->setErrorReporting(E_ALL & ~E_DEPRECATED); $year = date('Y'); $this->now = mktime(15, 0, 0, 2, 20, $year); @@ -239,6 +239,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty $this->years['default'] = ""; $this->years['none'] = ""; + } protected function reverse($string) @@ -395,6 +396,33 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty $this->assertEquals($result, $tpl->fetch()); } + public function testEmptyDayWithDateString() { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time="2022-02-" day_empty="day" start_year=2005}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEmptyMonthWithDateStrings() { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time="2022--20" month_empty="month" start_year=2005}'); + $this->assertEquals($result, $tpl->fetch()); + } + + public function testEmptyYearWithDateStrings() { + $n = "\n"; + $result = '' + . $n . '' + . $n . ''; + $tpl = $this->smarty->createTemplate('eval:{html_select_date time="-02-20" year_empty="year"}'); + $this->assertEquals($result, $tpl->fetch()); + } + public function testId() { $n = "\n"; From c693d8137073a5e6d58d62f321b76fa9edf6d378 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 14 Sep 2022 12:58:59 +0200 Subject: [PATCH 11/30] version bump --- CHANGELOG.md | 2 ++ libs/Smarty.class.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 784d5b10..85fc91ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.2.1] - 2022-09-14 + ### Security - Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks [#454](https://github.com/smarty-php/smarty/issues/454) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 58fd20b7..21beafdf 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -98,7 +98,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '4.2.0'; + const SMARTY_VERSION = '4.2.1'; /** * define variable scopes */ From e2e68b3622e3e4f0499477a9b353a333e449dfd1 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 14 Sep 2022 13:47:36 +0200 Subject: [PATCH 12/30] clean output buffer for Throwable instead of just Exception (#797) Fixes #514 --- CHANGELOG.md | 3 +++ libs/sysplugins/smarty_internal_templatebase.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85fc91ec..586befa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) + ## [4.2.1] - 2022-09-14 ### Security diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php index 2ffb896f..918362e9 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/libs/sysplugins/smarty_internal_templatebase.php @@ -257,7 +257,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data error_reporting($_smarty_old_error_level); } return $result; - } catch (Exception $e) { + } catch (Throwable $e) { while (ob_get_level() > $level) { ob_end_clean(); } From d683641f90bad0a9a812595c923c8f580d20bb7a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 18 Sep 2022 05:14:59 -0400 Subject: [PATCH 13/30] Fix wrong indentation in libs/plugins/modifier.capitalize.php (#802) --- libs/plugins/modifier.capitalize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php index b7da0898..2903d61d 100644 --- a/libs/plugins/modifier.capitalize.php +++ b/libs/plugins/modifier.capitalize.php @@ -22,7 +22,7 @@ */ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false) { - $string = (string) $string; + $string = (string) $string; if (Smarty::$_MBSTRING) { if ($lc_rest) { From db80246b58f53477478e720149309e91c1593003 Mon Sep 17 00:00:00 2001 From: Storyxx <57802448+Storyxx@users.noreply.github.com> Date: Sun, 18 Sep 2022 17:15:56 +0200 Subject: [PATCH 14/30] fix compilation for caching templates (#801) --- libs/sysplugins/smarty_internal_template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index bae22a7d..bf627ce7 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -292,7 +292,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $smarty = &$this->smarty; $_templateId = $smarty->_getTemplateId($template, $cache_id, $compile_id, $caching, $tpl); // recursive call ? - if (isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId() !== $_templateId) { + if ((isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId()) !== $_templateId) { // already in template cache? if (isset(self::$tplObjCache[ $_templateId ])) { // copy data from cached object @@ -358,7 +358,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } if ($tpl->caching === 9999) { if (!isset($tpl->compiled)) { - $this->loadCompiled(true); + $tpl->loadCompiled(true); } if ($tpl->compiled->has_nocache_code) { $this->cached->hashes[ $tpl->compiled->nocache_hash ] = true; From 32a11b34eafe25523f50db791e9761ebe2cd67e9 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Sun, 18 Sep 2022 17:18:32 +0200 Subject: [PATCH 15/30] Added changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 586befa5..460962d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) +- Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) ## [4.2.1] - 2022-09-14 From bf7d6b8bd852baf8f34ad058f682ac99dce54056 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Tue, 20 Sep 2022 22:45:16 +0200 Subject: [PATCH 16/30] Include docs en demo in the releases. Fixes #799 --- .gitattributes | 2 -- CHANGELOG.md | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 81586365..c6644c99 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,8 +7,6 @@ # exclude from git export /tests export-ignore -/demo export-ignore -/docs export-ignore /utilities export-ignore /docker-compose.yml export-ignore /.github export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 460962d6..de77f19f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799) + ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) - Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) From 45345e75ecaafe71fed31be30f30a9effad9e41e Mon Sep 17 00:00:00 2001 From: Jonathan Stoll Date: Wed, 21 Sep 2022 21:54:41 +0200 Subject: [PATCH 17/30] Fix Variable Usage (#808) Fix Variable Usage in Exception message when unable to load subtemplate --- libs/sysplugins/smarty_internal_method_mustcompile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/sysplugins/smarty_internal_method_mustcompile.php b/libs/sysplugins/smarty_internal_method_mustcompile.php index 39318838..381346c8 100644 --- a/libs/sysplugins/smarty_internal_method_mustcompile.php +++ b/libs/sysplugins/smarty_internal_method_mustcompile.php @@ -32,7 +32,7 @@ class Smarty_Internal_Method_MustCompile { if (!$_template->source->exists) { if ($_template->_isSubTpl()) { - $parent_resource = " in '$_template->parent->template_resource}'"; + $parent_resource = " in '{$_template->parent->template_resource}'"; } else { $parent_resource = ''; } From f8a958cd537fbec6a4cf8d459d0c5e7be15d6248 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 21 Sep 2022 21:56:39 +0200 Subject: [PATCH 18/30] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de77f19f..0063bb54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) - Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) +- Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808) ## [4.2.1] - 2022-09-14 From c53342c9fc9fb00e440a00a549e4076b688c808b Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 14:11:36 +0200 Subject: [PATCH 19/30] Silence deprecation errors for strtime in PHP8.1 or higher Fixes #672 (#811) --- CHANGELOG.md | 5 +++-- libs/plugins/function.html_select_date.php | 4 ++-- libs/plugins/modifier.date_format.php | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0063bb54..31421280 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) - Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) - Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808) +- Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672) ## [4.2.1] - 2022-09-14 @@ -20,8 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks [#454](https://github.com/smarty-php/smarty/issues/454) ### Fixed -- Fixed PHP8.1 deprecation errors in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) -- Fixed PHP8.1 deprecation errors in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789) +- Fixed PHP8.1 deprecation notices in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788) +- Fixed PHP8.1 deprecation notices in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789) - Fixed use of `rand()` without a parameter in math function [#794](https://github.com/smarty-php/smarty/issues/794) - Fixed unselected year/month/day not working in html_select_date [#395](https://github.com/smarty-php/smarty/issues/395) diff --git a/libs/plugins/function.html_select_date.php b/libs/plugins/function.html_select_date.php index a396046b..d9c57197 100644 --- a/libs/plugins/function.html_select_date.php +++ b/libs/plugins/function.html_select_date.php @@ -316,8 +316,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem for ($i = 1; $i <= 12; $i++) { $_val = sprintf('%02d', $i); $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) : - ($month_format === '%m' ? $_val : strftime($month_format, $_month_timestamps[ $i ])); - $_value = $month_value_format === '%m' ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]); + ($month_format === '%m' ? $_val : @strftime($month_format, $_month_timestamps[ $i ])); + $_value = $month_value_format === '%m' ? $_val : @strftime($month_value_format, $_month_timestamps[ $i ]); $_html_months .= '' . $option_separator; } diff --git a/libs/plugins/modifier.date_format.php b/libs/plugins/modifier.date_format.php index 8e7e0b6e..e3589fd0 100644 --- a/libs/plugins/modifier.date_format.php +++ b/libs/plugins/modifier.date_format.php @@ -78,7 +78,8 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '' } $format = str_replace($_win_from, $_win_to, $format); } - return strftime($format, $timestamp); + // @ to suppress deprecation errors when running in PHP8.1 or higher. + return @strftime($format, $timestamp); } else { return date($format, $timestamp); } From b91c04bfcf16f54fb505111f83dacbaef156b10e Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 22 Sep 2022 14:29:51 +0200 Subject: [PATCH 20/30] Fixed PHP8.1 deprecation errors passing null to parameter in trim (#807) Fixed a PHP 8.1 deprecation error: trim(): Passing null to parameter #1 ($string) of type string is deprecated in cacheresource_keyvaluestore.php on line 247 and in cacheresource_keyvaluestore.php on line 431 --- libs/sysplugins/smarty_cacheresource_keyvaluestore.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php index 59bf1d4a..4b1c0f6d 100644 --- a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php +++ b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php @@ -244,7 +244,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource */ protected function sanitize($string) { - $string = trim($string, '|'); + $string = trim((string)$string, '|'); if (!$string) { return ''; } @@ -428,7 +428,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $t[] = 'IVK#COMPILE' . $_compile; } $_name .= '#'; - $cid = trim($cache_id, '|'); + $cid = trim((string)$cache_id, '|'); if (!$cid) { return $t; } From 474138fd7ee0519b68a7fb773fb5867bd856e242 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 14:31:01 +0200 Subject: [PATCH 21/30] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31421280..a6a0cb05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) - Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808) - Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672) +- Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807) ## [4.2.1] - 2022-09-14 From ea95e8b04750b3e52d0dfc6e201a19e5e385f298 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 14:31:49 +0200 Subject: [PATCH 22/30] Re-organize all testrunners to use the same script(s). (#812) --- .github/workflows/ci.yml | 6 +---- docker-compose.yml | 2 +- run-tests-for-all-php-versions.sh | 44 +++++++++++++++++++++++++++++++ run-tests.sh | 13 +++++++++ run_tests_for_all_php_versions.sh | 7 ----- utilities/testrunners/run-test.sh | 2 -- 6 files changed, 59 insertions(+), 15 deletions(-) create mode 100755 run-tests-for-all-php-versions.sh create mode 100755 run-tests.sh delete mode 100755 run_tests_for_all_php_versions.sh delete mode 100755 utilities/testrunners/run-test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f70582f..449146c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,9 +71,5 @@ jobs: restore-keys: | ${{ runner.os }}-php-${{ matrix.php-version }}- - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest - - name: Run tests with phpunit - run: ./phpunit.sh + run: ./run-tests.sh diff --git a/docker-compose.yml b/docker-compose.yml index 86a45378..d46608bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: volumes: - .:/app working_dir: /app - entrypoint: sh ./utilities/testrunners/run-test.sh + entrypoint: sh ./run-tests.sh php71: extends: service: base diff --git a/run-tests-for-all-php-versions.sh b/run-tests-for-all-php-versions.sh new file mode 100755 index 00000000..6ecd9afb --- /dev/null +++ b/run-tests-for-all-php-versions.sh @@ -0,0 +1,44 @@ +#!/bin/bash +Help() +{ + # Display Help + echo "Runs PHPUnit tests for all PHP versions supported by this version of Smarty." + echo + echo "Syntax: $0 [-e|h]" + echo "options:" + echo "e Exclude a group of unit tests, e.g. -e 'slow'" + echo "h Print this Help." + echo +} + +Exclude="" + +# Get the options +while getopts ":he:" option; do + case $option in + e) # Exclude + echo $OPTARG + Exclude=$OPTARG;; + h) # display Help + Help + exit;; + \?) # Invalid option + echo "Error: Invalid option" + exit;; + esac +done + +if [ -z $Exclude ]; +then + Entrypoint="./run-tests.sh" +else + Entrypoint="./run-tests.sh $Exclude" +fi + +# Runs tests for all supported PHP versions +docker-compose run --entrypoint "$Entrypoint" php71 && \ +docker-compose run --entrypoint "$Entrypoint" php72 && \ +docker-compose run --entrypoint "$Entrypoint" php73 && \ +docker-compose run --entrypoint "$Entrypoint" php74 && \ +docker-compose run --entrypoint "$Entrypoint" php80 && \ +docker-compose run --entrypoint "$Entrypoint" php81 diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 00000000..ddcad01b --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,13 @@ +#!/bin/sh +composer update + +php -r 'echo "\nPHP version " . phpversion() . ". ";'; + +if [ -z $1 ]; +then + echo "Running all unit tests.\n" + php ./vendor/phpunit/phpunit/phpunit +else + echo "Running all unit tests, except tests marked with @group $1.\n" + php ./vendor/phpunit/phpunit/phpunit --exclude-group $1 +fi \ No newline at end of file diff --git a/run_tests_for_all_php_versions.sh b/run_tests_for_all_php_versions.sh deleted file mode 100755 index b95166fc..00000000 --- a/run_tests_for_all_php_versions.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Runs tests for all supported PHP versions -docker-compose run php71 && \ -docker-compose run php72 && \ -docker-compose run php73 && \ -docker-compose run php74 && \ -docker-compose run php80 && \ -docker-compose run php81 diff --git a/utilities/testrunners/run-test.sh b/utilities/testrunners/run-test.sh deleted file mode 100755 index cca96f5e..00000000 --- a/utilities/testrunners/run-test.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -composer update && php ./vendor/phpunit/phpunit/phpunit From 9eea30ec1e2de074d0a2874495833bce3568149f Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 14:44:45 +0200 Subject: [PATCH 23/30] Removed now superfluous phpunit.sh --- phpunit.sh | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 phpunit.sh diff --git a/phpunit.sh b/phpunit.sh deleted file mode 100755 index a733b767..00000000 --- a/phpunit.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/bash -vendor/phpunit/phpunit/phpunit From 612bd3f657875c9a425efebcab22856e4927c5ba Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 14:55:20 +0200 Subject: [PATCH 24/30] Fixed PHP8.1 deprecation errors in strip_tags (#803) --- CHANGELOG.md | 1 + libs/plugins/modifiercompiler.strip_tags.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6a0cb05..f9d10a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) - Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801) +- Fixed PHP8.1 deprecation errors in strip_tags - Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808) - Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672) - Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807) diff --git a/libs/plugins/modifiercompiler.strip_tags.php b/libs/plugins/modifiercompiler.strip_tags.php index 6ee3df9a..bd866a61 100644 --- a/libs/plugins/modifiercompiler.strip_tags.php +++ b/libs/plugins/modifiercompiler.strip_tags.php @@ -21,8 +21,8 @@ function smarty_modifiercompiler_strip_tags($params) { if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') { - return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; + return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')"; } else { - return 'strip_tags(' . $params[ 0 ] . ')'; + return 'strip_tags((string) ' . $params[ 0 ] . ')'; } } From 0fb29024e7980c14c1ba1578847a81b5a16612d5 Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Thu, 22 Sep 2022 14:32:55 -0700 Subject: [PATCH 25/30] #155 Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) (#586) * Implemented locale safe strotoupper, strolower and ucfirst functions for translating user string to filenames etc. Fixes #155 Co-Authored-By: Alexkurd <7689609+Alexkurd@users.noreply.github.com> --- CHANGELOG.md | 1 + libs/Autoloader.php | 7 ++- libs/Smarty.class.php | 9 ++++ libs/functions.php | 51 +++++++++++++++++++ libs/sysplugins/smarty_cacheresource.php | 4 +- ...nternal_compile_private_foreachsection.php | 6 +-- ...ernal_compile_private_special_variable.php | 6 +-- .../smarty_internal_extension_handler.php | 27 +++++----- .../smarty_internal_method_loadplugin.php | 4 +- .../smarty_internal_templatecompilerbase.php | 4 +- libs/sysplugins/smarty_resource.php | 4 +- 11 files changed, 94 insertions(+), 29 deletions(-) create mode 100644 libs/functions.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f9d10a75..8d7ef819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808) - Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672) - Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807) +- Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586) ## [4.2.1] - 2022-09-14 diff --git a/libs/Autoloader.php b/libs/Autoloader.php index 1673ce2f..c2081403 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -5,6 +5,11 @@ * @package Smarty */ + +if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) { + include dirname(__FILE__) . '/functions.php'; +} + /** * Smarty Autoloader * @@ -89,7 +94,7 @@ class Smarty_Autoloader if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) { return; } - $_class = strtolower($class); + $_class = smarty_strtolower_ascii($class); if (isset(self::$rootClasses[ $_class ])) { $file = self::$SMARTY_DIR . self::$rootClasses[ $_class ]; if (is_file($file)) { diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 21beafdf..5507ebcd 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -60,12 +60,21 @@ if (!defined('SMARTY_MBSTRING')) { */ define('SMARTY_MBSTRING', function_exists('mb_get_info')); } + +/** + * Load helper functions + */ +if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) { + include dirname(__FILE__) . '/functions.php'; +} + /** * Load Smarty_Autoloader */ if (!class_exists('Smarty_Autoloader')) { include dirname(__FILE__) . '/bootstrap.php'; } + /** * Load always needed external class files */ diff --git a/libs/functions.php b/libs/functions.php new file mode 100644 index 00000000..bac00e52 --- /dev/null +++ b/libs/functions.php @@ -0,0 +1,51 @@ +_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class(); } // try plugins dir - $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type); + $cache_resource_class = 'Smarty_CacheResource_' . smarty_ucfirst_ascii($type); if ($smarty->loadPlugin($cache_resource_class)) { return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class(); } diff --git a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php index d3aab24b..246350dc 100644 --- a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php +++ b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php @@ -143,7 +143,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com foreach ($this->resultOffsets as $key => $offset) { foreach ($match[ $offset ] as $m) { if (!empty($m)) { - $this->matchResults[ $key ][ strtolower($m) ] = true; + $this->matchResults[ $key ][ smarty_strtolower_ascii($m) ] = true; } } } @@ -213,12 +213,12 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com */ public function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) { - $tag = strtolower(trim($parameter[ 0 ], '"\'')); + $tag = smarty_strtolower_ascii(trim($parameter[ 0 ], '"\'')); $name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false; if (!$name) { $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true); } - $property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false; + $property = isset($parameter[ 2 ]) ? smarty_strtolower_ascii($compiler->getId($parameter[ 2 ])) : false; if (!$property || !in_array($property, $this->nameProperties)) { $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true); } diff --git a/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/libs/sysplugins/smarty_internal_compile_private_special_variable.php index d53ef51f..590cba5a 100644 --- a/libs/sysplugins/smarty_internal_compile_private_special_variable.php +++ b/libs/sysplugins/smarty_internal_compile_private_special_variable.php @@ -29,7 +29,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) { $_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2)); - $variable = strtolower($compiler->getId($_index[ 0 ])); + $variable = smarty_strtolower_ascii($compiler->getId($_index[ 0 ])); if ($variable === false) { $compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true); } @@ -40,7 +40,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C case 'foreach': case 'section': if (!isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ])) { - $class = 'Smarty_Internal_Compile_' . ucfirst($variable); + $class = 'Smarty_Internal_Compile_' . smarty_ucfirst_ascii($variable); Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class; } return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable( @@ -76,7 +76,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C $compiler->trigger_template_error("(secure mode) super globals not permitted"); break; } - $compiled_ref = '$_' . strtoupper($variable); + $compiled_ref = '$_' . smarty_strtoupper_ascii($variable); break; case 'template': return 'basename($_smarty_tpl->source->filepath)'; diff --git a/libs/sysplugins/smarty_internal_extension_handler.php b/libs/sysplugins/smarty_internal_extension_handler.php index b0761552..634ad831 100644 --- a/libs/sysplugins/smarty_internal_extension_handler.php +++ b/libs/sysplugins/smarty_internal_extension_handler.php @@ -88,20 +88,19 @@ class Smarty_Internal_Extension_Handler $objType = $data->_objType; $propertyType = false; if (!isset($this->resolvedProperties[ $match[ 0 ] ][ $objType ])) { - $property = isset($this->resolvedProperties[ 'property' ][ $basename ]) ? - $this->resolvedProperties[ 'property' ][ $basename ] : - $property = $this->resolvedProperties[ 'property' ][ $basename ] = strtolower( - join( - '_', - preg_split( - '/([A-Z][^A-Z]*)/', - $basename, - -1, - PREG_SPLIT_NO_EMPTY | - PREG_SPLIT_DELIM_CAPTURE - ) + $property = $this->resolvedProperties['property'][$basename] ?? + $this->resolvedProperties['property'][$basename] = smarty_strtolower_ascii( + join( + '_', + preg_split( + '/([A-Z][^A-Z]*)/', + $basename, + -1, + PREG_SPLIT_NO_EMPTY | + PREG_SPLIT_DELIM_CAPTURE ) - ); + ) + ); if ($property !== false) { if (property_exists($data, $property)) { $propertyType = $this->resolvedProperties[ $match[ 0 ] ][ $objType ] = 1; @@ -145,7 +144,7 @@ class Smarty_Internal_Extension_Handler public function upperCase($name) { $_name = explode('_', $name); - $_name = array_map('ucfirst', $_name); + $_name = array_map('smarty_ucfirst_ascii', $_name); return implode('_', $_name); } diff --git a/libs/sysplugins/smarty_internal_method_loadplugin.php b/libs/sysplugins/smarty_internal_method_loadplugin.php index 3bd659cb..6ddcaec9 100644 --- a/libs/sysplugins/smarty_internal_method_loadplugin.php +++ b/libs/sysplugins/smarty_internal_method_loadplugin.php @@ -40,7 +40,7 @@ class Smarty_Internal_Method_LoadPlugin throw new SmartyException("plugin {$plugin_name} is not a valid name format"); } if (!empty($match[ 2 ])) { - $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; + $file = SMARTY_SYSPLUGINS_DIR . smarty_strtolower_ascii($plugin_name) . '.php'; if (isset($this->plugin_files[ $file ])) { if ($this->plugin_files[ $file ] !== false) { return $this->plugin_files[ $file ]; @@ -60,7 +60,7 @@ class Smarty_Internal_Method_LoadPlugin } // plugin filename is expected to be: [type].[name].php $_plugin_filename = "{$match[1]}.{$match[4]}.php"; - $_lower_filename = strtolower($_plugin_filename); + $_lower_filename = smarty_strtolower_ascii($_plugin_filename); if (isset($this->plugin_files)) { if (isset($this->plugin_files[ 'plugins_dir' ][ $_lower_filename ])) { if (!$smarty->use_include_path || $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] !== false) { diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index d6f86ac0..545c1e4f 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -605,7 +605,7 @@ abstract class Smarty_Internal_TemplateCompilerBase if (strcasecmp($name, 'isset') === 0 || strcasecmp($name, 'empty') === 0 || strcasecmp($name, 'array') === 0 || is_callable($name) ) { - $func_name = strtolower($name); + $func_name = smarty_strtolower_ascii($name); if ($func_name === 'isset') { if (count($parameter) === 0) { @@ -765,7 +765,7 @@ abstract class Smarty_Internal_TemplateCompilerBase if (!isset(self::$_tag_objects[ $tag ])) { // lazy load internal compiler plugin $_tag = explode('_', $tag); - $_tag = array_map('ucfirst', $_tag); + $_tag = array_map('smarty_ucfirst_ascii', $_tag); $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag); if (class_exists($class_name) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) diff --git a/libs/sysplugins/smarty_resource.php b/libs/sysplugins/smarty_resource.php index 7fe84536..3c43a9f4 100644 --- a/libs/sysplugins/smarty_resource.php +++ b/libs/sysplugins/smarty_resource.php @@ -76,11 +76,11 @@ abstract class Smarty_Resource } // try sysplugins dir if (isset(self::$sysplugins[ $type ])) { - $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); + $_resource_class = 'Smarty_Internal_Resource_' . smarty_ucfirst_ascii($type); return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); } // try plugins dir - $_resource_class = 'Smarty_Resource_' . ucfirst($type); + $_resource_class = 'Smarty_Resource_' . smarty_ucfirst_ascii($type); if ($smarty->loadPlugin($_resource_class)) { if (class_exists($_resource_class, false)) { return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); From 4fc39d59a5d7b3cb3d49b5170eba43ceafcf6074 Mon Sep 17 00:00:00 2001 From: Scott Newton Date: Thu, 22 Sep 2022 17:56:18 -0400 Subject: [PATCH 26/30] Bug fix for underscore in template name (#581) * Corrected bug #578, where underscore characters were being stripped from template names when using a custom resource * Increased the maximum template name length to 127 characters when using a custom resource --- CHANGELOG.md | 1 + libs/sysplugins/smarty_resource_custom.php | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7ef819..8a924ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672) - Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807) - Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586) +- Bug fix for underscore and limited length in template name in custom resources [#581](https://github.com/smarty-php/smarty/pull/581) ## [4.2.1] - 2022-09-14 diff --git a/libs/sysplugins/smarty_resource_custom.php b/libs/sysplugins/smarty_resource_custom.php index 8d66be3a..191fa7c9 100644 --- a/libs/sysplugins/smarty_resource_custom.php +++ b/libs/sysplugins/smarty_resource_custom.php @@ -47,7 +47,7 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource */ public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) { - $source->filepath = $source->type . ':' . substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25); + $source->filepath = $source->type . ':' . $this->generateSafeName($source->name); $source->uid = sha1($source->type . ':' . $source->name); $mtime = $this->fetchTimestamp($source->name); if ($mtime !== null) { @@ -88,6 +88,17 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource */ public function getBasename(Smarty_Template_Source $source) { - return basename(substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25)); + return basename($this->generateSafeName($source->name)); + } + + /** + * Removes special characters from $name and limits its length to 127 characters. + * + * @param $name + * + * @return string + */ + private function generateSafeName($name): string { + return substr(preg_replace('/[^A-Za-z0-9._]/', '', (string) $name), 0, 127); } } From 4550fc03391bd120b4add41ad7934c4c59aa21e8 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Fri, 23 Sep 2022 00:09:00 +0200 Subject: [PATCH 27/30] Using PHP functions as modifiers now triggers a deprecation notice (#814) Fixes #813 --- CHANGELOG.md | 1 + libs/plugins/modifier.count.php | 36 +++++++++++ libs/plugins/modifiercompiler.nl2br.php | 23 +++++++ libs/plugins/modifiercompiler.round.php | 23 +++++++ libs/plugins/modifiercompiler.str_repeat.php | 23 +++++++ libs/plugins/modifiercompiler.strlen.php | 23 +++++++ ...arty_internal_compile_private_modifier.php | 3 + libs/sysplugins/smarty_security.php | 4 +- .../UnitTests/SecurityTests/SecurityTest.php | 19 +++--- .../RegisterBlock/RegisterBlockTest.php | 4 +- .../CompileRegisteredObjectFunctionTest.php | 4 +- .../TagTests/Append/CompileAppendTest.php | 1 + .../TagTests/Assign/CompileAssignTest.php | 1 + .../TagTests/If/CompileIfTest.php | 1 + .../PluginModifierCountTest.php | 48 +++++++++++++++ .../PluginModifierExplodeTest.php | 1 + .../PluginModifierNl2brTest.php | 33 ++++++++++ .../PluginModifierStrRepeatTest.php | 33 ++++++++++ .../ValueTests/Math/MathTest.php | 61 ++++++++++--------- .../_Issues/327/ModifierIssue327Test.php | 1 + 20 files changed, 299 insertions(+), 44 deletions(-) create mode 100644 libs/plugins/modifier.count.php create mode 100644 libs/plugins/modifiercompiler.nl2br.php create mode 100644 libs/plugins/modifiercompiler.round.php create mode 100644 libs/plugins/modifiercompiler.str_repeat.php create mode 100644 libs/plugins/modifiercompiler.strlen.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php create mode 100644 tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a924ca3..80367524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799) +- Using PHP functions as modifiers now triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813) ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514) diff --git a/libs/plugins/modifier.count.php b/libs/plugins/modifier.count.php new file mode 100644 index 00000000..ca35fc11 --- /dev/null +++ b/libs/plugins/modifier.count.php @@ -0,0 +1,36 @@ + Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface, + * > 1 would be returned, unless value was null, in which case 0 would be returned. + */ + + if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) { + return count($arrayOrObject, (int) $mode); + } elseif ($arrayOrObject === null) { + return 0; + } + return 1; +} diff --git a/libs/plugins/modifiercompiler.nl2br.php b/libs/plugins/modifiercompiler.nl2br.php new file mode 100644 index 00000000..308c00e4 --- /dev/null +++ b/libs/plugins/modifiercompiler.nl2br.php @@ -0,0 +1,23 @@ +smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler) ) { + trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' . + 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' . + 'a custom modifier.', E_USER_DEPRECATED); $output = "{$modifier}({$params})"; } $compiler->known_modifier_type[ $modifier ] = $type; diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php index 3c29c813..42c2a766 100644 --- a/libs/sysplugins/smarty_security.php +++ b/libs/sysplugins/smarty_security.php @@ -105,7 +105,7 @@ class Smarty_Security * * @var array */ - public $php_modifiers = array('escape', 'count', 'nl2br',); + public $php_modifiers = array('escape', 'count', 'sizeof', 'nl2br',); /** * This is an array of allowed tags. @@ -328,7 +328,7 @@ class Smarty_Security * * @param string $modifier_name * @param object $compiler compiler object - * + * @deprecated * @return boolean true if modifier is trusted */ public function isTrustedPhpModifier($modifier_name, $compiler) diff --git a/tests/UnitTests/SecurityTests/SecurityTest.php b/tests/UnitTests/SecurityTests/SecurityTest.php index d68ac3d4..60d80d67 100644 --- a/tests/UnitTests/SecurityTests/SecurityTest.php +++ b/tests/UnitTests/SecurityTests/SecurityTest.php @@ -52,7 +52,7 @@ class SecurityTest extends PHPUnit_Smarty */ public function testTrustedPHPFunction() { - $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}')); + $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{sizeof($foo)}')); } /** @@ -63,9 +63,9 @@ class SecurityTest extends PHPUnit_Smarty public function testNotTrustedPHPFunction() { $this->expectException('SmartyException'); - $this->expectExceptionMessage('PHP function \'count\' not allowed by security setting'); + $this->expectExceptionMessage('PHP function \'sizeof\' not allowed by security setting'); $this->smarty->security_policy->php_functions = array('null'); - $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}'); + $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{sizeof($foo)}'); } /** @@ -75,38 +75,41 @@ class SecurityTest extends PHPUnit_Smarty { $this->smarty->security_policy->php_functions = array('null'); $this->smarty->disableSecurity(); - $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}')); + $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{sizeof($foo)}')); } /** * test trusted modifier + * @deprecated */ public function testTrustedModifier() { - $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}')); + $this->assertEquals("5", @$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@sizeof}')); } /** * test not trusted modifier * @runInSeparateProcess * @preserveGlobalState disabled + * @deprecated */ public function testNotTrustedModifier() { $this->expectException('SmartyException'); - $this->expectExceptionMessage('modifier \'count\' not allowed by security setting'); + $this->expectExceptionMessage('modifier \'sizeof\' not allowed by security setting'); $this->smarty->security_policy->php_modifiers = array('null'); - $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}'); + @$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@sizeof}'); } /** * test not trusted modifier at disabled security + * @deprecated */ public function testDisabledTrustedModifier() { $this->smarty->security_policy->php_modifiers = array('null'); $this->smarty->disableSecurity(); - $this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}')); + @$this->assertEquals("5", $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@sizeof}')); } /** diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php index 7d72c73d..b79ce9fa 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php @@ -40,14 +40,14 @@ class RegisterBlockTest extends PHPUnit_Smarty { $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); $this->smarty->assign('value', 1); - $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|strtoupper}')); + $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|upper}')); } public function testRegisterBlockFunctionModifier2() { $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); $this->smarty->assign('value', 1); - $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|default:""|strtoupper}')); + $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|default:""|upper}')); } public function testRegisterBlockFunctionWrapper() diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php index 59bd3cb8..94a8ef55 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php @@ -60,13 +60,13 @@ class CompileRegisteredObjectFunctionTest extends PHPUnit_Smarty public function testRegisteredObjectBlockFunctionModifier1() { - $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock|strtoupper}'); + $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock|upper}'); $this->assertEquals(strtoupper('block test'), $this->smarty->fetch($tpl)); } public function testRegisteredObjectBlockFunctionModifier2() { - $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock|default:""|strtoupper}'); + $tpl = $this->smarty->createTemplate('eval:{objecttest->myblock}hello world{/objecttest->myblock|default:""|upper}'); $this->assertEquals(strtoupper('block test'), $this->smarty->fetch($tpl)); } // TODO diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php index 76b11052..9fab4fae 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php @@ -21,6 +21,7 @@ class CompileAppendTest extends PHPUnit_Smarty $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); + $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php index fefdd72d..fb02564f 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php @@ -21,6 +21,7 @@ class CompileAssignTest extends PHPUnit_Smarty $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); + $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php index 595ff55c..addd9999 100644 --- a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php @@ -21,6 +21,7 @@ class CompileIfTest extends PHPUnit_Smarty $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); + $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php new file mode 100644 index 00000000..c736356e --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php @@ -0,0 +1,48 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testArray() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", array(1, 2, 3)); + $this->assertEquals("count:3", $this->smarty->fetch($tpl)); + } + + public function testEmptyArray() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", array()); + $this->assertEquals("count:0", $this->smarty->fetch($tpl)); + } + + public function testNull() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", null); + $this->assertEquals("count:0", $this->smarty->fetch($tpl)); + } + + public function testString() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", "string"); + $this->assertEquals("count:1", $this->smarty->fetch($tpl)); + } + +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php index b3b9d50e..5cd13dd3 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php @@ -14,6 +14,7 @@ class PluginModifierExplodeTest extends \PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(__DIR__); + $this->smarty->registerPlugin('modifier', 'json_encode', 'json_encode'); } /** diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php new file mode 100644 index 00000000..ed263019 --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php @@ -0,0 +1,33 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{$v|nl2br}'); + $tpl->assign("v", "Line1\nLine2"); + $this->assertEquals("Line1
\nLine2", $this->smarty->fetch($tpl)); + } + + public function testNoXHTML() + { + $tpl = $this->smarty->createTemplate('string:{$v|nl2br:false}'); + $tpl->assign("v", "Line1\nLine2"); + $this->assertEquals("Line1
\nLine2", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php new file mode 100644 index 00000000..ef5bcfde --- /dev/null +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php @@ -0,0 +1,33 @@ +setUpSmarty(dirname(__FILE__)); + } + + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{$v|str_repeat:2}'); + $tpl->assign("v", "foo"); + $this->assertEquals("foofoo", $this->smarty->fetch($tpl)); + } + + public function testZeroTimes() + { + $tpl = $this->smarty->createTemplate('string:{$v|str_repeat:0}'); + $tpl->assign("v", "foo"); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } +} diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php index 3be6ad2e..b29d5beb 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php @@ -18,6 +18,7 @@ class MathTest extends PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->registerPlugin('modifier', 'sin', 'sin'); } public function testInit() @@ -104,7 +105,7 @@ class MathTest extends PHPUnit_Smarty { $this->smarty->disableSecurity(); $expected = "22.00 -- 4.10"; - $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{$z = $x * $y}{"%0.2f"|sprintf:$z} -- {$x = 20.5}{$y = 5}{$z = $x / $y}{"%0.2f"|sprintf:$z}'); + $tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{$z = $x * $y}{$z|string_format:"%0.2f"} -- {$x = 20.5}{$y = 5}{$z = $x / $y}{$z|string_format:"%0.2f"}'); $this->assertEquals($expected, $this->smarty->fetch($tpl)); } @@ -120,7 +121,7 @@ class MathTest extends PHPUnit_Smarty { $this->smarty->disableSecurity(); $expected = "22.00 -- 4.10"; - $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{$z = $x * $y}{"%0.2f"|sprintf:$z} -- {$x = "20.5"}{$y = "5"}{$z = $x / $y}{"%0.2f"|sprintf:$z}'); + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{$z = $x * $y}{$z|string_format:"%0.2f"} -- {$x = "20.5"}{$y = "5"}{$z = $x / $y}{$z|string_format:"%0.2f"}'); $this->assertEquals($expected, $this->smarty->fetch($tpl)); } @@ -132,36 +133,36 @@ class MathTest extends PHPUnit_Smarty $this->assertEquals($expected, $this->smarty->fetch($tpl)); } - public function testBackticksIllegal() - { - $this->expectException(PHPUnit\Framework\Error\Warning::class); - $expected = "22.00"; - $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="`ls` x * y" x=$x y=$y}'); - $this->assertEquals($expected, $this->smarty->fetch($tpl)); - } + public function testBackticksIllegal() + { + $this->expectException(PHPUnit\Framework\Error\Warning::class); + $expected = "22.00"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="`ls` x * y" x=$x y=$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } - public function testDollarSignsIllegal() - { - $this->expectException(PHPUnit\Framework\Error\Warning::class); - $expected = "22.00"; - $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="$" x=$x y=$y}'); - $this->assertEquals($expected, $this->smarty->fetch($tpl)); - } + public function testDollarSignsIllegal() + { + $this->expectException(PHPUnit\Framework\Error\Warning::class); + $expected = "22.00"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="$" x=$x y=$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } - public function testBracketsIllegal() - { - $this->expectException(PHPUnit\Framework\Error\Warning::class); - $expected = "I"; - $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{$y = "1"}{math equation="((y/x).(x))[x]" x=$x y=$y}'); - $this->assertEquals($expected, $this->smarty->fetch($tpl)); - } + public function testBracketsIllegal() + { + $this->expectException(PHPUnit\Framework\Error\Warning::class); + $expected = "I"; + $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{$y = "1"}{math equation="((y/x).(x))[x]" x=$x y=$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } - public function testRand() - { - $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{math equation="x * rand()" x=$x}'); - // this assertion may seem silly, but it serves to prove that using rand() without a parameter - // will not trigger a security error (see https://github.com/smarty-php/smarty/issues/794) - $this->assertEquals("0", $this->smarty->fetch($tpl)); - } + public function testRand() + { + $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{math equation="x * rand()" x=$x}'); + // this assertion may seem silly, but it serves to prove that using rand() without a parameter + // will not trigger a security error (see https://github.com/smarty-php/smarty/issues/794) + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } } diff --git a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php index 8418ea3e..0634907b 100644 --- a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php @@ -18,6 +18,7 @@ class ModifierIssue327Test extends PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(dirname(__FILE__)); + $this->smarty->registerPlugin('modifier', 'substr', 'substr'); } public function testInit() From 1b556c7077c57b94e2cec093a0877c9d4d571188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Tue, 27 Sep 2022 13:03:34 +0300 Subject: [PATCH 28/30] Use __DIR__ instead of dirname(__FILE__) (#817) --- libs/Autoloader.php | 4 +- libs/Smarty.class.php | 6 +- libs/bootstrap.php | 2 +- libs/sysplugins/smarty_internal_debug.php | 4 +- .../smarty_internal_testinstall.php | 2 +- tests/Bootstrap.php | 6 +- tests/PHPUnit_Smarty.php | 14 ++--- .../PathNormalizationTest.php | 2 +- .../PluginDirNormalizationTest.php | 2 +- .../TemlateDirNormalizationTest.php | 2 +- .../ProtectedFolderVarsTest.php | 56 +++++++++---------- .../UndefinedTemplateVarTest.php | 2 +- .../A_Core/AutoEscape/AutoEscapeTest.php | 2 +- tests/UnitTests/A_Core/Filter/FilterTest.php | 2 +- .../A_Core/Filter/LoadFilterTest.php | 2 +- .../A_Core/Filter/RegisterFilterTest.php | 2 +- .../A_Core/GetterSetter/GetterSetterTest.php | 2 +- .../LoadPlugin/DefaultPluginHandlerTest.php | 2 +- .../A_Core/LoadPlugin/IncludePathTest.php | 4 +- .../A_Core/LoadPlugin/LoadPluginTest.php | 2 +- .../PluginTests/PluginChainedLoadTest.php | 4 +- .../Shared/SharedFunctionsTest.php | 2 +- .../ModifiedSince/HttpModifiedSinceTest.php | 2 +- .../Apc/CacheResourceCustomApcTest.php | 4 +- .../File/CacheResourceFileTest.php | 4 +- .../CacheResourceCustomMemcacheTest.php | 4 +- .../Mysql/CacheResourceCustomMysqlTest.php | 4 +- .../PDO/CacheResourceCustomPDOTest.php | 4 +- .../CacheResourceCustomPDOGzipTest.php | 4 +- .../CacheResourceCustomRegisteredTest.php | 6 +- .../_shared/CacheResourceTestCommon.php | 8 +-- .../CompileCompilerPluginTest.php | 2 +- .../Compiler/Delimiter/AutoLiteralTest.php | 2 +- .../Compiler/Delimiter/DelimiterTest.php | 2 +- .../Compiler/Delimiter/UserLiteralTest.php | 2 +- .../DefaultConfigHandlerTest.php | 2 +- .../ConfigFileTests/file/ConfigVarTest.php | 4 +- .../Ambiguous/CustomResourceAmbiguousTest.php | 14 ++--- .../ResourceExtendsAllPluginTest.php | 2 +- .../ResourceMysqlPluginTest.php | 2 +- .../DefaultTemplateHandlerTest.php | 2 +- .../ResourceTests/Eval/EvalResourceTest.php | 2 +- .../Extends/ExtendsResourceTest.php | 2 +- .../ResourceTests/File/FileResourceTest.php | 44 +++++++-------- .../FileIncludePath/FileIncludePathTest.php | 4 +- .../FileIndexed/FileResourceIndexedTest.php | 8 +-- .../ResourceTests/Php/PhpResourceTest.php | 4 +- .../Registered/RegisteredResourceTest.php | 2 +- .../ResourcePlugins/ResourcePluginTest.php | 2 +- .../Stream/StreamResourceTest.php | 2 +- .../String/StringResourceTest.php | 4 +- .../UnitTests/SecurityTests/FunctionTest.php | 2 +- .../UnitTests/SecurityTests/SecurityTest.php | 4 +- .../SmartyMethodsTests/Append/AppendTest.php | 2 +- .../AppendByRef/AppendByRefTest.php | 2 +- .../SmartyMethodsTests/Assign/AssignTest.php | 2 +- .../AssignByRef/AssignByRefTest.php | 2 +- .../AssignGlobal/AssignGlobalTest.php | 2 +- .../ClearAllAssign/ClearAllAssignTest.php | 2 +- .../ClearAssign/ClearAssignTest.php | 2 +- .../ClearCompiledTest.php | 2 +- .../GetTemplateVars/GetTemplateVarsTest.php | 2 +- .../RegisterBlock/RegisterBlockTest.php | 2 +- .../RegisterCompilerFunctionTest.php | 2 +- .../RegisterFunction/RegisterFunctionTest.php | 2 +- .../RegisterModifier/RegisterModifierTest.php | 2 +- .../CompileRegisteredObjectFunctionTest.php | 2 +- .../TemplateExist/TemplateExistsTest.php | 2 +- .../TemplateSource/Comments/CommentsTest.php | 2 +- .../TemplateSource/Spacing/SpacingTest.php | 2 +- .../StaticClass/StaticClassAccessTest.php | 2 +- .../TagTests/Append/CompileAppendTest.php | 2 +- .../TagTests/Assign/CompileAssignTest.php | 2 +- .../BlockPlugin/CompileBlockPluginTest.php | 2 +- .../BockExtend/CompileBlockExtendsTest.php | 2 +- .../TagTests/Capture/CompileCaptureTest.php | 2 +- .../CompilerPlugin/CompilerPluginTest.php | 4 +- .../ConfigLoad/CompileConfigLoadTest.php | 2 +- .../Delimiter/CompileDelimiterTest.php | 2 +- .../TagTests/Eval/CompileEvalTest.php | 2 +- .../TagTests/For/CompileForTest.php | 2 +- .../TagTests/Foreach/CompileForeachTest.php | 2 +- .../CompileFunctionPluginTest.php | 2 +- .../TagTests/If/CompileIfTest.php | 2 +- .../TagTests/Include/CompileIncludeTest.php | 2 +- .../TagTests/Insert/CompileInsertTest.php | 10 ++-- .../TagTests/Literal/LiteralTest.php | 2 +- .../MakeNocache/CompileMakeNocacheTest.php | 2 +- .../TagTests/Nocache/CompileNocacheTest.php | 2 +- .../PluginBlock/PluginBlockTextformatTest.php | 2 +- .../PluginFunctionFetchTest.php | 2 +- .../PluginFunctionHtmlCheckboxesTest.php | 4 +- .../PluginFunctionHtmlOptionsTest.php | 4 +- .../PluginFunctionHtmlRadiosTest.php | 4 +- .../PluginFunctionHtmlSelectDateTest.php | 2 +- .../PluginFunctionHtmlSelectTimeTest.php | 2 +- .../PluginFunctionMailtoTest.php | 2 +- .../PluginModifierCapitalizeTest.php | 2 +- .../PluginModifierCharsetTest.php | 2 +- .../PluginModifierCountCharactersTest.php | 2 +- .../PluginModifierCountSentencesTest.php | 2 +- .../PluginModifierCountTest.php | 2 +- .../PluginModifierCountWordsTest.php | 2 +- .../PluginModifierDefaultTest.php | 2 +- .../PluginModifierEscapeTest.php | 2 +- .../PluginModifierLowerTest.php | 2 +- .../PluginModifierNl2brTest.php | 2 +- .../PluginModifierRegexReplaceTest.php | 2 +- .../PluginModifierSpacifyTest.php | 2 +- .../PluginModifierStrRepeatTest.php | 2 +- .../PluginModifierStripTest.php | 2 +- .../PluginModifierTruncateTest.php | 2 +- .../PluginModifierUnescapeTest.php | 2 +- .../PluginModifierUpperTest.php | 2 +- .../PluginModifierWordwrapTest.php | 2 +- .../TagTests/Section/CompileSectionTest.php | 2 +- .../SetFilter/CompileSetfilterTest.php | 2 +- .../TagTests/Strip/CompileStripTest.php | 2 +- .../TemplateFunction/CompileFunctionTest.php | 2 +- .../TagTests/While/CompileWhileTest.php | 2 +- .../TagTests/_Attributes/AttributeTest.php | 2 +- .../TagTests/_Error/CompileErrorTest.php | 2 +- .../TagTests/_Print/PrintTest.php | 2 +- .../TagTests/break/CompileBreakTest.php | 2 +- .../ValueTests/Array/ArrayTest.php | 2 +- .../ValueTests/BoolenNull/BooleanNullTest.php | 2 +- .../ConstantTests/ConstantsTest.php | 2 +- .../DoubleQuoted/DoubleQuotedStringTest.php | 2 +- .../ValueTests/Math/MathTest.php | 2 +- .../ValueTests/Modifier/ModifierTest.php | 2 +- .../ValueTests/Objects/ObjectVariableTest.php | 2 +- .../PHPfunctions/PhpFunctionTest.php | 2 +- .../SingleQouted/SingleQuotedStringTest.php | 2 +- .../Constant/SmartyConstantTest.php | 2 +- .../SmartySpecialVars/Cookie/CookieTest.php | 2 +- .../Delimiter/SmartyDelimiterTest.php | 2 +- .../Error/SmartyErrorTest.php | 2 +- .../SmartySpecialVars/Now/SmartyNowTest.php | 2 +- .../SmartySpecialVars/Post/PostTest.php | 2 +- .../SmartyTemplateObjectTest.php | 2 +- .../Version/SmartyVersionTest.php | 2 +- .../Variables/Stream/StreamVariableTest.php | 2 +- .../VariableVariable/VariableVariableTest.php | 2 +- .../TemplateSource/X_Scopes/ScopeTest.php | 2 +- .../UnitTests/TemplateSource/Xml/XmlTest.php | 2 +- .../_Issues/327/ModifierIssue327Test.php | 2 +- .../_Issues/419/ExtendsIssue419Test.php | 2 +- .../_Issues/422/NestedLoopIssue422Test.php | 2 +- ...ctionPropertiesShortSyntaxIssue428Test.php | 2 +- .../549/MbSplitEncodingIssue549Test.php | 2 +- .../_Issues/topic26878/NewlineSpacing.php | 2 +- utilities/BuildExpectedFiles.php | 8 +-- 152 files changed, 250 insertions(+), 250 deletions(-) diff --git a/libs/Autoloader.php b/libs/Autoloader.php index c2081403..da7e32ab 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -7,7 +7,7 @@ if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) { - include dirname(__FILE__) . '/functions.php'; + include __DIR__ . '/functions.php'; } /** @@ -78,7 +78,7 @@ class Smarty_Autoloader */ public static function register($prepend = false) { - self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR; + self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : __DIR__ . DIRECTORY_SEPARATOR; self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR; spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 5507ebcd..22ea0c31 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -36,7 +36,7 @@ if (!defined('SMARTY_DIR')) { /** * */ - define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); + define('SMARTY_DIR', __DIR__ . DIRECTORY_SEPARATOR); } /** * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. @@ -65,14 +65,14 @@ if (!defined('SMARTY_MBSTRING')) { * Load helper functions */ if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) { - include dirname(__FILE__) . '/functions.php'; + include __DIR__ . '/functions.php'; } /** * Load Smarty_Autoloader */ if (!class_exists('Smarty_Autoloader')) { - include dirname(__FILE__) . '/bootstrap.php'; + include __DIR__ . '/bootstrap.php'; } /** diff --git a/libs/bootstrap.php b/libs/bootstrap.php index 2c830468..a226ac04 100644 --- a/libs/bootstrap.php +++ b/libs/bootstrap.php @@ -11,6 +11,6 @@ * Load and register Smarty Autoloader */ if (!class_exists('Smarty_Autoloader')) { - include dirname(__FILE__) . '/Autoloader.php'; + include __DIR__ . '/Autoloader.php'; } Smarty_Autoloader::register(true); diff --git a/libs/sysplugins/smarty_internal_debug.php b/libs/sysplugins/smarty_internal_debug.php index 24b233e2..570819d2 100644 --- a/libs/sysplugins/smarty_internal_debug.php +++ b/libs/sysplugins/smarty_internal_debug.php @@ -210,7 +210,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data // copy the working dirs from application $debObj->setCompileDir($smarty->getCompileDir()); // init properties by hand as user may have edited the original Smarty class - $debObj->setPluginsDir(is_dir(dirname(__FILE__) . '/../plugins') ? dirname(__FILE__) . + $debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ . '/../plugins' : $smarty->getPluginsDir()); $debObj->force_compile = false; $debObj->compile_check = Smarty::COMPILECHECK_ON; @@ -221,7 +221,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data $debObj->debugging_ctrl = 'NONE'; $debObj->error_reporting = E_ALL & ~E_NOTICE; $debObj->debug_tpl = - isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . dirname(__FILE__) . '/../debug.tpl'; + isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl'; $debObj->registered_plugins = array(); $debObj->registered_resources = array(); $debObj->registered_filters = array(); diff --git a/libs/sysplugins/smarty_internal_testinstall.php b/libs/sysplugins/smarty_internal_testinstall.php index 1fac79b7..c8ffd4cc 100644 --- a/libs/sysplugins/smarty_internal_testinstall.php +++ b/libs/sysplugins/smarty_internal_testinstall.php @@ -144,7 +144,7 @@ class Smarty_Internal_TestInstall } // test if all registered plugins_dir are accessible // and if core plugins directory is still registered - $_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins'); + $_core_plugins_dir = realpath(__DIR__ . '/../plugins'); $_core_plugins_available = false; foreach ($smarty->getPluginsDir() as $plugin_dir) { $_plugin_dir = $plugin_dir; diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index d7ed0b5a..eb9c76f7 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -6,9 +6,9 @@ /* * Smarty PHPUnit Bootstrap */ -require_once dirname(__FILE__) . '/Config.php'; -require_once dirname(__FILE__) . '/../vendor/autoload.php'; -require_once dirname(__FILE__) . '/../libs/bootstrap.php'; +require_once __DIR__ . '/Config.php'; +require_once __DIR__ . '/../vendor/autoload.php'; +require_once __DIR__ . '/../libs/bootstrap.php'; require_once 'PHPUnit_Smarty.php'; if (!ini_get('date.timezone')) { diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index 2b949bf4..de4a3776 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -128,7 +128,7 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase } $s_dir[ $dir ] = true; } - $dir = dirname(__FILE__); + $dir = __DIR__; } if (!is_dir($dir . '/templates_c')) { mkdir($dir . '/templates_c'); @@ -145,8 +145,8 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase // instance Smarty class $this->smarty = new Smarty; if (individualFolders != 'true') { - $this->smarty->setCompileDir(dirname(__FILE__) . '/templates_c'); - $this->smarty->setCacheDir(dirname(__FILE__) . '/cache'); + $this->smarty->setCompileDir(__DIR__ . '/templates_c'); + $this->smarty->setCacheDir(__DIR__ . '/cache'); } $this->getSmartyObj(); @@ -637,10 +637,10 @@ KEY `name` (`name`) } public static function getSmartyPluginsDir(){ - if (is_dir(dirname(__FILE__) . '/../smarty/libs/plugins')) { - return dirname(__FILE__) . '/../smarty/libs/plugins'; - } else if(is_dir(dirname(__FILE__) . '/../libs/plugins')) { - return dirname(__FILE__) . '/../libs/plugins'; + if (is_dir(__DIR__ . '/../smarty/libs/plugins')) { + return __DIR__ . '/../smarty/libs/plugins'; + } else if(is_dir(__DIR__ . '/../libs/plugins')) { + return __DIR__ . '/../libs/plugins'; } } /** diff --git a/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php b/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php index fdba81b9..620f21c8 100644 --- a/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php +++ b/tests/UnitTests/A_0/PathNormalization/PathNormalizationTest.php @@ -17,7 +17,7 @@ class PathNormalizationTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testNormalizeToAbsolute() { diff --git a/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php b/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php index 81e51730..4d623876 100644 --- a/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php +++ b/tests/UnitTests/A_0/PathNormalization/PluginDirNormalizationTest.php @@ -17,7 +17,7 @@ class PluginNormalizationTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testGetPluginsDefaultDir() diff --git a/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php b/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php index e8107f3e..cf47ff0c 100644 --- a/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php +++ b/tests/UnitTests/A_0/PathNormalization/TemlateDirNormalizationTest.php @@ -17,7 +17,7 @@ class TemplateNormalizationTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testGetTemplateDir() diff --git a/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php b/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php index 0b2c4aa2..a6fb46a3 100644 --- a/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php +++ b/tests/UnitTests/A_1/ProtectedFolderVars/ProtectedFolderVarsTest.php @@ -17,7 +17,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /* @@ -29,7 +29,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->template_dir = './foo'; $d = $s->getTemplateDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } public function testTemplateDirDirectRelativeArray() @@ -37,8 +37,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->template_dir = array('./foo', './bar/'); $d = $s->template_dir; - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } public function testTemplateDirDirectRelativeArrayAdd() @@ -47,15 +47,15 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s->template_dir = './foo'; $s->addTemplateDir('./bar/'); $d = $s->getTemplateDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } public function testTemplateDirDirectRelativeExtends() { $s = new FolderT(); $d = $s->getTemplateDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } public function testTemplateDirDirectRelativeExtends2() @@ -63,7 +63,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new FolderT(); $s->template_dir = './bar'; $d = $s->getTemplateDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); } /* @@ -75,7 +75,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->config_dir = './foo'; $d = $s->getConfigDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } public function testConfigDirDirectRelativeArray() @@ -83,8 +83,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->config_dir = array('./foo', './bar/'); $d = $s->config_dir; - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } public function testConfigDirDirectRelativeArrayAdd() @@ -93,15 +93,15 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s->config_dir = './foo'; $s->addConfigDir('./bar/'); $d = $s->getConfigDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } public function testConfigDirDirectRelativeExtends() { $s = new FolderT(); $d = $s->getConfigDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR, $d[ 0 ]); } public function testConfigDirDirectRelativeExtends2() @@ -109,7 +109,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new FolderT(); $s->config_dir = './bar'; $d = $s->getConfigDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); } /* @@ -121,7 +121,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->plugins_dir = './foo'; $d = $s->getPluginsDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); } public function testPluginDirDirectRelativeArray() @@ -129,8 +129,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->plugins_dir = array('./foo', './bar/'); $d = $s->plugins_dir; - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } public function testPluginDirDirectRelativeArrayAdd() @@ -139,15 +139,15 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s->plugins_dir = './foo'; $s->addPluginsDir('./bar/'); $d = $s->getPluginsDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]); } public function testPluginDirDirectRelativeExtends() { $s = new FolderT(); $d = $s->getPluginsDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plug' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'plug' . DIRECTORY_SEPARATOR, $d[ 0 ]); } public function testPluginDirDirectRelativeExtends2() @@ -155,7 +155,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new FolderT(); $s->plugins_dir = './bar'; $d = $s->getPluginsDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]); } /* * compile_dir @@ -166,14 +166,14 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->compile_dir = './foo'; $d = $s->getCompileDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); } public function testCompileDirDirectRelativeExtends() { $s = new FolderT(); $d = $s->getCompileDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'comp' . DIRECTORY_SEPARATOR, $d); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'comp' . DIRECTORY_SEPARATOR, $d); } public function testCompileDirDirectRelativeExtends2() @@ -181,7 +181,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new FolderT(); $s->compile_dir = './bar'; $d = $s->getCompileDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); } /* * cache_dir @@ -192,14 +192,14 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new Smarty(); $s->cache_dir = './foo'; $d = $s->getCacheDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d); } public function testCacheDirDirectRelativeExtends() { $s = new FolderT(); $d = $s->getCacheDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, $d); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, $d); } public function testCacheDirDirectRelativeExtends2() @@ -207,7 +207,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty $s = new FolderT(); $s->cache_dir = './bar'; $d = $s->getCacheDir(); - $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); + $this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d); } } diff --git a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php index 3e813100..617adfdd 100644 --- a/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php +++ b/tests/UnitTests/A_2/UndefinedTemplateVar/UndefinedTemplateVarTest.php @@ -15,7 +15,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php index e1d73628..f98d9a84 100644 --- a/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php +++ b/tests/UnitTests/A_Core/AutoEscape/AutoEscapeTest.php @@ -17,7 +17,7 @@ class AutoEscapeTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setEscapeHtml(true); } diff --git a/tests/UnitTests/A_Core/Filter/FilterTest.php b/tests/UnitTests/A_Core/Filter/FilterTest.php index d7b023d8..bea43e33 100644 --- a/tests/UnitTests/A_Core/Filter/FilterTest.php +++ b/tests/UnitTests/A_Core/Filter/FilterTest.php @@ -18,7 +18,7 @@ class FilterTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/A_Core/Filter/LoadFilterTest.php b/tests/UnitTests/A_Core/Filter/LoadFilterTest.php index 27ef30b2..223fa1e0 100644 --- a/tests/UnitTests/A_Core/Filter/LoadFilterTest.php +++ b/tests/UnitTests/A_Core/Filter/LoadFilterTest.php @@ -17,7 +17,7 @@ class LoadFilterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** diff --git a/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php index 9c9733c1..95e806ac 100644 --- a/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php +++ b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php @@ -17,7 +17,7 @@ class RegisterFilterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** diff --git a/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php b/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php index 3610b3e9..da5a04f1 100644 --- a/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php +++ b/tests/UnitTests/A_Core/GetterSetter/GetterSetterTest.php @@ -17,7 +17,7 @@ class GetterSetterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php index 2205a746..78d2c93f 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php @@ -17,7 +17,7 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setForceCompile(true); $this->smarty->disableSecurity(); $this->smarty->registerDefaultPluginHandler('my_plugin_handler'); diff --git a/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php index 100bc877..680fc8f6 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php @@ -13,12 +13,12 @@ class IncludePathTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->use_include_path = true; $this->smarty->setPluginsDir(array('./include','./include1')); $this->smarty->enableSecurity(); $ds = DIRECTORY_SEPARATOR; - set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path()); + set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path()); } /** diff --git a/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php index cf7756a6..820f31a4 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php @@ -17,7 +17,7 @@ class LoadPluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** diff --git a/tests/UnitTests/A_Core/PluginTests/PluginChainedLoadTest.php b/tests/UnitTests/A_Core/PluginTests/PluginChainedLoadTest.php index e2c171f8..0c71f260 100644 --- a/tests/UnitTests/A_Core/PluginTests/PluginChainedLoadTest.php +++ b/tests/UnitTests/A_Core/PluginTests/PluginChainedLoadTest.php @@ -17,7 +17,7 @@ class PluginChainedLoadTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() @@ -27,7 +27,7 @@ class PluginChainedLoadTest extends PHPUnit_Smarty public function testPluginChainedLoad() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); $this->assertStringContainsString('from chain3', $this->smarty->fetch('test_plugin_chained_load.tpl')); } } diff --git a/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php b/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php index 2fb82d43..522c08c7 100644 --- a/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php +++ b/tests/UnitTests/A_Core/PluginTests/Shared/SharedFunctionsTest.php @@ -13,7 +13,7 @@ class SharedFunctionsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** diff --git a/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php b/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php index 8f483de7..509620e6 100644 --- a/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php +++ b/tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php @@ -18,7 +18,7 @@ class HttpModifiedSinceTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php index d1114a73..fa3ca2b1 100644 --- a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php +++ b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php @@ -5,7 +5,7 @@ * @package PHPunit * @author Uwe Tews */ -include_once dirname(__FILE__) . '/../Memcache/CacheResourceCustomMemcacheTest.php'; +include_once __DIR__ . '/../Memcache/CacheResourceCustomMemcacheTest.php'; /** * class for cache resource file tests @@ -21,7 +21,7 @@ class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) { $this->markTestSkipped('APC cache not available'); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); $this->smarty->setCachingType('apc'); $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/'); diff --git a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php index 383aa20f..56a1a49c 100644 --- a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php +++ b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php @@ -6,7 +6,7 @@ * @author Uwe Tews */ -include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; +include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; /** * class for cache resource file tests @@ -20,7 +20,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); $this->smarty->setCachingType('filetest'); } diff --git a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php index 9b9ebfaa..434f2fa1 100644 --- a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php +++ b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php @@ -6,7 +6,7 @@ * @author Uwe Tews */ -include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; +include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; /** * class for cache resource memcache tests @@ -27,7 +27,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon if (!class_exists('Memcache')) { $this->markTestSkipped('Memcache not available'); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); $this->smarty->setCachingType('memcachetest'); } diff --git a/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php b/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php index eec3fc20..3db8ccd8 100644 --- a/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php +++ b/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php @@ -7,7 +7,7 @@ */ if (MysqlCacheEnable == true) { - include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; + include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; /** * class for cache resource file tests @@ -28,7 +28,7 @@ if (MysqlCacheEnable == true) { if (self::$init) { $this->getConnection(); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); $this->smarty->setCachingType('mysqltest'); } diff --git a/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php b/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php index cd025d6b..fc9d0afd 100644 --- a/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php +++ b/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php @@ -7,7 +7,7 @@ */ if (PdoCacheEnable == true) { - include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; + include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; /** * class for cache resource file tests @@ -27,7 +27,7 @@ if (PdoCacheEnable == true) { if (self::$init) { $this->getConnection(); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); $this->smarty->setCachingType('pdo'); $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/'); diff --git a/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php b/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php index 3017232c..5df30e25 100644 --- a/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php +++ b/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php @@ -7,7 +7,7 @@ */ if (PdoGzipCacheEnable == true) { - include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; + include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; /** * class for cache resource file tests @@ -25,7 +25,7 @@ if (PdoGzipCacheEnable == true) { if (self::$init) { $this->getConnection(); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); $this->smarty->setCachingType('pdo'); $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/'); diff --git a/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php b/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php index 8b03e7b3..8bd34941 100644 --- a/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php +++ b/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php @@ -6,7 +6,7 @@ * @author Uwe Tews */ if (MysqlCacheEnable == true) { - include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; + include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; /** * class for cache resource file tests @@ -25,10 +25,10 @@ if (MysqlCacheEnable == true) { if (self::$init) { $this->getConnection(); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); parent::setUp(); if (!class_exists('Smarty_CacheResource_Mysqltest', false)) { - require_once(dirname(__FILE__) . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php"); + require_once(__DIR__ . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php"); } $this->smarty->setCachingType('foobar'); $this->smarty->registerCacheResource('foobar', new Smarty_CacheResource_Mysqltest()); diff --git a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php index dc4c1cd7..a5361c18 100644 --- a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php +++ b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php @@ -17,8 +17,8 @@ class CacheResourceTestCommon extends PHPUnit_Smarty public function setUp(): void { - $this->smarty->setTemplateDir(dirname(__FILE__) . '/templates'); - $this->smarty->addPluginsDir(dirname(__FILE__) . '/PHPunitplugins'); + $this->smarty->setTemplateDir(__DIR__ . '/templates'); + $this->smarty->addPluginsDir(__DIR__ . '/PHPunitplugins'); $this->smarty->registerFilter('pre', array($this, 'compiledPrefilter')); } @@ -543,9 +543,9 @@ class CacheResourceTestCommon extends PHPUnit_Smarty { $this->smarty->setCaching(true); if ($folder == 0) { - $this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/a')); + $this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/a')); } else { - $this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/b')); + $this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/b')); } if ($merge) { $this->smarty->setCompileId(1); diff --git a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php index f59c0903..e28b35e8 100644 --- a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php +++ b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php @@ -17,7 +17,7 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php b/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php index 49bdcdf7..d359ba63 100644 --- a/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php +++ b/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php @@ -16,7 +16,7 @@ class AutoliteralTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); } diff --git a/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php b/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php index caa7f707..06d5c6f3 100644 --- a/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php +++ b/tests/UnitTests/Compiler/Delimiter/DelimiterTest.php @@ -17,7 +17,7 @@ class DelimiterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php b/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php index 1d0980ce..52308a20 100644 --- a/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php +++ b/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php @@ -20,7 +20,7 @@ class UserliteralTest extends PHPUnit_Smarty if (!property_exists('Smarty', 'literals')) { $this->markTestSkipped('user literal support'); } else { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } } diff --git a/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php b/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php index e311c003..7c358412 100644 --- a/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php +++ b/tests/UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php @@ -23,7 +23,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setForceCompile(true); } diff --git a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php index 70287c5d..b4a75439 100644 --- a/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php +++ b/tests/UnitTests/ConfigFileTests/file/ConfigVarTest.php @@ -22,7 +22,7 @@ class ConfigVarTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** @@ -387,7 +387,7 @@ class ConfigVarTest extends PHPUnit_Smarty public function testConfigResourceDb4() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); $this->smarty->configLoad('db4:foo.conf'); $this->assertEquals("bar", $this->smarty->fetch('foo.tpl')); } diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php index c3ba4e51..326dbfc2 100644 --- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php @@ -19,8 +19,8 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); - require_once dirname(__FILE__) . '/PHPunitplugins/resource.ambiguous.php'; + $this->setUpSmarty(__DIR__); + require_once __DIR__ . '/PHPunitplugins/resource.ambiguous.php'; // empty the template dir $this->smarty->setTemplateDir(array()); @@ -36,7 +36,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty protected function relative($path) { - $path = str_replace(dirname(__FILE__), '.', $path); + $path = str_replace(__DIR__, '.', $path); if (DIRECTORY_SEPARATOR == "\\") { $path = str_replace("\\", "/", $path); } @@ -46,7 +46,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty public function testNone() { - $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/'); $this->smarty->registerResource('ambiguous', $resource_handler); $this->smarty->setDefaultResourceType('ambiguous'); $this->smarty->setAllowAmbiguousResources(true); @@ -63,7 +63,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty */ public function testCase1() { - $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/'); $this->smarty->registerResource('ambiguous', $resource_handler); $this->smarty->setDefaultResourceType('ambiguous'); $this->smarty->setAllowAmbiguousResources(true); @@ -83,7 +83,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty */ public function testCase2() { - $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/'); $this->smarty->registerResource('ambiguous', $resource_handler); $this->smarty->setDefaultResourceType('ambiguous'); $this->smarty->setAllowAmbiguousResources(true); @@ -103,7 +103,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty */ public function testCaseSwitching() { - $resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/'); + $resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/'); $this->smarty->registerResource('ambiguous', $resource_handler); $this->smarty->setDefaultResourceType('ambiguous'); $this->smarty->setAllowAmbiguousResources(true); diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php index d32b0407..5e81a8c3 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php @@ -17,7 +17,7 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php index 526e90d0..6309eff9 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php @@ -23,7 +23,7 @@ if (MysqlResourceEnable == true) { if (self::$init) { $this->getConnection(); } - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("./PHPunitplugins/"); } diff --git a/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php b/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php index 6914dd06..64c7174b 100644 --- a/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php +++ b/tests/UnitTests/ResourceTests/DefaultHandler/DefaultTemplateHandlerTest.php @@ -17,7 +17,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setForceCompile(true); $this->smarty->disableSecurity(); } diff --git a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php index 867dfc19..d8cd146d 100644 --- a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php +++ b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php @@ -17,7 +17,7 @@ class EvalResourceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php index e5d8a718..0494ead0 100644 --- a/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php +++ b/tests/UnitTests/ResourceTests/Extends/ExtendsResourceTest.php @@ -17,7 +17,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->enableSecurity(); } diff --git a/tests/UnitTests/ResourceTests/File/FileResourceTest.php b/tests/UnitTests/ResourceTests/File/FileResourceTest.php index d5633fba..c4e8c069 100644 --- a/tests/UnitTests/ResourceTests/File/FileResourceTest.php +++ b/tests/UnitTests/ResourceTests/File/FileResourceTest.php @@ -17,7 +17,7 @@ class FileResourceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->enableSecurity(); } @@ -28,7 +28,7 @@ class FileResourceTest extends PHPUnit_Smarty protected function relative($path) { - $path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path)); + $path = str_replace(str_replace("\\", "/", __DIR__), '.', str_replace("\\", "/", $path)); return $path; } @@ -249,8 +249,8 @@ class FileResourceTest extends PHPUnit_Smarty public function testRelativeFetch() { $this->smarty->setTemplateDir(array( - dirname(__FILE__) . '/does-not-exist/', - dirname(__FILE__) . '/templates/sub/', + __DIR__ . '/does-not-exist/', + __DIR__ . '/templates/sub/', )); $this->smarty->security_policy = null; $this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl')); @@ -265,8 +265,8 @@ class FileResourceTest extends PHPUnit_Smarty public function testRelativeFetch2() { $this->smarty->setTemplateDir(array( - dirname(__FILE__) . '/does-not-exist/', - dirname(__FILE__) . '/templates/sub/', + __DIR__ . '/does-not-exist/', + __DIR__ . '/templates/sub/', )); $this->smarty->security_policy = null; $this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl')); @@ -281,12 +281,12 @@ class FileResourceTest extends PHPUnit_Smarty public function testRelativeFetchCwd() { $cwd = getcwd(); - chdir(dirname(__FILE__) . '/templates/sub/'); - $dn = dirname(__FILE__); + chdir(__DIR__ . '/templates/sub/'); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); $this->smarty->setTemplateDir(array( - dirname(__FILE__) . '/does-not-exist/', + __DIR__ . '/does-not-exist/', )); $this->smarty->security_policy = null; $this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl')); @@ -302,12 +302,12 @@ class FileResourceTest extends PHPUnit_Smarty public function testRelativeFetchCwd2() { $cwd = getcwd(); - chdir(dirname(__FILE__) . '/templates/sub/'); - $dn = dirname(__FILE__); + chdir(__DIR__ . '/templates/sub/'); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); $this->smarty->setTemplateDir(array( - dirname(__FILE__) . '/does-not-exist/', + __DIR__ . '/does-not-exist/', )); $this->smarty->security_policy = null; $this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl')); @@ -359,7 +359,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); $this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/',)); @@ -378,7 +378,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -409,7 +409,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -438,7 +438,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -458,7 +458,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -489,7 +489,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -507,7 +507,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -526,7 +526,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); @@ -560,7 +560,7 @@ class FileResourceTest extends PHPUnit_Smarty $this->smarty->security_policy = null; $cwd = getcwd(); - $dn = dirname(__FILE__); + $dn = __DIR__; $this->smarty->setCompileDir($dn . '/templates_c/'); $this->smarty->setCacheDir($dn . '/cache/'); $this->smarty->setTemplateDir(array( @@ -599,7 +599,7 @@ class FileResourceTest extends PHPUnit_Smarty * */ public function testSmartyCurrentDir() { - $dirname = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates'; + $dirname = __DIR__ . DIRECTORY_SEPARATOR . 'templates'; $this->assertEquals('current_dir = ' . $dirname, $this->smarty->fetch('001_smarty_current_dir.tpl')); } } diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php index 6b297458..1447ef09 100644 --- a/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php +++ b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php @@ -13,12 +13,12 @@ class FileIncludePathTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->use_include_path = true; $this->smarty->setTemplateDir(array('./templates', './templates_2', './include')); $this->smarty->enableSecurity(); $ds = DIRECTORY_SEPARATOR; - set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path()); + set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path()); } /** diff --git a/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php b/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php index 0650f799..5f8ed76f 100644 --- a/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php +++ b/tests/UnitTests/ResourceTests/FileIndexed/FileResourceIndexedTest.php @@ -13,11 +13,11 @@ class FileResourceIndexedTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); - $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_2'); + $this->setUpSmarty(__DIR__); + $this->smarty->addTemplateDir(__DIR__ . '/templates_2'); // note that 10 is a string! - $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_3', '10'); - $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_4', 'foo'); + $this->smarty->addTemplateDir(__DIR__ . '/templates_3', '10'); + $this->smarty->addTemplateDir(__DIR__ . '/templates_4', 'foo'); } public function testInit() diff --git a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php index c55cd647..fdb62085 100644 --- a/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php +++ b/tests/UnitTests/ResourceTests/Php/PhpResourceTest.php @@ -17,7 +17,7 @@ class PhpResourceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() @@ -27,7 +27,7 @@ class PhpResourceTest extends PHPUnit_Smarty protected function relative($path) { - $path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path)); + $path = str_replace(str_replace("\\", "/", __DIR__), '.', str_replace("\\", "/", $path)); return $path; } diff --git a/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php b/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php index d42786cb..1f62bc4c 100644 --- a/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php +++ b/tests/UnitTests/ResourceTests/Registered/RegisteredResourceTest.php @@ -18,7 +18,7 @@ class RegisteredResourceTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->registerResource("rr", new RegisteredResourceTest_Resource1()); } diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php b/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php index 17a136a6..9aa46718 100644 --- a/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/ResourcePluginTest.php @@ -17,7 +17,7 @@ class ResourcePluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php index 402f0226..57dbd9eb 100644 --- a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php +++ b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php @@ -17,7 +17,7 @@ class StreamResourceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->assign('foo', 'bar'); stream_wrapper_register("global", "ResourceStream") diff --git a/tests/UnitTests/ResourceTests/String/StringResourceTest.php b/tests/UnitTests/ResourceTests/String/StringResourceTest.php index b01e2925..35be632f 100644 --- a/tests/UnitTests/ResourceTests/String/StringResourceTest.php +++ b/tests/UnitTests/ResourceTests/String/StringResourceTest.php @@ -17,7 +17,7 @@ class StringResourceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } @@ -28,7 +28,7 @@ class StringResourceTest extends PHPUnit_Smarty protected function relative($path) { - $path = str_replace(dirname(__FILE__), '.', $path); + $path = str_replace(__DIR__, '.', $path); if (DIRECTORY_SEPARATOR == "\\") { $path = str_replace("\\", "/", $path); } diff --git a/tests/UnitTests/SecurityTests/FunctionTest.php b/tests/UnitTests/SecurityTests/FunctionTest.php index 30ba119b..30804b85 100644 --- a/tests/UnitTests/SecurityTests/FunctionTest.php +++ b/tests/UnitTests/SecurityTests/FunctionTest.php @@ -17,7 +17,7 @@ class FunctionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/SecurityTests/SecurityTest.php b/tests/UnitTests/SecurityTests/SecurityTest.php index 60d80d67..e1469a8d 100644 --- a/tests/UnitTests/SecurityTests/SecurityTest.php +++ b/tests/UnitTests/SecurityTests/SecurityTest.php @@ -17,7 +17,7 @@ class SecurityTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setForceCompile(true); $this->smarty->enableSecurity(); @@ -237,7 +237,7 @@ class SecurityTest extends PHPUnit_Smarty { $this->expectException('SmartyException'); $this->expectExceptionMessage('not trusted file path'); - $this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', dirname(__FILE__) . '/templates_3/')); + $this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', __DIR__ . '/templates_3/')); $this->smarty->fetch('string:{include file="templates_2/hello.tpl"}'); } diff --git a/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php b/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php index 5d63b654..a10744cd 100644 --- a/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php +++ b/tests/UnitTests/SmartyMethodsTests/Append/AppendTest.php @@ -17,7 +17,7 @@ class AppendTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php b/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php index abf074dc..0f6abe5e 100644 --- a/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php +++ b/tests/UnitTests/SmartyMethodsTests/AppendByRef/AppendByRefTest.php @@ -17,7 +17,7 @@ class AppendByRefTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** diff --git a/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php b/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php index fbe44365..75c4de76 100644 --- a/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php +++ b/tests/UnitTests/SmartyMethodsTests/Assign/AssignTest.php @@ -17,7 +17,7 @@ class AssignTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php b/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php index 789f2aa5..e6d01146 100644 --- a/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php +++ b/tests/UnitTests/SmartyMethodsTests/AssignByRef/AssignByRefTest.php @@ -17,7 +17,7 @@ class AssignByRefTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } /** diff --git a/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php index 62c5aca8..8f61b81d 100644 --- a/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php +++ b/tests/UnitTests/SmartyMethodsTests/AssignGlobal/AssignGlobalTest.php @@ -17,7 +17,7 @@ class AssignGlobalTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php index db273ffd..9363f323 100644 --- a/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php +++ b/tests/UnitTests/SmartyMethodsTests/ClearAllAssign/ClearAllAssignTest.php @@ -20,7 +20,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->assign('foo', 'foo'); $this->_data = $this->smarty->createData($this->smarty); diff --git a/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php index 7dd12d15..8d34c3e7 100644 --- a/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php +++ b/tests/UnitTests/SmartyMethodsTests/ClearAssign/ClearAssignTest.php @@ -17,7 +17,7 @@ class ClearAssignTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->assign('foo', 'foo'); $this->smarty->assign('bar', 'bar'); $this->smarty->assign('blar', 'blar'); diff --git a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php index 796ca360..0944928a 100644 --- a/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php +++ b/tests/UnitTests/SmartyMethodsTests/ClearCompiledTemplate/ClearCompiledTest.php @@ -19,7 +19,7 @@ class ClearCompiledTest extends PHPUnit_Smarty public $methodName = null; public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addTemplateDir('./templates_2/'); $this->methodName = 'clearCompiledTemplate'; } diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php index 35af56fb..0f356ff3 100644 --- a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php +++ b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php @@ -17,7 +17,7 @@ class GetTemplateVarsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php index b79ce9fa..dce15034 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php @@ -17,7 +17,7 @@ class RegisterBlockTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->disableSecurity(); } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php index 996e9067..62494be1 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php @@ -17,7 +17,7 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php index 478d1e71..29f44336 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php @@ -18,7 +18,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php index 4c76197c..50b25086 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php @@ -17,7 +17,7 @@ class RegisterModifierTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php index 94a8ef55..63a7b52d 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterObject/CompileRegisteredObjectFunctionTest.php @@ -17,7 +17,7 @@ class CompileRegisteredObjectFunctionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setForceCompile(true); $this->smarty->disableSecurity(); diff --git a/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php b/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php index 6712ddaf..92e0d9c7 100644 --- a/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php +++ b/tests/UnitTests/SmartyMethodsTests/TemplateExist/TemplateExistsTest.php @@ -17,7 +17,7 @@ class TemplateExistsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/Comments/CommentsTest.php b/tests/UnitTests/TemplateSource/Comments/CommentsTest.php index 4e01b845..b8bd2cc8 100644 --- a/tests/UnitTests/TemplateSource/Comments/CommentsTest.php +++ b/tests/UnitTests/TemplateSource/Comments/CommentsTest.php @@ -17,7 +17,7 @@ class CommentsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php b/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php index 5a0bbfeb..7f92fb03 100644 --- a/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php +++ b/tests/UnitTests/TemplateSource/Spacing/SpacingTest.php @@ -17,7 +17,7 @@ class SpacingTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php b/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php index aaaa1819..b3fbdb18 100644 --- a/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php +++ b/tests/UnitTests/TemplateSource/StaticClass/StaticClassAccessTest.php @@ -17,7 +17,7 @@ class StaticClassAccessTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->disableSecurity(); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php index 9fab4fae..4590982b 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php @@ -17,7 +17,7 @@ class CompileAppendTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php index fb02564f..d9be6c7c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php @@ -17,7 +17,7 @@ class CompileAssignTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php index 4a0480ec..1c3e8b2e 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php @@ -17,7 +17,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("./PHPunitplugins/"); $this->smarty->disableSecurity(); } diff --git a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php index 84eaf92a..99711a77 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BockExtend/CompileBlockExtendsTest.php @@ -17,7 +17,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); //$this->smarty->setMergeCompiledIncludes(true); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php b/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php index ae89049e..8c1c7d6d 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Capture/CompileCaptureTest.php @@ -17,7 +17,7 @@ class CompileCaptureTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addTemplateDir("./templates_tmp"); } diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php index 2f455656..68bfc45a 100644 --- a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/CompilerPluginTest.php @@ -17,7 +17,7 @@ class CompilerPluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } @@ -30,7 +30,7 @@ class CompilerPluginTest extends PHPUnit_Smarty */ public function testCompilerPlugin() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); $this->assertEquals('test output', $this->smarty->fetch('eval:{test data="test output"}{/test}')); } } diff --git a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php index f3d800a2..18cbe4cb 100644 --- a/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/ConfigLoad/CompileConfigLoadTest.php @@ -22,7 +22,7 @@ class CompileConfigLoadTest extends PHPUnit_Smarty */ public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php b/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php index 2efd06f6..1100beb8 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Delimiter/CompileDelimiterTest.php @@ -17,7 +17,7 @@ class CompileDelimiterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php b/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php index 1a979184..cd6d14bf 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Eval/CompileEvalTest.php @@ -17,7 +17,7 @@ class CompileEvalTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php b/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php index 289fd365..07137973 100644 --- a/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/For/CompileForTest.php @@ -17,7 +17,7 @@ class CompileForTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php index 845b6986..d0a496c8 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Foreach/CompileForeachTest.php @@ -17,7 +17,7 @@ class CompileForeachTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("./templates_tmp"); } diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php index e029dbf7..bb130b58 100644 --- a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php @@ -17,7 +17,7 @@ class CompileFunctionPluginTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); } diff --git a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php index addd9999..1fe73e9f 100644 --- a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php @@ -17,7 +17,7 @@ class CompileIfTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php index 69d3f69c..c9b1c154 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Include/CompileIncludeTest.php @@ -17,7 +17,7 @@ class CompileIncludeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("./templates_tmp"); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php b/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php index 6e608df9..e9a5328f 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php @@ -17,8 +17,8 @@ class CompileInsertTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->setUpSmarty(__DIR__); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); $this->smarty->enableSecurity(); } @@ -120,7 +120,7 @@ class CompileInsertTest extends PHPUnit_Smarty */ public function testInsertPluginCaching1_2() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); global $insertglobal; $insertglobal = 'changed global 2'; $this->smarty->caching = 1; @@ -138,7 +138,7 @@ class CompileInsertTest extends PHPUnit_Smarty */ public function testInsertPluginCaching1_3() { - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); global $insertglobal; $insertglobal = 'changed global'; $this->smarty->caching = 1; @@ -156,7 +156,7 @@ class CompileInsertTest extends PHPUnit_Smarty public function testInsertPluginCaching1_4() { global $insertglobal; - $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); + $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); $insertglobal = 'changed global 4'; $this->smarty->caching = 1; $this->smarty->assign('foo', 'buh', true); diff --git a/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php b/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php index 6cb608bd..64c9432c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Literal/LiteralTest.php @@ -17,7 +17,7 @@ class LiteralTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php index daf85774..ca520b9c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/MakeNocache/CompileMakeNocacheTest.php @@ -17,7 +17,7 @@ class CompileMakeNocacheTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php b/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php index 332e4919..5aea12b2 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Nocache/CompileNocacheTest.php @@ -17,7 +17,7 @@ class CompileNocacheTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php index 9ee5e315..854d2b4a 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php @@ -19,7 +19,7 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php index f4de02c6..13e9f3a3 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php @@ -17,7 +17,7 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php index 12aed25d..7deb4df7 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlCheckboxesTest.php @@ -6,7 +6,7 @@ * @author Rodney Rehm */ -require_once(dirname(__FILE__) . '/helpers/_object_tostring.php'); +require_once(__DIR__ . '/helpers/_object_tostring.php'); /** * class for modifier tests @@ -19,7 +19,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testAssociativeArray() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php index 039a5eec..7520f87c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlOptionsTest.php @@ -6,7 +6,7 @@ * @author Rodney Rehm */ -require_once(dirname(__FILE__) . '/helpers/_object_tostring.php'); +require_once(__DIR__ . '/helpers/_object_tostring.php'); /** * class for modifier tests @@ -19,7 +19,7 @@ class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testAssociativeArray() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php index 57a3ecc5..ac9046ba 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlRadiosTest.php @@ -6,7 +6,7 @@ * @author Rodney Rehm */ -require_once(dirname(__FILE__) . '/helpers/_object_tostring.php'); +require_once(__DIR__ . '/helpers/_object_tostring.php'); /** * class for modifier tests @@ -18,7 +18,7 @@ class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testAssociativeArray() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php index 0cf4f9ba..260ff45c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php @@ -209,7 +209,7 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setErrorReporting(E_ALL & ~E_DEPRECATED); $year = date('Y'); diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php index acef4694..1077b599 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectTimeTest.php @@ -17,7 +17,7 @@ class PluginFunctionHtmlSelectTimeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->now = mktime(16, 15, 11, 2, 20, 2011); } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php index 52b18ecc..792142c6 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php @@ -17,7 +17,7 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php index 59b34fa8..9fc10d75 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php @@ -17,7 +17,7 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php index d960b23e..423b593c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php @@ -17,7 +17,7 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testToLatin1() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php index df92c71a..14955ded 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php @@ -17,7 +17,7 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php index a1a055b3..1abd12b8 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php @@ -17,7 +17,7 @@ class PluginModifierCountSentencesTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php index c736356e..2bbcb573 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php @@ -14,7 +14,7 @@ class PluginModifierCountTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testArray() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php index 7684a39b..c6c1b543 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php @@ -17,7 +17,7 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierDefaultTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierDefaultTest.php index 34bc7f50..a2582011 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierDefaultTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierDefaultTest.php @@ -17,7 +17,7 @@ class PluginModifierDefaultTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php index 46a8297f..0782a01c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php @@ -17,7 +17,7 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testHtml() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php index b5fe9e41..06235551 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php @@ -16,7 +16,7 @@ class PluginModifierLowerTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php index ed263019..9b2c50b4 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php @@ -14,7 +14,7 @@ class PluginModifierNl2brTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php index b0fed84d..f0a79ffc 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php @@ -17,7 +17,7 @@ class PluginModifierRegexReplaceTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php index 55323845..79e2b1ce 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierSpacifyTest.php @@ -17,7 +17,7 @@ class PluginModifierSpacifyTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php index ef5bcfde..6a2d0966 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php @@ -14,7 +14,7 @@ class PluginModifierStrRepeatTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php index 4383f965..fbef16b0 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTest.php @@ -17,7 +17,7 @@ class PluginModifierStripTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php index a6105817..667fb7d7 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php @@ -17,7 +17,7 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php index 25716204..e3e4ac6b 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php @@ -17,7 +17,7 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testHtml() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php index d4bff113..84d35a7c 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php @@ -17,7 +17,7 @@ class PluginModifierUpperTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php index c65ab3a7..20b6f223 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php @@ -17,7 +17,7 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testDefault() diff --git a/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php index 9e422f34..bb196012 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Section/CompileSectionTest.php @@ -17,7 +17,7 @@ class CompileSectionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php b/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php index 1dcbaf37..e86f28fe 100644 --- a/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/SetFilter/CompileSetfilterTest.php @@ -17,7 +17,7 @@ class CompileSetfilterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php index ae9f0e69..5e26728d 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php @@ -17,7 +17,7 @@ class CompileStripTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("./templates_tmp"); } diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php index 61a08583..6d1da7f5 100644 --- a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php @@ -17,7 +17,7 @@ class CompileFunctionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php index a808aec9..984dd7bd 100644 --- a/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/While/CompileWhileTest.php @@ -17,7 +17,7 @@ class CompileWhileTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php b/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php index ad81d673..c6778469 100644 --- a/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/_Attributes/AttributeTest.php @@ -17,7 +17,7 @@ class AttributeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); } diff --git a/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php b/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php index 2f50ea31..05e1e160 100644 --- a/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/_Error/CompileErrorTest.php @@ -17,7 +17,7 @@ class CompileErrorTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php index b856a969..8d2b2fc6 100644 --- a/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/_Print/PrintTest.php @@ -17,7 +17,7 @@ class PrintTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php index e0a68ff6..c731e4d0 100644 --- a/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/break/CompileBreakTest.php @@ -17,7 +17,7 @@ class CompileBreakTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php b/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php index 67868bb8..75b1db85 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Array/ArrayTest.php @@ -17,7 +17,7 @@ class ArrayTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php index 20eed17b..d60a9a00 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/BoolenNull/BooleanNullTest.php @@ -17,7 +17,7 @@ class BooleanNullTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php index 4168a152..fd821a8c 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/ConstantTests/ConstantsTest.php @@ -21,7 +21,7 @@ class ConstantsTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } diff --git a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php index 653c2691..b6830230 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/DoubleQuoted/DoubleQuotedStringTest.php @@ -17,7 +17,7 @@ class DoubleQuotedStringTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php index b29d5beb..e4522e06 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php @@ -17,7 +17,7 @@ class MathTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->registerPlugin('modifier', 'sin', 'sin'); } diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php index 6578550f..065a4920 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php @@ -17,7 +17,7 @@ class ModifierTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addTemplateDir("./templates_tmp"); } diff --git a/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php index 4180dbac..502a2271 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Objects/ObjectVariableTest.php @@ -17,7 +17,7 @@ class ObjectVariableTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->setForceCompile(true); } diff --git a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php index c8f0f9ea..cf8970c5 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php @@ -19,7 +19,7 @@ class PhpFunctionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php index b55871bb..02919d93 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php @@ -17,7 +17,7 @@ class SingleQuotedStringTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php index 990d686b..08002c64 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Constant/SmartyConstantTest.php @@ -17,7 +17,7 @@ class SmartyConstantTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php index e6e3dc44..84bafb09 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php @@ -17,7 +17,7 @@ class CookieTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php index 0b1bd1d4..3cb1de4a 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Delimiter/SmartyDelimiterTest.php @@ -17,7 +17,7 @@ class SmartyDelimiterTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php index 07ba2677..40f85e59 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php @@ -17,7 +17,7 @@ class SmartyErrorTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php index ed7d6b35..4e5f5f50 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php @@ -17,7 +17,7 @@ class SmartyNowTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php index f924edb8..b7204666 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Post/PostTest.php @@ -17,7 +17,7 @@ class PostTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php index 4f24f4eb..0fb2fe38 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/TemplateObject/SmartyTemplateObjectTest.php @@ -17,7 +17,7 @@ class SmartyTemplateObjectTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php index 518e42f3..8e295824 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php @@ -17,7 +17,7 @@ class SmartyVersionTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php index 18560ba8..feca410e 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/Stream/StreamVariableTest.php @@ -17,7 +17,7 @@ class StreamVariableTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); stream_wrapper_register("var", "VariableStream") or die("Failed to register protocol"); diff --git a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php index 3e45a204..84843262 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Variables/VariableVariable/VariableVariableTest.php @@ -17,7 +17,7 @@ class VariableVariableTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php index c24ec2b3..8c0a7156 100644 --- a/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php +++ b/tests/UnitTests/TemplateSource/X_Scopes/ScopeTest.php @@ -17,7 +17,7 @@ class ScopeTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); diff --git a/tests/UnitTests/TemplateSource/Xml/XmlTest.php b/tests/UnitTests/TemplateSource/Xml/XmlTest.php index 78473284..542f2c41 100644 --- a/tests/UnitTests/TemplateSource/Xml/XmlTest.php +++ b/tests/UnitTests/TemplateSource/Xml/XmlTest.php @@ -17,7 +17,7 @@ class XmlTest extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->enableSecurity(); $this->smarty->setForceCompile(true); } diff --git a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php index 0634907b..caacbebd 100644 --- a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php @@ -17,7 +17,7 @@ class ModifierIssue327Test extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); $this->smarty->registerPlugin('modifier', 'substr', 'substr'); } diff --git a/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php index d6358a5c..5ea20027 100644 --- a/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/419/ExtendsIssue419Test.php @@ -17,7 +17,7 @@ class ExtendsIssue419Test extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php index 4a772789..e8104d5c 100644 --- a/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/422/NestedLoopIssue422Test.php @@ -19,7 +19,7 @@ class NestedLoopIssue422Test extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php index 1b0fbc06..7a9c6ab2 100644 --- a/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/428/SectionPropertiesShortSyntaxIssue428Test.php @@ -19,7 +19,7 @@ class SectionPropertiesShortSyntaxIssue428Test extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php b/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php index aafef311..7490c56b 100644 --- a/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php @@ -36,7 +36,7 @@ class MbSplitEncodingIssue549Test extends PHPUnit_Smarty } $this->charset = \Smarty::$_CHARSET; - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } protected function tearDown(): void diff --git a/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php index b1f34d39..6fcf32ac 100644 --- a/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php +++ b/tests/UnitTests/TemplateSource/_Issues/topic26878/NewlineSpacing.php @@ -17,7 +17,7 @@ class NewlineSpacing extends PHPUnit_Smarty { public function setUp(): void { - $this->setUpSmarty(dirname(__FILE__)); + $this->setUpSmarty(__DIR__); } public function testInit() diff --git a/utilities/BuildExpectedFiles.php b/utilities/BuildExpectedFiles.php index ee33a30d..5945a350 100644 --- a/utilities/BuildExpectedFiles.php +++ b/utilities/BuildExpectedFiles.php @@ -6,7 +6,7 @@ * Time: 23:58 */ $sysplugins = array(); -$iterator = new DirectoryIterator(dirname(__FILE__) . '/../libs/sysplugins'); +$iterator = new DirectoryIterator(__DIR__ . '/../libs/sysplugins'); foreach ($iterator as $file) { if (!$file->isDot() && 'php' == $file->getExtension()) { $filename = $file->getBasename(); @@ -14,16 +14,16 @@ foreach ($iterator as $file) { } } $plugins = array(); -$iterator = new DirectoryIterator(dirname(__FILE__) . '/../libs/plugins'); +$iterator = new DirectoryIterator(__DIR__ . '/../libs/plugins'); foreach ($iterator as $file) { if (!$file->isDot() && 'php' == $file->getExtension()) { $filename = $file->getBasename(); $plugins[ $filename ] = true; } } -$code = file_get_contents(dirname(__FILE__) . '/../libs/sysplugins/smarty_internal_testinstall.php'); +$code = file_get_contents(__DIR__ . '/../libs/sysplugins/smarty_internal_testinstall.php'); $expectedPlugins = '$expectedPlugins = ' . var_export($plugins, true); $code = preg_replace('#\$expectedPlugins =[^;]+#', $expectedPlugins, $code); $expectedSysplugins = '$expectedSysplugins = ' . var_export($sysplugins, true); $code = preg_replace('#\$expectedSysplugins =[^;]+#', $expectedSysplugins, $code); -file_put_contents(dirname(__FILE__) . '/../libs/sysplugins/smarty_internal_testinstall.php', $code); +file_put_contents(__DIR__ . '/../libs/sysplugins/smarty_internal_testinstall.php', $code); From 254b5cabeeab75e84ed71fc9b6c26c60866767c4 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Tue, 27 Sep 2022 12:21:01 +0200 Subject: [PATCH 29/30] Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. --- docs/appendixes/tips.md | 67 +---------------- .../language-syntax-attributes.md | 2 +- docs/designers/language-builtin-functions.md | 1 - .../language-function-assign.md | 1 - .../language-function-include-php.md | 74 ------------------- .../language-function-include.md | 4 +- .../advanced-features-security.md | 28 +------ docs/programmers/api-variables.md | 1 - .../api-variables/variable-php-handling.md | 21 ------ .../api-variables/variable-trusted-dir.md | 2 +- docs/programmers/smarty-constants.md | 3 +- lexer/smarty_internal_templatelexer.plex | 1 - libs/sysplugins/smarty_security.php | 29 -------- 13 files changed, 8 insertions(+), 226 deletions(-) delete mode 100644 docs/designers/language-builtin-functions/language-function-include-php.md delete mode 100644 docs/programmers/api-variables/variable-php-handling.md diff --git a/docs/appendixes/tips.md b/docs/appendixes/tips.md index b0ea40cc..cdcc56b1 100644 --- a/docs/appendixes/tips.md +++ b/docs/appendixes/tips.md @@ -188,67 +188,6 @@ See also [`{html_select_date}`](#language.function.html.select.date), [`date_format`](#language.modifier.date.format) and [`$smarty.now`](#language.variables.smarty.now), -WAP/WML {#tips.wap} -======= - -WAP/WML templates require a php [Content-Type -header](&url.php-manual;header) to be passed along with the template. -The easist way to do this would be to write a custom function that -prints the header. If you are using [caching](#caching), that won\'t -work so we\'ll do it using the [`{insert}`](#language.function.insert) -tag; remember `{insert}` tags are not cached! Be sure that there is -nothing output to the browser before the template, or else the header -may fail. - - - - - - -your Smarty template *must* begin with the insert tag : - - - {insert name=header content="Content-Type: text/vnd.wap.wml"} - - - - - - - - - - - -

- Welcome to WAP with Smarty! - Press OK to continue... -

-
- - -

- Pretty easy isn't it? -

-
-
- - - Componentized Templates {#tips.componentized.templates} ======================= @@ -259,7 +198,7 @@ Smarty object, [`assign()`](#api.assign) the variables and [`display()`](#api.display) the template. So lets say for example we have a stock ticker on our template. We would collect the stock data in our application, then assign these variables in the template and display -it. Now wouldn\'t it be nice if you could add this stock ticker to any +it. Now wouldn't it be nice if you could add this stock ticker to any application by merely including the template, and not worry about fetching the data up front? @@ -301,9 +240,7 @@ assigning it to a template variable. -See also [`{include_php}`](#language.function.include.php), -[`{include}`](#language.function.include) and -[`{php}`](#language.function.php). +See also: [`{include}`](#language.function.include). Obfuscating E-mail Addresses {#tips.obfuscating.email} ============================ diff --git a/docs/designers/language-basic-syntax/language-syntax-attributes.md b/docs/designers/language-basic-syntax/language-syntax-attributes.md index 0fa7c773..417ac972 100644 --- a/docs/designers/language-basic-syntax/language-syntax-attributes.md +++ b/docs/designers/language-basic-syntax/language-syntax-attributes.md @@ -3,7 +3,7 @@ Attributes {#language.syntax.attributes} Most of the [functions](#language.syntax.functions) take attributes that specify or modify their behavior. Attributes to Smarty functions are -much like HTML attributes. Static values don\'t have to be enclosed in +much like HTML attributes. Static values don't have to be enclosed in quotes, but it is required for literal strings. Variables with or without modifiers may also be used, and should not be in quotes. You can even use PHP function results, plugin results and complex expressions. diff --git a/docs/designers/language-builtin-functions.md b/docs/designers/language-builtin-functions.md index 6c0879d6..fa615555 100644 --- a/docs/designers/language-builtin-functions.md +++ b/docs/designers/language-builtin-functions.md @@ -16,7 +16,6 @@ Built-in Functions {#language.builtin.functions} - [{function}](./language-builtin-functions/language-function-function.md) - [{if},{elseif},{else}](./language-builtin-functions/language-function-if.md) - [{include}](./language-builtin-functions/language-function-include.md) -- [{include_php}](./language-builtin-functions/language-function-include.php) - [{insert}](./language-builtin-functions/language-function-insert.md) - [{ldelim},{rdelim}](./language-builtin-functions/language-function-ldelim.md) - [{literal}](./language-builtin-functions/language-function-literal.md) diff --git a/docs/designers/language-builtin-functions/language-function-assign.md b/docs/designers/language-builtin-functions/language-function-assign.md index 3d3615bf..e4d50d30 100644 --- a/docs/designers/language-builtin-functions/language-function-assign.md +++ b/docs/designers/language-builtin-functions/language-function-assign.md @@ -135,7 +135,6 @@ The following functions can also *optionally* assign template variables. [`{capture}`](#language.function.capture), [`{include}`](#language.function.include), -[`{include_php}`](#language.function.include.php), [`{insert}`](#language.function.insert), [`{counter}`](#language.function.counter), [`{cycle}`](#language.function.cycle), diff --git a/docs/designers/language-builtin-functions/language-function-include-php.md b/docs/designers/language-builtin-functions/language-function-include-php.md deleted file mode 100644 index 8fc074a2..00000000 --- a/docs/designers/language-builtin-functions/language-function-include-php.md +++ /dev/null @@ -1,74 +0,0 @@ -{include\_php} {#language.function.include.php} -============== - -> **Note** -> -> `{include_php}` is deprecated from Smarty, use registered plugins to -> properly insulate presentation from the application code. As of Smarty -> 3.1 the `{include_php}` tags are only available from [SmartyBC](#bc). - - Attribute Name Type Required Default Description - ---------------- --------- ---------- --------- ---------------------------------------------------------------------------------- - file string Yes *n/a* The name of the php file to include as absolute path - once boolean No *TRUE* whether or not to include the php file more than once if included multiple times - assign string No *n/a* The name of the variable that the output of include\_php will be assigned to - -**Option Flags:** - - Name Description - --------- ---------------------------------------- - nocache Disables caching of inluded PHP script - -`{include_php}` tags are used to include a php script in your template. -The path of the attribute `file` can be either absolute, or relative to -[`$trusted_dir`](#variable.trusted.dir). If security is enabled, then -the script must be located in the `$trusted_dir` path of the securty -policy. See the [Security](#advanced.features.security) section for -details. - -By default, php files are only included once even if called multiple -times in the template. You can specify that it should be included every -time with the `once` attribute. Setting once to FALSE will include the -php script each time it is included in the template. - -You can optionally pass the `assign` attribute, which will specify a -template variable name that the output of `{include_php}` will be -assigned to instead of displayed. - -The smarty object is available as `$_smarty_tpl->smarty` within the PHP -script that you include. - -The `load_nav.php` file: - - - query('select url, name from navigation order by name'); - $this->assign('navigation', $db->getRows()); - - ?> - - - -where the template is: - - - {* absolute path, or relative to $trusted_dir *} - {include_php file='/path/to/load_nav.php'} - {include_php '/path/to/load_nav.php'} {* short-hand *} - - {foreach item='nav' from=$navigation} - {$nav.name}
- {/foreach} - - - -See also [`{include}`](#language.function.include), -[`$trusted_dir`](#variable.trusted.dir), -[`{php}`](#language.function.php), -[`{capture}`](#language.function.capture), [template -resources](#resources) and [componentized -templates](#tips.componentized.templates) diff --git a/docs/designers/language-builtin-functions/language-function-include.md b/docs/designers/language-builtin-functions/language-function-include.md index 956d893e..512f14a3 100644 --- a/docs/designers/language-builtin-functions/language-function-include.md +++ b/docs/designers/language-builtin-functions/language-function-include.md @@ -188,7 +188,5 @@ current template. -See also [`{include_php}`](#language.function.include.php), -[`{insert}`](#language.function.insert), -[`{php}`](#language.function.php), [template resources](#resources) and +See also [`{insert}`](#language.function.insert), [template resources](#resources) and [componentized templates](#tips.componentized.templates). diff --git a/docs/programmers/advanced-features/advanced-features-security.md b/docs/programmers/advanced-features/advanced-features-security.md index 98817a43..15755b42 100644 --- a/docs/programmers/advanced-features/advanced-features-security.md +++ b/docs/programmers/advanced-features/advanced-features-security.md @@ -8,22 +8,6 @@ security compromises through the template language. The settings of the security policy are defined by properties of an instance of the Smarty\_Security class. These are the possible settings: -- `$php_handling` determines how Smarty to handle PHP code embedded in - templates. Possible values are: - - - Smarty::PHP\_PASSTHRU -\> echo PHP tags as they are - - - Smarty::PHP\_QUOTE -\> escape tags as entities - - - Smarty::PHP\_REMOVE -\> remove php tags - - - Smarty::PHP\_ALLOW -\> execute php tags - - The default value is Smarty::PHP\_PASSTHRU. - - If security is enabled the [`$php_handling`](#variable.php.handling) - setting of the Smarty object is not checked for security. - - `$secure_dir` is an array of template directories that are considered secure. [`$template_dir`](#variable.template.dir) concidered secure implicitly. The default is an empty array. @@ -31,7 +15,7 @@ instance of the Smarty\_Security class. These are the possible settings: - `$trusted_dir` is an array of all directories that are considered trusted. Trusted directories are where you keep php scripts that are executed directly from the templates with - [`{include_php}`](#language.function.include.php). The default is an + [`{insert}`](#language.function.insert.php). The default is an empty array. - `$trusted_uri` is an array of regular expressions matching URIs that @@ -110,12 +94,8 @@ instance of the Smarty\_Security class. These are the possible settings: super globals can be accessed by the template. The default is \"true\". -- `$allow_php_tag` is a boolean flag which controls if {php} and - {include\_php} tags can be used by the template. The default is - \"false\". - If security is enabled, no private methods, functions or properties of -static classes or assigned objects can be accessed (beginningwith +static classes or assigned objects can be accessed (beginning with \'\_\') by the template. To customize the security policy settings you can extend the @@ -128,8 +108,6 @@ Smarty\_Security class or create an instance of it. class My_Security_Policy extends Smarty_Security { // disable all PHP functions public $php_functions = null; - // remove PHP tags - public $php_handling = Smarty::PHP_REMOVE; // allow everthing as modifier public $php_modifiers = array(); } @@ -145,8 +123,6 @@ Smarty\_Security class or create an instance of it. $my_security_policy = new Smarty_Security($smarty); // disable all PHP functions $my_security_policy->php_functions = null; - // remove PHP tags - $my_security_policy->php_handling = Smarty::PHP_REMOVE; // allow everthing as modifier $my_security_policy->php_modifiers = array(); // enable security diff --git a/docs/programmers/api-variables.md b/docs/programmers/api-variables.md index 2fcf6e21..ee9c0761 100644 --- a/docs/programmers/api-variables.md +++ b/docs/programmers/api-variables.md @@ -39,7 +39,6 @@ them directly, or use the corresponding setter/getter methods. - [$left_delimiter](./api-variables/variable-left-delimiter.md) - [$locking_timeout](./api-variables/variable-locking-timeout.md) - [$merge_compiled_includes](./api-variables/variable-merge-compiled-includes.md) -- [$php_handling](./api-variables/variable-php-handling.md) - [$plugins_dir](./api-variables/variable-plugins-dir.md) - [$right_delimiter](./api-variables/variable-right-delimiter.md) - [$smarty_debug_id](./api-variables/variable-smarty-debug-id.md) diff --git a/docs/programmers/api-variables/variable-php-handling.md b/docs/programmers/api-variables/variable-php-handling.md deleted file mode 100644 index 574ea6d5..00000000 --- a/docs/programmers/api-variables/variable-php-handling.md +++ /dev/null @@ -1,21 +0,0 @@ -\$php\_handling {#variable.php.handling} -=============== - -This tells Smarty how to handle PHP code embedded in the templates. -There are four possible settings, the default being -`Smarty::PHP_PASSTHRU`. Note that this does NOT affect php code within -[`{php}{/php}`](#language.function.php) tags in the template. - -- `Smarty::PHP_PASSTHRU` - Smarty echos tags as-is. - -- `Smarty::PHP_QUOTE` - Smarty quotes the tags as html entities. - -- `Smarty::PHP_REMOVE` - Smarty removes the tags from the templates. - -- `Smarty::PHP_ALLOW` - Smarty will execute the tags as PHP code. - -> **Note** -> -> Embedding PHP code into templates is highly discouraged. Use [custom -> functions](#plugins.functions) or [modifiers](#plugins.modifiers) -> instead. diff --git a/docs/programmers/api-variables/variable-trusted-dir.md b/docs/programmers/api-variables/variable-trusted-dir.md index 3d1a308f..9720ae8a 100644 --- a/docs/programmers/api-variables/variable-trusted-dir.md +++ b/docs/programmers/api-variables/variable-trusted-dir.md @@ -5,4 +5,4 @@ array of all directories that are considered trusted. Trusted directories are where you keep php scripts that are executed directly from the templates with -[`{include_php}`](#language.function.include.php). +[`{insert}`](#language.function.insert.php). diff --git a/docs/programmers/smarty-constants.md b/docs/programmers/smarty-constants.md index 042ea5e3..de04e1b5 100644 --- a/docs/programmers/smarty-constants.md +++ b/docs/programmers/smarty-constants.md @@ -23,5 +23,4 @@ to determine the appropriate value automatically. If defined, the path -See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md) and -[`$php_handling constants`](./api-variables/variable-php-handling.md) +See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md). diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex index 67c840d7..2cd46df9 100644 --- a/lexer/smarty_internal_templatelexer.plex +++ b/lexer/smarty_internal_templatelexer.plex @@ -161,7 +161,6 @@ class Smarty_Internal_Templatelexer 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to', - 'PHP' => '" '"<", "==" ... logical operator', 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', 'SCOND' => '"is even" ... if condition', diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php index 42c2a766..974c6352 100644 --- a/libs/sysplugins/smarty_security.php +++ b/libs/sysplugins/smarty_security.php @@ -555,35 +555,6 @@ class Smarty_Security throw new SmartyException("URI '{$uri}' not allowed by security setting"); } - /** - * Check if directory of file resource is trusted. - * - * @param string $filepath - * - * @return boolean true if directory is trusted - * @throws SmartyException if PHP directory is not trusted - */ - public function isTrustedPHPDir($filepath) - { - if (empty($this->trusted_dir)) { - throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); - } - // check if index is outdated - if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { - $this->_php_resource_dir = array(); - $this->_trusted_dir = $this->trusted_dir; - foreach ((array)$this->trusted_dir as $directory) { - $directory = $this->smarty->_realpath($directory . '/', true); - $this->_php_resource_dir[ $directory ] = true; - } - } - $addPath = $this->_checkDir($filepath, $this->_php_resource_dir); - if ($addPath !== false) { - $this->_php_resource_dir = array_merge($this->_php_resource_dir, $addPath); - } - return true; - } - /** * Remove old directories and its sub folders, add new directories * From 1ff79c6c38a73253304f761a8b387598d084f11c Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Tue, 27 Sep 2022 12:24:08 +0200 Subject: [PATCH 30/30] Update changelog Closes #816 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80367524..333035ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799) - Using PHP functions as modifiers now triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813) +- Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. [#816](https://github.com/smarty-php/smarty/issues/816) ### Fixed - Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514)