mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
new core functions
This commit is contained in:
@@ -3,19 +3,29 @@
|
||||
* This file is part of the Smarty PHPUnit tests.
|
||||
*
|
||||
*/
|
||||
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__), FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__), FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::CHILD_FIRST) as $path) {
|
||||
$p = $path->getPathname();
|
||||
if ((strpos($p, '\coverage') !== false) || ((strpos($p, '\templates_c') === false) && (strpos($p, '\cache') === false))) {
|
||||
if ((strpos($p, '\coverage') !== false) ||
|
||||
((strpos($p, '\templates_c') === false) && (strpos($p, '\cache\\') === false) &&
|
||||
(strpos($p, '\templates_tmp') === false))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$p = $path->getPathname();
|
||||
$i = 1;
|
||||
//$path->isDir() && !$path->isLink() ? rmdir($path->getPathname()) : unlink($path->getPathname());
|
||||
if ($path->isDir() && !$path->isLink()) {
|
||||
if (strpos($p, '\templates_tmp') !== false) {
|
||||
rmdir($path->getPathname());
|
||||
} else {
|
||||
touch($path->getPathname() . '/dummy.txt');
|
||||
}
|
||||
} else {
|
||||
unlink($path->getPathname());
|
||||
if (strpos($p, '\templates_tmp') === false) {
|
||||
touch($path->getPath() . '/dummy.txt');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -44,6 +44,13 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public static $init = true;
|
||||
|
||||
/**
|
||||
* Count test number
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $testNumber = 0;
|
||||
|
||||
/**
|
||||
* Configuration data from config.xml
|
||||
*
|
||||
@@ -70,7 +77,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $backupStaticAttributesBlacklist = array('PHPUnit_Smarty' => array('config', 'pdo', 'init'),);
|
||||
protected $backupStaticAttributesBlacklist = array('PHPUnit_Smarty' => array('config', 'pdo', 'init', 'testNumver'),);
|
||||
|
||||
/**
|
||||
* This method is called before the first test of this test class is run.
|
||||
@@ -89,6 +96,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
//self::$pdo = null;
|
||||
self::$testNumber = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +112,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
||||
define('individualFolders', true);
|
||||
}
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$this->backupStaticAttributesBlacklist[ get_class($this) ] = array('init', 'config', 'pdo');
|
||||
$this->backupStaticAttributesBlacklist[ get_class($this) ] = array('init', 'config', 'pdo', 'testNumber');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,6 +138,9 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
||||
if (!isset($s_dir[ $dir ])) {
|
||||
$this->cleanDir($dir . '/templates_c');
|
||||
$this->cleanDir($dir . '/cache');
|
||||
if (is_dir($dir . '/templates_tmp')) {
|
||||
$this->cleanDir($dir . '/templates_tmp');
|
||||
}
|
||||
$s_dir[ $dir ] = true;
|
||||
}
|
||||
$dir = dirname(__FILE__);
|
||||
@@ -230,6 +241,23 @@ KEY `expire` (`expire`)
|
||||
{
|
||||
$this->cleanCompileDir();
|
||||
$this->cleanCacheDir();
|
||||
if (is_dir(self::$cwd . '/templates_tmp')) {
|
||||
$this->cleanDir(self::$cwd . '/templates_tmp');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make temporary template file
|
||||
*
|
||||
*/
|
||||
public function makeTemplateFile($name, $code)
|
||||
{
|
||||
if (!is_dir(self::$cwd . '/templates_tmp')) {
|
||||
mkdir(self::$cwd . '/templates_tmp');
|
||||
chmod(self::$cwd . '/templates_tmp', 0775);
|
||||
}
|
||||
$fileName = self::$cwd . '/templates_tmp/' . "{$name}";
|
||||
file_put_contents($fileName, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,6 +337,22 @@ KEY `expire` (`expire`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all spaces
|
||||
*
|
||||
* @param string $in
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function strip($in)
|
||||
{
|
||||
if (is_string($in)) {
|
||||
return preg_replace('/\s/', '', $in);
|
||||
} else {
|
||||
return $in;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return source path
|
||||
*
|
||||
|
Reference in New Issue
Block a user