Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -2,19 +2,18 @@
/**
* ApcEngineTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache.Engine
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Cache', 'Cache');
@ -26,6 +25,13 @@ App::uses('Cache', 'Cache');
*/
class ApcEngineTest extends CakeTestCase {
/**
* APC extension to be used
*
* @var string
*/
protected $_apcExtension = 'apc';
/**
* setUp method
*
@ -33,7 +39,16 @@ class ApcEngineTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
$this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.');
$hasApc = extension_loaded('apc') || extension_loaded('apcu');
$this->skipIf(!$hasApc, 'Apc is not installed or configured properly.');
if (PHP_SAPI === 'cli') {
$this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.');
}
if (extension_loaded('apcu')) {
$this->_apcExtension = 'apcu';
}
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
@ -144,7 +159,8 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testDecrement() {
$this->skipIf(!function_exists('apc_dec'), 'No apc_dec() function, cannot test decrement().');
$hasSupport = function_exists('apc_dec') || function_exists('apcu_dec');
$this->skipIf(!$hasSupport, 'No apc_dec()/apcu_dec() function, cannot test decrement().');
$result = Cache::write('test_decrement', 5, 'apc');
$this->assertTrue($result);
@ -168,7 +184,8 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testIncrement() {
$this->skipIf(!function_exists('apc_inc'), 'No apc_inc() function, cannot test increment().');
$hasSupport = function_exists('apc_inc') || function_exists('apcu_inc');
$this->skipIf(!function_exists('apc_inc'), 'No apc_inc()/apcu_inc() function, cannot test increment().');
$result = Cache::write('test_increment', 5, 'apc');
$this->assertTrue($result);
@ -192,14 +209,18 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testClear() {
apc_store('not_cake', 'survive');
$storeFunc = $this->_apcExtension . '_store';
$fetchFunc = $this->_apcExtension . '_fetch';
$deleteFunc = $this->_apcExtension . '_delete';
$storeFunc('not_cake', 'survive');
Cache::write('some_value', 'value', 'apc');
$result = Cache::clear(false, 'apc');
$this->assertTrue($result);
$this->assertFalse(Cache::read('some_value', 'apc'));
$this->assertEquals('survive', apc_fetch('not_cake'));
apc_delete('not_cake');
$this->assertEquals('survive', $fetchFunc('not_cake'));
$deleteFunc('not_cake');
}
/**
@ -210,6 +231,7 @@ class ApcEngineTest extends CakeTestCase {
* @return void
*/
public function testGroupsReadWrite() {
$incFunc = $this->_apcExtension . '_inc';
Cache::config('apc_groups', array(
'engine' => 'Apc',
'duration' => 0,
@ -219,12 +241,12 @@ class ApcEngineTest extends CakeTestCase {
$this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups'));
$this->assertEquals('value', Cache::read('test_groups', 'apc_groups'));
apc_inc('test_group_a');
$incFunc('test_group_a');
$this->assertFalse(Cache::read('test_groups', 'apc_groups'));
$this->assertTrue(Cache::write('test_groups', 'value2', 'apc_groups'));
$this->assertEquals('value2', Cache::read('test_groups', 'apc_groups'));
apc_inc('test_group_b');
$incFunc('test_group_b');
$this->assertFalse(Cache::read('test_groups', 'apc_groups'));
$this->assertTrue(Cache::write('test_groups', 'value3', 'apc_groups'));
$this->assertEquals('value3', Cache::read('test_groups', 'apc_groups'));
@ -253,7 +275,7 @@ class ApcEngineTest extends CakeTestCase {
* Test clearing a cache group
*
* @return void
**/
*/
public function testGroupClear() {
Cache::config('apc_groups', array(
'engine' => 'Apc',
@ -270,4 +292,23 @@ class ApcEngineTest extends CakeTestCase {
$this->assertTrue(Cache::clearGroup('group_b', 'apc_groups'));
$this->assertFalse(Cache::read('test_groups', 'apc_groups'));
}
/**
* Test add method.
*
* @return void
*/
public function testAdd() {
Cache::delete('test_add_key', 'apc');
$result = Cache::add('test_add_key', 'test data', 'apc');
$this->assertTrue($result);
$expected = 'test data';
$result = Cache::read('test_add_key', 'apc');
$this->assertEquals($expected, $result);
$result = Cache::add('test_add_key', 'test data 2', 'apc');
$this->assertFalse($result);
}
}