Update test for 3.1.28 master

This commit is contained in:
uwetews
2015-10-24 04:12:28 +02:00
parent e4ed69f174
commit cee9d19fba
6 changed files with 28 additions and 27 deletions

View File

@@ -5,6 +5,7 @@
*/ */
include_once __DIR__ . '/Config.php'; include_once __DIR__ . '/Config.php';
/** /**
* Smarty Test Case Fixture * Smarty Test Case Fixture
*/ */
@@ -71,10 +72,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
* *
* @var array * @var array
*/ */
protected $backupStaticAttributesBlacklist = array( protected $backupStaticAttributesBlacklist = array('PHPUnit_Smarty' => array('config', 'pdo', 'init'),);
'PHPUnit_Smarty' => array('config', 'pdo', 'init'),
);
/** /**
* This method is called before the first test of this test class is run. * This method is called before the first test of this test class is run.
@@ -84,7 +82,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
{ {
error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
self::$init = true; self::$init = true;
} }
/** /**
* This method is called after the last test of this test class is run. * This method is called after the last test of this test class is run.
@@ -322,7 +320,7 @@ KEY `expire` (`expire`)
case 'file': case 'file':
case 'filetest': case 'filetest':
case 'php': case 'php':
return $this->normalizePath($dir . $name); return $this->normalizePath($dir . $name);
case 'mysqltest': case 'mysqltest':
case 'mysql': case 'mysql':
return sha1($type . ':' . $name); return sha1($type . ':' . $name);
@@ -371,17 +369,20 @@ KEY `expire` (`expire`)
* - remove /./ and /../ * - remove /./ and /../
* - make it absolute * - make it absolute
* *
* @param string $path file path * @param string $path file path
* *
* @return string * @return string
*/ */
public function normalizePath($path) { public function normalizePath($path)
{
if ($path[0] == '.') { if ($path[0] == '.') {
$path = getcwd() . DS . $path; $path = getcwd() . DS . $path;
} }
$path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DS, $path); $path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DS, $path);
while (strrpos($path, '.' . DS) !== false) { while (strrpos($path, '.' . DS) !== false) {
$path = preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS, $path); $path =
preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS,
$path);
} }
return $path; return $path;
} }
@@ -430,7 +431,8 @@ KEY `expire` (`expire`)
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public function buildCompiledPath(Smarty_Internal_Template $tpl, $sub = true, $caching = false, $compile_id = null, $name = null, $type = null, $dir = null) public function buildCompiledPath(Smarty_Internal_Template $tpl, $sub = true, $caching = false, $compile_id = null,
$name = null, $type = null, $dir = null)
{ {
$sep = DS; $sep = DS;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
@@ -438,18 +440,17 @@ KEY `expire` (`expire`)
$uid = $this->buildUid($tpl, $sp, $name, $type); $uid = $this->buildUid($tpl, $sp, $name, $type);
$_flag = ''; $_flag = '';
if (isset($tpl->source) && $tpl->source->isConfig) { if (isset($tpl->source) && $tpl->source->isConfig) {
$_flag = '_' . ((int) $tpl->smarty->config_read_hidden + (int) $tpl->smarty->config_booleanize * 2 $_flag = '_' . ((int) $tpl->smarty->config_read_hidden + (int) $tpl->smarty->config_booleanize * 2 +
+ (int) $tpl->smarty->config_overwrite * 4); (int) $tpl->smarty->config_overwrite * 4);
} else { } else {
$_flag = '_' . ((int) $tpl->smarty->merge_compiled_includes + (int) $tpl->smarty->escape_html * 2); $_flag = '_' . ((int) $tpl->smarty->merge_compiled_includes + (int) $tpl->smarty->escape_html * 2);
} }
$_filepath = $uid . $_flag; $_filepath = $uid . $_flag;
// if use_sub_dirs, break file into directories // if use_sub_dirs, break file into directories
if ($sub) { if ($sub) {
$_filepath = substr($_filepath, 0, 2) . $sep $_filepath =
. substr($_filepath, 2, 2) . $sep substr($_filepath, 0, 2) . $sep . substr($_filepath, 2, 2) . $sep . substr($_filepath, 4, 2) . $sep .
. substr($_filepath, 4, 2) . $sep $_filepath;
. $_filepath;
} }
$_compile_dir_sep = $sub ? $sep : '^'; $_compile_dir_sep = $sub ? $sep : '^';
if (isset($_compile_id)) { if (isset($_compile_id)) {
@@ -490,7 +491,8 @@ KEY `expire` (`expire`)
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public function buildCachedPath($tpl, $sub = true, $cache_id = null, $compile_id = null, $name = null, $type = null, $dir = null, $cacheType = null) public function buildCachedPath($tpl, $sub = true, $cache_id = null, $compile_id = null, $name = null, $type = null,
$dir = null, $cacheType = null)
{ {
$cacheType = isset($cacheType) ? $cacheType : $tpl->smarty->caching_type; $cacheType = isset($cacheType) ? $cacheType : $tpl->smarty->caching_type;
switch ($cacheType) { switch ($cacheType) {
@@ -504,10 +506,9 @@ KEY `expire` (`expire`)
$_filepath = $uid; $_filepath = $uid;
// if use_sub_dirs, break file into directories // if use_sub_dirs, break file into directories
if ($sub) { if ($sub) {
$_filepath = substr($_filepath, 0, 2) . $sep $_filepath =
. substr($_filepath, 2, 2) . $sep substr($_filepath, 0, 2) . $sep . substr($_filepath, 2, 2) . $sep . substr($_filepath, 4, 2) .
. substr($_filepath, 4, 2) . $sep $sep . $_filepath;
. $_filepath;
} }
$_compile_dir_sep = $sub ? $sep : '^'; $_compile_dir_sep = $sub ? $sep : '^';
if (isset($_cache_id)) { if (isset($_cache_id)) {
@@ -536,7 +537,6 @@ KEY `expire` (`expire`)
} }
} }
/** /**
* Tears down the fixture * Tears down the fixture
* This method is called after a test is executed. * This method is called after a test is executed.

View File

@@ -52,7 +52,7 @@ class FilterTest extends PHPUnit_Smarty
public function testLoadedOutputFilter() public function testLoadedOutputFilter()
{ {
$this->smarty->loadFilter(Smarty::FILTER_OUTPUT, 'trimwhitespace'); $this->smarty->loadFilter(Smarty::FILTER_OUTPUT, 'trimwhitespace');
$tpl = $this->smarty->createTemplate('eval:{" <br>hello world"}'); $tpl = $this->smarty->createTemplate('string:{" <br>hello world"}');
$this->assertEquals("<br>hello world", $this->smarty->fetch($tpl)); $this->assertEquals("<br>hello world", $this->smarty->fetch($tpl));
} }

View File

@@ -5,7 +5,7 @@
* *
* @package PHPunit * @package PHPunit
* @author Rodney Rehm * @author Rodney Rehm
* @runTestsInSeparateProcess * @run TestsInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @backupStaticAttributes enabled * @backupStaticAttributes enabled
*/ */

View File

@@ -30,7 +30,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
public function compiledPrefilter($text, Smarty_Internal_Template $tpl) public function compiledPrefilter($text, Smarty_Internal_Template $tpl)
{ {
return str_replace('#', $tpl->_getVariable('test'), $text); return str_replace('#', $tpl->getTemplateVars('test'), $text);
} }
/** /**

View File

@@ -28,7 +28,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
public function compiledPrefilter($text, Smarty_Internal_Template $tpl) public function compiledPrefilter($text, Smarty_Internal_Template $tpl)
{ {
return str_replace('#', $tpl->_getVariable('test'), $text); return str_replace('#', $tpl->getTemplateVars('test'), $text);
} }
/** /**

View File

@@ -23,7 +23,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
public function compiledPrefilter($text, Smarty_Internal_Template $tpl) public function compiledPrefilter($text, Smarty_Internal_Template $tpl)
{ {
return str_replace('#', $tpl->_getVariable('test'), $text); return str_replace('#', $tpl->getTemplateVars('test'), $text);
} }
public function testInit() public function testInit()
@@ -633,6 +633,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
/** /**
* test child/parent template chain * test child/parent template chain
*
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @dataProvider data * @dataProvider data