diff --git a/.gitattributes b/.gitattributes
index ca0450d8..c6644c99 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,11 +7,10 @@
# exclude from git export
/tests export-ignore
-/demo export-ignore
-/docs export-ignore
/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
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e27b60bf..449146c9 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
@@ -69,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/CHANGELOG.md b/CHANGELOG.md
index 9c58ff21..333035ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,32 @@ 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)
+- 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)
+- 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)
+- 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
+
+### 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 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)
+
## [4.2.0] - 2022-08-01
### Fixed
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 |
| ------- | ------------------ |
diff --git a/docker-compose.yml b/docker-compose.yml
index 8ba90328..d46608bf 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,10 +3,11 @@ services:
base:
build:
context: .
+ dockerfile: ./utilities/testrunners/php71/Dockerfile
volumes:
- .:/app
working_dir: /app
- entrypoint: sh ./utilities/testrunners/run-test.sh
+ entrypoint: sh ./run-tests.sh
php71:
extends:
service: base
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?
-
- {/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/Autoloader.php b/libs/Autoloader.php
index 9a8ffdaf..bf88bab4 100644
--- a/libs/Autoloader.php
+++ b/libs/Autoloader.php
@@ -5,6 +5,11 @@
* @package Smarty
*/
+
+if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
+ include __DIR__ . '/functions.php';
+}
+
/**
* Smarty Autoloader
*
@@ -48,7 +53,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);
@@ -64,7 +69,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 fefe9633..d1753dfe 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.
@@ -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 __DIR__ . '/functions.php';
+}
+
/**
* Load Smarty_Autoloader
*/
if (!class_exists('Smarty_Autoloader')) {
- include dirname(__FILE__) . '/bootstrap.php';
+ include __DIR__ . '/bootstrap.php';
}
+
/**
* Load always needed external class files
*/
@@ -98,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
- const SMARTY_VERSION = '4.2.0';
+ const SMARTY_VERSION = '4.2.1';
/**
* define variable scopes
*/
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/functions.php b/libs/functions.php
new file mode 100644
index 00000000..bac00e52
--- /dev/null
+++ b/libs/functions.php
@@ -0,0 +1,51 @@
+ $_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,41 +169,57 @@ 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 = $params[ '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/libs/plugins/function.mailto.php b/libs/plugins/function.mailto.php
index da5ea258..813c4731 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,15 +100,17 @@ 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 ]);
}
@@ -129,6 +137,6 @@ function smarty_function_mailto($params)
return '' . $text_encode . '';
} else {
// no encoding
- return '' . $text . '';
+ return $string;
}
}
diff --git a/libs/plugins/function.math.php b/libs/plugins/function.math.php
index 30d84810..88f42852 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/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php
index c5fc400a..2903d61d 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)
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/modifier.date_format.php b/libs/plugins/modifier.date_format.php
index 9ad898a9..43082a8a 100644
--- a/libs/plugins/modifier.date_format.php
+++ b/libs/plugins/modifier.date_format.php
@@ -79,6 +79,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
}
$format = str_replace($_win_from, $_win_to, $format);
}
+ // @ to suppress deprecation errors when running in PHP8.1 or higher.
return @strftime($format, $timestamp);
} else {
return date($format, $timestamp);
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/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 @@
+]*?>!', ' ', {$params[0]})";
+ return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')";
} else {
- return 'strip_tags(' . $params[ 0 ] . ')';
+ return 'strip_tags((string) ' . $params[ 0 ] . ')';
}
}
diff --git a/libs/plugins/modifiercompiler.strlen.php b/libs/plugins/modifiercompiler.strlen.php
new file mode 100644
index 00000000..d43e8ef1
--- /dev/null
+++ b/libs/plugins/modifiercompiler.strlen.php
@@ -0,0 +1,23 @@
+_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_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
index 9aa1c0e8..d036d21b 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;
}
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_modifier.php b/libs/sysplugins/smarty_internal_compile_private_modifier.php
index 72773fff..aea082f0 100644
--- a/libs/sysplugins/smarty_internal_compile_private_modifier.php
+++ b/libs/sysplugins/smarty_internal_compile_private_modifier.php
@@ -109,6 +109,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
if (!is_object($compiler->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_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_debug.php b/libs/sysplugins/smarty_internal_debug.php
index 02f8252b..59adf333 100644
--- a/libs/sysplugins/smarty_internal_debug.php
+++ b/libs/sysplugins/smarty_internal_debug.php
@@ -212,7 +212,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;
diff --git a/libs/sysplugins/smarty_internal_extension_handler.php b/libs/sysplugins/smarty_internal_extension_handler.php
index 2600f22e..5c2f338f 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_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 = '';
}
diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php
index 0ad053a6..e86f88bb 100644
--- a/libs/sysplugins/smarty_internal_template.php
+++ b/libs/sysplugins/smarty_internal_template.php
@@ -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;
diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php
index 7e0fe34e..006abc86 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();
}
diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php
index 0f0f8812..9191c6ff 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_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/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();
diff --git a/libs/sysplugins/smarty_resource_custom.php b/libs/sysplugins/smarty_resource_custom.php
index 5ff9d698..bdc1230f 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);
}
}
diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php
index cb48cf8b..bf8c6f70 100644
--- a/libs/sysplugins/smarty_security.php
+++ b/libs/sysplugins/smarty_security.php
@@ -104,7 +104,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.
@@ -327,7 +327,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)
@@ -554,35 +554,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
*
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
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/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 d68ac3d4..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();
@@ -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}'));
}
/**
@@ -234,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 7d72c73d..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();
}
@@ -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/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 59bd3cb8..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();
@@ -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/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 76b11052..4590982b 100644
--- a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php
@@ -17,10 +17,11 @@ 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");
+ $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..d9be6c7c 100644
--- a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php
@@ -17,10 +17,11 @@ 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");
+ $this->smarty->registerPlugin('modifier', 'var_export', 'var_export');
}
public function testInit()
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 595ff55c..1fe73e9f 100644
--- a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php
@@ -17,10 +17,11 @@ 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");
+ $this->smarty->registerPlugin('modifier', 'var_export', 'var_export');
}
public function testInit()
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 26ea6faa..260ff45c 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionHtmlSelectDateTest.php
@@ -209,8 +209,8 @@ class PluginFunctionHtmlSelectDateTest extends PHPUnit_Smarty
public function setUp(): void
{
- $this->setUpSmarty(dirname(__FILE__));
- $this->smarty->setErrorReporting(E_ALL & ~E_DEPRECATED);
+ $this->setUpSmarty(__DIR__);
+ $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";
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 bc5152a2..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()
@@ -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 = 'me@example.com"><h1>';
+ $this->smarty->assign('address', 'me@example.com">