Compare commits

..

2 Commits

Author SHA1 Message Date
Simon Wisselink 965275d04f whitespace 2022-09-22 23:55:25 +02:00
Simon Wisselink 2aa0b3f855 Using PHP functions as modifiers now triggers a deprecation notice.
Fixes #813
2022-09-22 17:25:36 +02:00
177 changed files with 543 additions and 400 deletions
-3
View File
@@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799)
- Using PHP functions as modifiers now triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813)
- Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. [#816](https://github.com/smarty-php/smarty/issues/816)
### Fixed
- Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514)
@@ -18,8 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808)
- Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672)
- Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807)
- Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586)
- 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
+65 -2
View File
@@ -188,6 +188,67 @@ 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.
<?php
// be sure apache is configure for the .wml extensions!
// put this function somewhere in your application, or in Smarty.addons.php
function insert_header($params)
{
// this function expects $content argument
if (empty($params['content'])) {
return;
}
header($params['content']);
return;
}
?>
your Smarty template *must* begin with the insert tag :
{insert name=header content="Content-Type: text/vnd.wap.wml"}
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<!-- begin new wml deck -->
<wml>
<!-- begin first card -->
<card>
<do type="accept">
<go href="#two"/>
</do>
<p>
Welcome to WAP with Smarty!
Press OK to continue...
</p>
</card>
<!-- begin second card -->
<card id="two">
<p>
Pretty easy isn't it?
</p>
</card>
</wml>
Componentized Templates {#tips.componentized.templates}
=======================
@@ -198,7 +259,7 @@ Smarty object, [`assign()`](#api.assign) the variables and
[`display()`](#api.display) the template. So lets say for example we
have a stock ticker on our template. We would collect the stock data in
our application, then assign these variables in the template and display
it. Now wouldn't it be nice if you could add this stock ticker to any
it. Now wouldn\'t it be nice if you could add this stock ticker to any
application by merely including the template, and not worry about
fetching the data up front?
@@ -240,7 +301,9 @@ assigning it to a template variable.
See also: [`{include}`](#language.function.include).
See also [`{include_php}`](#language.function.include.php),
[`{include}`](#language.function.include) and
[`{php}`](#language.function.php).
Obfuscating E-mail Addresses {#tips.obfuscating.email}
============================
@@ -3,7 +3,7 @@ Attributes {#language.syntax.attributes}
Most of the [functions](#language.syntax.functions) take attributes that
specify or modify their behavior. Attributes to Smarty functions are
much like HTML attributes. Static values don't have to be enclosed in
much like HTML attributes. Static values don\'t have to be enclosed in
quotes, but it is required for literal strings. Variables with or
without modifiers may also be used, and should not be in quotes. You can
even use PHP function results, plugin results and complex expressions.
@@ -16,6 +16,7 @@ Built-in Functions {#language.builtin.functions}
- [{function}](./language-builtin-functions/language-function-function.md)
- [{if},{elseif},{else}](./language-builtin-functions/language-function-if.md)
- [{include}](./language-builtin-functions/language-function-include.md)
- [{include_php}](./language-builtin-functions/language-function-include.php)
- [{insert}](./language-builtin-functions/language-function-insert.md)
- [{ldelim},{rdelim}](./language-builtin-functions/language-function-ldelim.md)
- [{literal}](./language-builtin-functions/language-function-literal.md)
@@ -135,6 +135,7 @@ The following functions can also *optionally* assign template variables.
[`{capture}`](#language.function.capture),
[`{include}`](#language.function.include),
[`{include_php}`](#language.function.include.php),
[`{insert}`](#language.function.insert),
[`{counter}`](#language.function.counter),
[`{cycle}`](#language.function.cycle),
@@ -0,0 +1,74 @@
{include\_php} {#language.function.include.php}
==============
> **Note**
>
> `{include_php}` is deprecated from Smarty, use registered plugins to
> properly insulate presentation from the application code. As of Smarty
> 3.1 the `{include_php}` tags are only available from [SmartyBC](#bc).
Attribute Name Type Required Default Description
---------------- --------- ---------- --------- ----------------------------------------------------------------------------------
file string Yes *n/a* The name of the php file to include as absolute path
once boolean No *TRUE* whether or not to include the php file more than once if included multiple times
assign string No *n/a* The name of the variable that the output of include\_php will be assigned to
**Option Flags:**
Name Description
--------- ----------------------------------------
nocache Disables caching of inluded PHP script
`{include_php}` tags are used to include a php script in your template.
The path of the attribute `file` can be either absolute, or relative to
[`$trusted_dir`](#variable.trusted.dir). If security is enabled, then
the script must be located in the `$trusted_dir` path of the securty
policy. See the [Security](#advanced.features.security) section for
details.
By default, php files are only included once even if called multiple
times in the template. You can specify that it should be included every
time with the `once` attribute. Setting once to FALSE will include the
php script each time it is included in the template.
You can optionally pass the `assign` attribute, which will specify a
template variable name that the output of `{include_php}` will be
assigned to instead of displayed.
The smarty object is available as `$_smarty_tpl->smarty` within the PHP
script that you include.
The `load_nav.php` file:
<?php
// load in variables from a mysql db and assign them to the template
require_once('database.class.php');
$db = new Db();
$db->query('select url, name from navigation order by name');
$this->assign('navigation', $db->getRows());
?>
where the template is:
{* absolute path, or relative to $trusted_dir *}
{include_php file='/path/to/load_nav.php'}
{include_php '/path/to/load_nav.php'} {* short-hand *}
{foreach item='nav' from=$navigation}
<a href="{$nav.url}">{$nav.name}</a><br />
{/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)
@@ -188,5 +188,7 @@ current template.
See also [`{insert}`](#language.function.insert), [template resources](#resources) and
See also [`{include_php}`](#language.function.include.php),
[`{insert}`](#language.function.insert),
[`{php}`](#language.function.php), [template resources](#resources) and
[componentized templates](#tips.componentized.templates).
@@ -1,43 +1,41 @@
# capitalize (modifier)
capitalize {#language.modifier.capitalize}
==========
This is used to capitalize the first letter of all words in a variable.
This is similar to the PHP [`ucwords()`](&url.php-manual;ucwords)
function.
## Parameters
Parameter Position Type Required Default Description
-------------------- --------- ---------- --------- -----------------------------------------------------------------------------------------------------------
1 boolean No FALSE This determines whether or not words with digits will be uppercased
2 boolean No FALSE This determines whether or not Capital letters within words should be lowercased, e.g. \"aAa\" to \"Aaa\"
| Position | Type | Required | Default | Description |
|----------|---------|----------|---------|-------------------------------------------------------------------------------------------------------|
| 1 | boolean | No | False | This determines whether or not words with digits will be uppercased. |
| 2 | boolean | No | False | This determines whether or not Capital letters within words should be lowercased, e.g. "aAa" to "Aaa" |
## Example
<?php
PHP-script:
$smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
?>
```php
$smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
```
Where the template is:
```smarty
{$articleTitle}
{$articleTitle|capitalize}
{$articleTitle|capitalize:true}
```
Will output:
```
next x-men film, x3, delayed.
Next X-Men Film, x3, Delayed.
Next X-Men Film, X3, Delayed.
```
## See also
- [lower (modifier)](./language-modifier-lower.md)
- [upper (modifier)](./language-modifier-upper.md)
See also [`lower`](#language.modifier.lower) and
[`upper`](#language.modifier.upper)
@@ -1,26 +1,31 @@
# cat (modifier)
cat {#language.modifier.cat}
===
This value is concatenated to the given variable.
## Parameters
Parameter Position Type Required Default Description
-------------------- -------- ---------- --------- -----------------------------------------------
1 string No *empty* This value to catenate to the given variable.
| Position | Type | Required | Default | Description |
|----------|--------|----------|---------|-----------------------------------------------|
| 1 | string | No | *empty* | This value to catenate to the given variable. |
## Example
<?php
$smarty->assign('articleTitle', "Psychics predict world didn't end");
?>
PHP-script:
```php
$smarty->assign('articleTitle', "Psychics predict world didn't end");
```
Where template is:
```smarty
{$articleTitle|cat:' yesterday.'}
```
{$articleTitle|cat:' yesterday.'}
Will output:
```
Psychics predict world didn't end yesterday.
```
@@ -8,6 +8,22 @@ 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.
@@ -15,7 +31,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
[`{insert}`](#language.function.insert.php). The default is an
[`{include_php}`](#language.function.include.php). The default is an
empty array.
- `$trusted_uri` is an array of regular expressions matching URIs that
@@ -94,8 +110,12 @@ 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 (beginning with
static classes or assigned objects can be accessed (beginningwith
\'\_\') by the template.
To customize the security policy settings you can extend the
@@ -108,6 +128,8 @@ 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();
}
@@ -123,6 +145,8 @@ 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
+1
View File
@@ -39,6 +39,7 @@ 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)
@@ -0,0 +1,21 @@
\$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.
@@ -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
[`{insert}`](#language.function.insert.php).
[`{include_php}`](#language.function.include.php).
+2 -1
View File
@@ -23,4 +23,5 @@ to determine the appropriate value automatically. If defined, the path
See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md).
See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md) and
[`$php_handling constants`](./api-variables/variable-php-handling.md)
+1
View File
@@ -161,6 +161,7 @@ class Smarty_Internal_Templatelexer
'COMMENT' => 'comment',
'AS' => 'as',
'TO' => 'to',
'PHP' => '"<?php", "<%", "{php}" tag',
'LOGOP' => '"<", "==" ... logical operator',
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
'SCOND' => '"is even" ... if condition',
+2 -7
View File
@@ -5,11 +5,6 @@
* @package Smarty
*/
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
include __DIR__ . '/functions.php';
}
/**
* Smarty Autoloader
*
@@ -78,7 +73,7 @@ class Smarty_Autoloader
*/
public static function register($prepend = false)
{
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : __DIR__ . DIRECTORY_SEPARATOR;
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . 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);
@@ -94,7 +89,7 @@ class Smarty_Autoloader
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
return;
}
$_class = smarty_strtolower_ascii($class);
$_class = strtolower($class);
if (isset(self::$rootClasses[ $_class ])) {
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
if (is_file($file)) {
+2 -11
View File
@@ -36,7 +36,7 @@ if (!defined('SMARTY_DIR')) {
/**
*
*/
define('SMARTY_DIR', __DIR__ . DIRECTORY_SEPARATOR);
define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
}
/**
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
@@ -60,21 +60,12 @@ 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 __DIR__ . '/bootstrap.php';
include dirname(__FILE__) . '/bootstrap.php';
}
/**
* Load always needed external class files
*/
+1 -1
View File
@@ -11,6 +11,6 @@
* Load and register Smarty Autoloader
*/
if (!class_exists('Smarty_Autoloader')) {
include __DIR__ . '/Autoloader.php';
include dirname(__FILE__) . '/Autoloader.php';
}
Smarty_Autoloader::register(true);
-51
View File
@@ -1,51 +0,0 @@
<?php
/**
* This file is part of the Smarty package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Registers some helper/polyfill functions.
*/
const SMARTY_HELPER_FUNCTIONS_LOADED = true;
/**
* Converts the first characters in $string to uppercase (A-Z) if it is an ASCII lowercase character (a-z).
*
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
*
* @param $string
*
* @return string
*/
function smarty_ucfirst_ascii($string): string {
return smarty_strtoupper_ascii(substr($string, 0, 1)) . substr($string, 1);
}
/**
* Converts all uppercase ASCII characters (A-Z) in $string to lowercase (a-z).
*
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
*
* @param $string
*
* @return string
*/
function smarty_strtolower_ascii($string): string {
return strtr($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
}
/**
* Converts all lowercase ASCII characters (a-z) in $string to uppercase (A-Z).
*
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
*
* @param $string
*
* @return string
*/
function smarty_strtoupper_ascii($string): string {
return strtr($string, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
}
+2 -2
View File
@@ -205,11 +205,11 @@ abstract class Smarty_CacheResource
}
// try sysplugins dir
if (isset(self::$sysplugins[ $type ])) {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . smarty_ucfirst_ascii($type);
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
}
// try plugins dir
$cache_resource_class = 'Smarty_CacheResource_' . smarty_ucfirst_ascii($type);
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
if ($smarty->loadPlugin($cache_resource_class)) {
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
}
@@ -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 ][ smarty_strtolower_ascii($m) ] = true;
$this->matchResults[ $key ][ strtolower($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 = smarty_strtolower_ascii(trim($parameter[ 0 ], '"\''));
$tag = strtolower(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 ]) ? smarty_strtolower_ascii($compiler->getId($parameter[ 2 ])) : false;
$property = isset($parameter[ 2 ]) ? strtolower($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);
}
@@ -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 = smarty_strtolower_ascii($compiler->getId($_index[ 0 ]));
$variable = strtolower($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_' . smarty_ucfirst_ascii($variable);
$class = 'Smarty_Internal_Compile_' . ucfirst($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 = '$_' . smarty_strtoupper_ascii($variable);
$compiled_ref = '$_' . strtoupper($variable);
break;
case 'template':
return 'basename($_smarty_tpl->source->filepath)';
+2 -2
View File
@@ -210,7 +210,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
// copy the working dirs from application
$debObj->setCompileDir($smarty->getCompileDir());
// init properties by hand as user may have edited the original Smarty class
$debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ .
$debObj->setPluginsDir(is_dir(dirname(__FILE__) . '/../plugins') ? dirname(__FILE__) .
'/../plugins' : $smarty->getPluginsDir());
$debObj->force_compile = false;
$debObj->compile_check = Smarty::COMPILECHECK_ON;
@@ -221,7 +221,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debObj->debugging_ctrl = 'NONE';
$debObj->error_reporting = E_ALL & ~E_NOTICE;
$debObj->debug_tpl =
isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl';
isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . dirname(__FILE__) . '/../debug.tpl';
$debObj->registered_plugins = array();
$debObj->registered_resources = array();
$debObj->registered_filters = array();
@@ -88,19 +88,20 @@ class Smarty_Internal_Extension_Handler
$objType = $data->_objType;
$propertyType = false;
if (!isset($this->resolvedProperties[ $match[ 0 ] ][ $objType ])) {
$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
$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
)
)
)
);
);
if ($property !== false) {
if (property_exists($data, $property)) {
$propertyType = $this->resolvedProperties[ $match[ 0 ] ][ $objType ] = 1;
@@ -144,7 +145,7 @@ class Smarty_Internal_Extension_Handler
public function upperCase($name)
{
$_name = explode('_', $name);
$_name = array_map('smarty_ucfirst_ascii', $_name);
$_name = array_map('ucfirst', $_name);
return implode('_', $_name);
}
@@ -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 . smarty_strtolower_ascii($plugin_name) . '.php';
$file = SMARTY_SYSPLUGINS_DIR . strtolower($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 = smarty_strtolower_ascii($_plugin_filename);
$_lower_filename = strtolower($_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) {
@@ -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 = smarty_strtolower_ascii($name);
$func_name = strtolower($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('smarty_ucfirst_ascii', $_tag);
$_tag = array_map('ucfirst', $_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))
@@ -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(__DIR__ . '/../plugins');
$_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
$_core_plugins_available = false;
foreach ($smarty->getPluginsDir() as $plugin_dir) {
$_plugin_dir = $plugin_dir;
+2 -2
View File
@@ -76,11 +76,11 @@ abstract class Smarty_Resource
}
// try sysplugins dir
if (isset(self::$sysplugins[ $type ])) {
$_resource_class = 'Smarty_Internal_Resource_' . smarty_ucfirst_ascii($type);
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class();
}
// try plugins dir
$_resource_class = 'Smarty_Resource_' . smarty_ucfirst_ascii($type);
$_resource_class = 'Smarty_Resource_' . ucfirst($type);
if ($smarty->loadPlugin($_resource_class)) {
if (class_exists($_resource_class, false)) {
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class();
+2 -13
View File
@@ -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 . ':' . $this->generateSafeName($source->name);
$source->filepath = $source->type . ':' . substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25);
$source->uid = sha1($source->type . ':' . $source->name);
$mtime = $this->fetchTimestamp($source->name);
if ($mtime !== null) {
@@ -88,17 +88,6 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
*/
public function getBasename(Smarty_Template_Source $source)
{
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);
return basename(substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25));
}
}
+29
View File
@@ -555,6 +555,35 @@ 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
*
+3 -3
View File
@@ -6,9 +6,9 @@
/*
* Smarty PHPUnit Bootstrap
*/
require_once __DIR__ . '/Config.php';
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../libs/bootstrap.php';
require_once dirname(__FILE__) . '/Config.php';
require_once dirname(__FILE__) . '/../vendor/autoload.php';
require_once dirname(__FILE__) . '/../libs/bootstrap.php';
require_once 'PHPUnit_Smarty.php';
if (!ini_get('date.timezone')) {
+7 -7
View File
@@ -128,7 +128,7 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
}
$s_dir[ $dir ] = true;
}
$dir = __DIR__;
$dir = dirname(__FILE__);
}
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(__DIR__ . '/templates_c');
$this->smarty->setCacheDir(__DIR__ . '/cache');
$this->smarty->setCompileDir(dirname(__FILE__) . '/templates_c');
$this->smarty->setCacheDir(dirname(__FILE__) . '/cache');
}
$this->getSmartyObj();
@@ -637,10 +637,10 @@ KEY `name` (`name`)
}
public static function getSmartyPluginsDir(){
if (is_dir(__DIR__ . '/../smarty/libs/plugins')) {
return __DIR__ . '/../smarty/libs/plugins';
} else if(is_dir(__DIR__ . '/../libs/plugins')) {
return __DIR__ . '/../libs/plugins';
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';
}
}
/**
@@ -17,7 +17,7 @@ class PathNormalizationTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testNormalizeToAbsolute() {
@@ -17,7 +17,7 @@ class PluginNormalizationTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testGetPluginsDefaultDir()
@@ -17,7 +17,7 @@ class TemplateNormalizationTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testGetTemplateDir()
@@ -17,7 +17,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/*
@@ -29,7 +29,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
$s = new Smarty();
$s->template_dir = './foo';
$d = $s->getTemplateDir();
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
}
public function testTemplateDirDirectRelativeExtends()
{
$s = new FolderT();
$d = $s->getTemplateDir();
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
}
public function testConfigDirDirectRelativeExtends()
{
$s = new FolderT();
$d = $s->getConfigDir();
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
}
public function testPluginDirDirectRelativeExtends()
{
$s = new FolderT();
$d = $s->getPluginsDir();
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'plug' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
}
public function testCompileDirDirectRelativeExtends()
{
$s = new FolderT();
$d = $s->getCompileDir();
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'comp' . DIRECTORY_SEPARATOR, $d);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
}
public function testCacheDirDirectRelativeExtends()
{
$s = new FolderT();
$d = $s->getCacheDir();
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, $d);
$this->assertEquals(dirname(__FILE__) . 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(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
}
}
@@ -15,7 +15,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class AutoEscapeTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->setEscapeHtml(true);
}
+1 -1
View File
@@ -18,7 +18,7 @@ class FilterTest extends PHPUnit_Smarty
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class LoadFilterTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -17,7 +17,7 @@ class RegisterFilterTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -17,7 +17,7 @@ class GetterSetterTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true);
$this->smarty->disableSecurity();
$this->smarty->registerDefaultPluginHandler('my_plugin_handler');
@@ -13,12 +13,12 @@ class IncludePathTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->use_include_path = true;
$this->smarty->setPluginsDir(array('./include','./include1'));
$this->smarty->enableSecurity();
$ds = DIRECTORY_SEPARATOR;
set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path());
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path());
}
/**
@@ -17,7 +17,7 @@ class LoadPluginTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -17,7 +17,7 @@ class PluginChainedLoadTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -27,7 +27,7 @@ class PluginChainedLoadTest extends PHPUnit_Smarty
public function testPluginChainedLoad()
{
$this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/");
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
$this->assertStringContainsString('from chain3', $this->smarty->fetch('test_plugin_chained_load.tpl'));
}
}
@@ -13,7 +13,7 @@ class SharedFunctionsTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -18,7 +18,7 @@ class HttpModifiedSinceTest extends PHPUnit_Smarty
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -5,7 +5,7 @@
* @package PHPunit
* @author Uwe Tews
*/
include_once __DIR__ . '/../Memcache/CacheResourceCustomMemcacheTest.php';
include_once dirname(__FILE__) . '/../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(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
$this->smarty->setCachingType('apc');
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
@@ -6,7 +6,7 @@
* @author Uwe Tews
*/
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource file tests
@@ -20,7 +20,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
$this->smarty->setCachingType('filetest');
}
@@ -6,7 +6,7 @@
* @author Uwe Tews
*/
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
include_once dirname(__FILE__) . '/../_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(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
$this->smarty->setCachingType('memcachetest');
}
@@ -7,7 +7,7 @@
*/
if (MysqlCacheEnable == true) {
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource file tests
@@ -28,7 +28,7 @@ if (MysqlCacheEnable == true) {
if (self::$init) {
$this->getConnection();
}
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
$this->smarty->setCachingType('mysqltest');
}
@@ -7,7 +7,7 @@
*/
if (PdoCacheEnable == true) {
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource file tests
@@ -27,7 +27,7 @@ if (PdoCacheEnable == true) {
if (self::$init) {
$this->getConnection();
}
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
$this->smarty->setCachingType('pdo');
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
@@ -7,7 +7,7 @@
*/
if (PdoGzipCacheEnable == true) {
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource file tests
@@ -25,7 +25,7 @@ if (PdoGzipCacheEnable == true) {
if (self::$init) {
$this->getConnection();
}
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
$this->smarty->setCachingType('pdo');
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
@@ -6,7 +6,7 @@
* @author Uwe Tews
*/
if (MysqlCacheEnable == true) {
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource file tests
@@ -25,10 +25,10 @@ if (MysqlCacheEnable == true) {
if (self::$init) {
$this->getConnection();
}
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
parent::setUp();
if (!class_exists('Smarty_CacheResource_Mysqltest', false)) {
require_once(__DIR__ . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php");
require_once(dirname(__FILE__) . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php");
}
$this->smarty->setCachingType('foobar');
$this->smarty->registerCacheResource('foobar', new Smarty_CacheResource_Mysqltest());
@@ -17,8 +17,8 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
public function setUp(): void
{
$this->smarty->setTemplateDir(__DIR__ . '/templates');
$this->smarty->addPluginsDir(__DIR__ . '/PHPunitplugins');
$this->smarty->setTemplateDir(dirname(__FILE__) . '/templates');
$this->smarty->addPluginsDir(dirname(__FILE__) . '/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(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/a'));
$this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/a'));
} else {
$this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/b'));
$this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/b'));
}
if ($merge) {
$this->smarty->setCompileId(1);
@@ -17,7 +17,7 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -16,7 +16,7 @@ class AutoliteralTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../__shared/PHPunitplugins/");
}
@@ -17,7 +17,7 @@ class DelimiterTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -20,7 +20,7 @@ class UserliteralTest extends PHPUnit_Smarty
if (!property_exists('Smarty', 'literals')) {
$this->markTestSkipped('user literal support');
} else {
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
}
@@ -23,7 +23,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true);
}
@@ -22,7 +22,7 @@ class ConfigVarTest extends PHPUnit_Smarty
*/
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -387,7 +387,7 @@ class ConfigVarTest extends PHPUnit_Smarty
public function testConfigResourceDb4()
{
$this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/");
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
$this->smarty->configLoad('db4:foo.conf');
$this->assertEquals("bar", $this->smarty->fetch('foo.tpl'));
}
@@ -19,8 +19,8 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
require_once __DIR__ . '/PHPunitplugins/resource.ambiguous.php';
$this->setUpSmarty(dirname(__FILE__));
require_once dirname(__FILE__) . '/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(__DIR__, '.', $path);
$path = str_replace(dirname(__FILE__), '.', $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(__DIR__ . '/templates/ambiguous/');
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/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(__DIR__ . '/templates/ambiguous/');
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/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(__DIR__ . '/templates/ambiguous/');
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/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(__DIR__ . '/templates/ambiguous/');
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/');
$this->smarty->registerResource('ambiguous', $resource_handler);
$this->smarty->setDefaultResourceType('ambiguous');
$this->smarty->setAllowAmbiguousResources(true);
@@ -17,7 +17,7 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -23,7 +23,7 @@ if (MysqlResourceEnable == true) {
if (self::$init) {
$this->getConnection();
}
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("./PHPunitplugins/");
}
@@ -17,7 +17,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true);
$this->smarty->disableSecurity();
}
@@ -17,7 +17,7 @@ class EvalResourceTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -17,7 +17,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->enableSecurity();
}
@@ -17,7 +17,7 @@ class FileResourceTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->enableSecurity();
}
@@ -28,7 +28,7 @@ class FileResourceTest extends PHPUnit_Smarty
protected function relative($path)
{
$path = str_replace(str_replace("\\", "/", __DIR__), '.', str_replace("\\", "/", $path));
$path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path));
return $path;
}
@@ -249,8 +249,8 @@ class FileResourceTest extends PHPUnit_Smarty
public function testRelativeFetch()
{
$this->smarty->setTemplateDir(array(
__DIR__ . '/does-not-exist/',
__DIR__ . '/templates/sub/',
dirname(__FILE__) . '/does-not-exist/',
dirname(__FILE__) . '/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(
__DIR__ . '/does-not-exist/',
__DIR__ . '/templates/sub/',
dirname(__FILE__) . '/does-not-exist/',
dirname(__FILE__) . '/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(__DIR__ . '/templates/sub/');
$dn = __DIR__;
chdir(dirname(__FILE__) . '/templates/sub/');
$dn = dirname(__FILE__);
$this->smarty->setCompileDir($dn . '/templates_c/');
$this->smarty->setCacheDir($dn . '/cache/');
$this->smarty->setTemplateDir(array(
__DIR__ . '/does-not-exist/',
dirname(__FILE__) . '/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(__DIR__ . '/templates/sub/');
$dn = __DIR__;
chdir(dirname(__FILE__) . '/templates/sub/');
$dn = dirname(__FILE__);
$this->smarty->setCompileDir($dn . '/templates_c/');
$this->smarty->setCacheDir($dn . '/cache/');
$this->smarty->setTemplateDir(array(
__DIR__ . '/does-not-exist/',
dirname(__FILE__) . '/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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__;
$dn = dirname(__FILE__);
$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 = __DIR__ . DIRECTORY_SEPARATOR . 'templates';
$dirname = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates';
$this->assertEquals('current_dir = ' . $dirname, $this->smarty->fetch('001_smarty_current_dir.tpl'));
}
}
@@ -13,12 +13,12 @@ class FileIncludePathTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$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(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path());
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path());
}
/**
@@ -13,11 +13,11 @@ class FileResourceIndexedTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->smarty->addTemplateDir(__DIR__ . '/templates_2');
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_2');
// note that 10 is a string!
$this->smarty->addTemplateDir(__DIR__ . '/templates_3', '10');
$this->smarty->addTemplateDir(__DIR__ . '/templates_4', 'foo');
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_3', '10');
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_4', 'foo');
}
public function testInit()
@@ -17,7 +17,7 @@ class PhpResourceTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -27,7 +27,7 @@ class PhpResourceTest extends PHPUnit_Smarty
protected function relative($path)
{
$path = str_replace(str_replace("\\", "/", __DIR__), '.', str_replace("\\", "/", $path));
$path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path));
return $path;
}
@@ -18,7 +18,7 @@ class RegisteredResourceTest extends PHPUnit_Smarty
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->registerResource("rr", new RegisteredResourceTest_Resource1());
}
@@ -17,7 +17,7 @@ class ResourcePluginTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class StreamResourceTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->assign('foo', 'bar');
stream_wrapper_register("global", "ResourceStream")
@@ -17,7 +17,7 @@ class StringResourceTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -28,7 +28,7 @@ class StringResourceTest extends PHPUnit_Smarty
protected function relative($path)
{
$path = str_replace(__DIR__, '.', $path);
$path = str_replace(dirname(__FILE__), '.', $path);
if (DIRECTORY_SEPARATOR == "\\") {
$path = str_replace("\\", "/", $path);
}
@@ -17,7 +17,7 @@ class FunctionTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class SecurityTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true);
$this->smarty->enableSecurity();
@@ -237,7 +237,7 @@ class SecurityTest extends PHPUnit_Smarty
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', __DIR__ . '/templates_3/'));
$this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', dirname(__FILE__) . '/templates_3/'));
$this->smarty->fetch('string:{include file="templates_2/hello.tpl"}');
}
@@ -17,7 +17,7 @@ class AppendTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -17,7 +17,7 @@ class AppendByRefTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -17,7 +17,7 @@ class AssignTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -17,7 +17,7 @@ class AssignByRefTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
/**
@@ -17,7 +17,7 @@ class AssignGlobalTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -20,7 +20,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->assign('foo', 'foo');
$this->_data = $this->smarty->createData($this->smarty);
@@ -17,7 +17,7 @@ class ClearAssignTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->assign('foo', 'foo');
$this->smarty->assign('bar', 'bar');
$this->smarty->assign('blar', 'blar');
@@ -19,7 +19,7 @@ class ClearCompiledTest extends PHPUnit_Smarty
public $methodName = null;
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addTemplateDir('./templates_2/');
$this->methodName = 'clearCompiledTemplate';
}
@@ -17,7 +17,7 @@ class GetTemplateVarsTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -17,7 +17,7 @@ class RegisterBlockTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->disableSecurity();
}
@@ -17,7 +17,7 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -18,7 +18,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class RegisterModifierTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -17,7 +17,7 @@ class CompileRegisteredObjectFunctionTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true);
$this->smarty->disableSecurity();
@@ -17,7 +17,7 @@ class TemplateExistsTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
@@ -17,7 +17,7 @@ class CommentsTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class SpacingTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
}
public function testInit()
@@ -17,7 +17,7 @@ class StaticClassAccessTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->disableSecurity();
}
@@ -17,7 +17,7 @@ class CompileAppendTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");
$this->smarty->addTemplateDir("../../../__shared/templates/");
$this->smarty->addTemplateDir("./templates_tmp");
@@ -17,7 +17,7 @@ class CompileAssignTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");
$this->smarty->addTemplateDir("../../../__shared/templates/");
$this->smarty->addTemplateDir("./templates_tmp");
@@ -17,7 +17,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("./PHPunitplugins/");
$this->smarty->disableSecurity();
}
@@ -17,7 +17,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
$this->setUpSmarty(dirname(__FILE__));
//$this->smarty->setMergeCompiledIncludes(true);
}

Some files were not shown because too many files have changed in this diff Show More