From be86d1eb6d91a6b8e6e38cfe51b59a2dc0ecd3b0 Mon Sep 17 00:00:00 2001 From: uwetews Date: Tue, 23 Aug 2016 07:56:09 +0200 Subject: [PATCH] replace constant DS with DIRECTORY_SEPARATOR --- tests/PHPUnit_Smarty.php | 12 ++++++------ .../UnitTests/A_Core/LoadPlugin/IncludePathTest.php | 2 +- .../Custom/Ambiguous/CustomResourceAmbiguousTest.php | 2 +- .../Ambiguous/PHPunitplugins/resource.ambiguous.php | 4 ++-- .../FileIncludePath/FileIncludePathTest.php | 2 +- .../ResourceTests/String/StringResourceTest.php | 2 +- tests/UnitTests/SecurityTests/SecurityTest.php | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index f9eb066f..aa9bee8a 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -431,12 +431,12 @@ KEY `expire` (`expire`) public function normalizePath($path) { if ($path[ 0 ] == '.') { - $path = getcwd() . DS . $path; + $path = getcwd() . DIRECTORY_SEPARATOR . $path; } - $path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DS, $path); - while (strrpos($path, '.' . DS) !== false) { + $path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DIRECTORY_SEPARATOR, $path); + while (strrpos($path, '.' . DIRECTORY_SEPARATOR) !== false) { $path = - preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS, + preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DIRECTORY_SEPARATOR, $path); } return $path; @@ -489,7 +489,7 @@ KEY `expire` (`expire`) public function buildCompiledPath(Smarty_Internal_Template $tpl, $sub = true, $caching = false, $compile_id = null, $name = null, $type = null, $dir = null) { - $sep = DS; + $sep = DIRECTORY_SEPARATOR; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $sp = $this->buildSourcePath($tpl, $name, $type, $dir); $uid = $this->buildUid($tpl, $sp, $name, $type); @@ -553,7 +553,7 @@ KEY `expire` (`expire`) switch ($cacheType) { case 'file': case 'filetest': - $sep = DS; + $sep = DIRECTORY_SEPARATOR; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; $sp = $this->buildSourcePath($tpl, $name, $type, $dir); diff --git a/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php index 3dc4ab5f..b5beec20 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/IncludePathTest.php @@ -17,7 +17,7 @@ class IncludePathTest extends PHPUnit_Smarty $this->smarty->use_include_path = true; $this->smarty->setPluginsDir(array('./include','./include1')); $this->smarty->enableSecurity(); - $ds = DS; + $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()); } diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php index 8a72d45b..b16af7dc 100644 --- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php @@ -37,7 +37,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty protected function relative($path) { $path = str_replace(dirname(__FILE__), '.', $path); - if (DS == "\\") { + if (DIRECTORY_SEPARATOR == "\\") { $path = str_replace("\\", "/", $path); } diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php index 697a5c4e..f161844a 100644 --- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php @@ -13,7 +13,7 @@ class Smarty_Resource_Ambiguous extends Smarty_Internal_Resource_File public function __construct($directory) { - $this->directory = rtrim($directory, "/\\") . DS; + $this->directory = rtrim($directory, "/\\") . DIRECTORY_SEPARATOR; // parent::__construct(); } @@ -45,7 +45,7 @@ class Smarty_Resource_Ambiguous extends Smarty_Internal_Resource_File { $segment = ''; if ($this->segment) { - $segment = rtrim($this->segment, "/\\") . DS; + $segment = rtrim($this->segment, "/\\") . DIRECTORY_SEPARATOR; } $source->filepath = $this->directory . $segment . $source->name; diff --git a/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php index f92c46c9..81470ebc 100644 --- a/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php +++ b/tests/UnitTests/ResourceTests/FileIncludePath/FileIncludePathTest.php @@ -17,7 +17,7 @@ class FileIncludePathTest extends PHPUnit_Smarty $this->smarty->use_include_path = true; $this->smarty->setTemplateDir(array('./templates', './templates_2', './include')); $this->smarty->enableSecurity(); - $ds = DS; + $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()); } diff --git a/tests/UnitTests/ResourceTests/String/StringResourceTest.php b/tests/UnitTests/ResourceTests/String/StringResourceTest.php index c9798fe1..28bf13b1 100644 --- a/tests/UnitTests/ResourceTests/String/StringResourceTest.php +++ b/tests/UnitTests/ResourceTests/String/StringResourceTest.php @@ -29,7 +29,7 @@ class StringResourceTest extends PHPUnit_Smarty protected function relative($path) { $path = str_replace(dirname(__FILE__), '.', $path); - if (DS == "\\") { + if (DIRECTORY_SEPARATOR == "\\") { $path = str_replace("\\", "/", $path); } diff --git a/tests/UnitTests/SecurityTests/SecurityTest.php b/tests/UnitTests/SecurityTests/SecurityTest.php index a3edb867..5b3ff306 100644 --- a/tests/UnitTests/SecurityTests/SecurityTest.php +++ b/tests/UnitTests/SecurityTests/SecurityTest.php @@ -343,13 +343,13 @@ class SecurityTest extends PHPUnit_Smarty public function testChangedTrustedDirectory() { $this->smarty->security_policy->secure_dir = array( - '.' . DS . 'templates_2' . DS, + '.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR, ); $this->assertEquals("hello world", $this->smarty->fetch('eval:{include file="templates_2/hello.tpl"}')); $this->smarty->security_policy->secure_dir = array( - '.' . DS . 'templates_2' . DS, - '.' . DS . 'templates_3' . DS, + '.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR, + '.' . DIRECTORY_SEPARATOR . 'templates_3' . DIRECTORY_SEPARATOR, ); $this->assertEquals("templates_3", $this->smarty->fetch('eval:{include file="templates_3/dirname.tpl"}')); }