mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
updating file engine and test case
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7252 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
330992a8a3
commit
013e9889e5
3 changed files with 38 additions and 27 deletions
21
cake/libs/cache/file.php
vendored
21
cake/libs/cache/file.php
vendored
|
@ -77,13 +77,24 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function init($settings = array()) {
|
||||
parent::init(array_merge(array('engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> false, 'serialize'=> true), $settings));
|
||||
parent::init(array_merge(
|
||||
array(
|
||||
'engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> false,
|
||||
'serialize'=> true, 'isWindows' => false
|
||||
),
|
||||
$settings
|
||||
));
|
||||
if(!isset($this->__File)) {
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
$this->__File =& new File($this->settings['path'] . DS . 'cake');
|
||||
}
|
||||
|
||||
if(substr(PHP_OS, 0, 3) == "WIN") {
|
||||
$this->settings['isWindows'] = true;
|
||||
}
|
||||
|
||||
$this->settings['path'] = $this->__File->Folder->cd($this->settings['path']);
|
||||
if(empty($this->settings['path'])) {
|
||||
return false;
|
||||
|
@ -120,16 +131,14 @@ class FileEngine extends CacheEngine {
|
|||
if ($duration == null) {
|
||||
$duration = $this->settings['duration'];
|
||||
}
|
||||
$windows = false;
|
||||
$lineBreak = "\n";
|
||||
|
||||
if (substr(PHP_OS, 0, 3) == "WIN") {
|
||||
if ($this->settings['isWindows']) {
|
||||
$lineBreak = "\r\n";
|
||||
$windows = true;
|
||||
}
|
||||
|
||||
if (!empty($this->settings['serialize'])) {
|
||||
if ($windows) {
|
||||
if ($this->settings['isWindows']) {
|
||||
$data = str_replace('\\', '\\\\\\\\', serialize($data));
|
||||
} else {
|
||||
$data = serialize($data);
|
||||
|
@ -169,7 +178,7 @@ class FileEngine extends CacheEngine {
|
|||
$data = $this->__File->read(true);
|
||||
|
||||
if ($data !== '' && !empty($this->settings['serialize'])) {
|
||||
if (substr(PHP_OS, 0, 3) == "WIN") {
|
||||
if ($this->settings['isWindows']) {
|
||||
$data = str_replace('\\\\\\\\', '\\', $data);
|
||||
}
|
||||
$data = unserialize($data);
|
||||
|
|
40
cake/tests/cases/libs/cache/file.test.php
vendored
40
cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -29,6 +29,9 @@
|
|||
if (!class_exists('Cache')) {
|
||||
require LIBS . 'cache.php';
|
||||
}
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
|
@ -38,14 +41,14 @@ if (!class_exists('Cache')) {
|
|||
class FileEngineTest extends CakeTestCase {
|
||||
/**
|
||||
* config property
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $config = array();
|
||||
/**
|
||||
* start method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -55,7 +58,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* end method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -64,7 +67,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testCacheDirChange method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -79,7 +82,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testReadAndWriteCache method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -106,7 +109,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testExpiry method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -133,7 +136,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testDeleteCache method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -152,7 +155,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testSerialize method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -176,7 +179,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testClear method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -269,7 +272,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testKeyPath method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -286,18 +289,14 @@ class FileEngineTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testRemoveWindowsSlashesFromCache method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRemoveWindowsSlashesFromCache() {
|
||||
$File = new File(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'tmp' . DS . 'dir_map');
|
||||
$File->read(11);
|
||||
Cache::engine('File', array('isWindows' => true, 'prefix' => null, 'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'tmp'));
|
||||
|
||||
$data = $File->read(true);
|
||||
$data = str_replace('\\\\\\\\', '\\', $data);
|
||||
$data = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $data);
|
||||
$data = unserialize($data);
|
||||
$data = Cache::read('dir_map');
|
||||
|
||||
$expected = array (
|
||||
'C:\dev\prj2\sites\cake\libs' => array(
|
||||
|
@ -327,10 +326,9 @@ class FileEngineTest extends CakeTestCase {
|
|||
'C:\dev\prj2\sites\main_site\views\helpers' => array(
|
||||
0 => 'C:\dev\prj2\sites\main_site\views\helpers'));
|
||||
|
||||
$File->close();
|
||||
$this->assertEqual($expected, $data);
|
||||
}
|
||||
|
||||
|
||||
function testWriteQuotedString() {
|
||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
||||
Cache::write('App.doubleQuoteTest', '"this is a quoted string"');
|
||||
|
@ -338,6 +336,10 @@ class FileEngineTest extends CakeTestCase {
|
|||
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
|
||||
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
|
||||
|
||||
Cache::engine('File', array('isWindows' => true, 'path' => TMP . 'tests'));
|
||||
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
|
||||
Cache::write('App.singleQuoteTest', "'this is a quoted string'");
|
||||
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,2 +1,2 @@
|
|||
1205865293
|
||||
a:4:{s:27:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs";a:24:{i:0;s:27:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs";i:1;s:32:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view";i:2;s:42:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\scaffolds";i:3;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\pages";i:4;s:40:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts";i:5;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\xml";i:6;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\rss";i:7;s:43:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\js";i:8;s:46:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email";i:9;s:51:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\text";i:10;s:51:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\html";i:11;s:40:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\helpers";i:12;s:39:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\errors";i:13;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements";i:14;s:47:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email";i:15;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\text";i:16;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\html";i:17;s:33:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model";i:18;s:45:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\datasources";i:19;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:20;s:43:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\behaviors";i:21;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\controller";i:22;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\controller\\\\components";i:23;s:33:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\cache";}s:35:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors";a:7:{i:0;s:35:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors";i:1;s:42:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells";i:2;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\templates";i:3;s:64:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\templates\\\\cdc_project";i:4;s:48:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\tasks";i:5;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\js";i:6;s:39:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\css";}s:25:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors";a:10:{i:0;s:25:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors";i:1;s:36:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest";i:2;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test";i:3;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test\\\\support";i:4;s:59:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test\\\\support\\\\collector";i:5;s:47:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\extensions";i:6;s:55:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\extensions\\\\testdox";i:7;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs";i:8;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs\\\\fr";i:9;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs\\\\en";}s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\views\\\\helpers";a:1:{i:0;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\views\\\\helpers";}}
|
||||
1845415352
|
||||
a:4:{s:27:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs";a:24:{i:0;s:27:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs";i:1;s:32:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view";i:2;s:42:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\scaffolds";i:3;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\pages";i:4;s:40:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts";i:5;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\xml";i:6;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\rss";i:7;s:43:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\js";i:8;s:46:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email";i:9;s:51:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\text";i:10;s:51:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\html";i:11;s:40:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\helpers";i:12;s:39:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\errors";i:13;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements";i:14;s:47:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email";i:15;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\text";i:16;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\html";i:17;s:33:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model";i:18;s:45:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\datasources";i:19;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:20;s:43:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\behaviors";i:21;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\controller";i:22;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\controller\\\\components";i:23;s:33:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\cache";}s:35:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors";a:7:{i:0;s:35:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors";i:1;s:42:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells";i:2;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\templates";i:3;s:64:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\templates\\\\cdc_project";i:4;s:48:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\tasks";i:5;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\js";i:6;s:39:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\css";}s:25:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors";a:10:{i:0;s:25:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors";i:1;s:36:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest";i:2;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test";i:3;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test\\\\support";i:4;s:59:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test\\\\support\\\\collector";i:5;s:47:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\extensions";i:6;s:55:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\extensions\\\\testdox";i:7;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs";i:8;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs\\\\fr";i:9;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs\\\\en";}s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\views\\\\helpers";a:1:{i:0;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\views\\\\helpers";}}
|
||||
|
|
Loading…
Reference in a new issue