Skip to content
Permalink
Browse files

Update failing cache tests.

Remove 'engine' from the settings in each engine. It provides no value
and is never referenced outside of tests.
  • Loading branch information...
markstory committed Aug 17, 2013
1 parent f074fd8 commit ab7082540c5b8c4c0bd9673e28f82f9b2d5654da
@@ -45,7 +45,6 @@ public function init($settings = array()) {
if (!isset($settings['prefix'])) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
$settings += array('engine' => __CLASS__);
parent::init($settings);
return function_exists('apc_dec');
}
@@ -75,7 +75,6 @@ class FileEngine extends CacheEngine {
*/
public function init($settings = array()) {
$settings += array(
'engine' => __CLASS__,
'path' => CACHE,
'prefix' => 'cake_',
'lock' => true,
@@ -70,7 +70,6 @@ public function init($settings = array()) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
$settings += array(
'engine' => __CLASS__,
'servers' => array('127.0.0.1'),
'compress' => false,
'persistent' => true
@@ -57,7 +57,6 @@ public function init($settings = array()) {
return false;
}
parent::init(array_merge(array(
'engine' => __CLASS__,
'prefix' => null,
'server' => '127.0.0.1',
'port' => 6379,
@@ -47,7 +47,6 @@ public function init($settings = array()) {
if (!isset($settings['prefix'])) {
$settings['prefix'] = Inflector::slug(APP_DIR) . '_';
}
$settings += array('engine' => __CLASS__);
parent::init($settings);
return function_exists('wincache_ucache_info');
}
@@ -51,7 +51,6 @@ class XcacheEngine extends CacheEngine {
public function init($settings = array()) {
if (php_sapi_name() !== 'cli') {
parent::init(array_merge(array(
'engine' => __CLASS__,
'prefix' => Inflector::slug(APP_DIR) . '_',
'PHP_AUTH_USER' => 'user',
'PHP_AUTH_PW' => 'password'
@@ -86,6 +86,7 @@ public function testReadAndWriteCache() {
* @return void
*/
public function testReadWriteDurationZero() {
Cache::drop('apc');
Cache::config('apc', ['engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_']);
Cache::write('zero', 'Should save', 'apc');
sleep(1);
@@ -47,7 +47,7 @@ public function setUp() {
Configure::write('Cache.disable', false);
Cache::config('file_test', [
'engine' => 'File',
'path' => CACHE
'path' => TMP . 'tests',
]);
}
@@ -57,12 +57,12 @@ public function setUp() {
* @return void
*/
public function tearDown() {
parent::tearDown();
Cache::clear(false, 'file_test');
Cache::drop('file_test');
Cache::drop('file_groups');
Cache::drop('file_groups2');
Cache::drop('file_groups3');
parent::tearDown();
}
/**
@@ -82,7 +82,7 @@ public function testReadAndWriteCache() {
$data = 'this is a test of the emergency broadcasting system';
$result = Cache::write('test', $data, 'file_test');
$this->assertTrue(file_exists(CACHE . 'cake_test'));
$this->assertTrue(file_exists(TMP . 'tests/cake_test'));
$result = Cache::read('test', 'file_test');
$expecting = $data;
@@ -162,6 +162,7 @@ public function testDeleteCache() {
* @return void
*/
public function testSerialize() {
Cache::drop('file_test');
Cache::config('file_test', ['engine' => 'File', 'serialize' => true]);
$data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test', $data, 'file_test');
@@ -181,6 +182,7 @@ public function testSerialize() {
* @return void
*/
public function testClear() {
Cache::drop('file_test');
Cache::config('file_test', ['engine' => 'File', 'duration' => 1]);
$data = 'this is a test of the emergency broadcasting system';
@@ -284,7 +286,7 @@ public function testClearWithNoKeys() {
public function testKeyPath() {
$result = Cache::write('views.countries.something', 'here', 'file_test');
$this->assertTrue($result);
$this->assertTrue(file_exists(CACHE . 'cake_views_countries_something'));
$this->assertTrue(file_exists(TMP . 'tests/cake_views_countries_something'));
$result = Cache::read('views.countries.something', 'file_test');
$this->assertEquals('here', $result);
@@ -349,13 +351,18 @@ public function testRemoveWindowsSlashesFromCache() {
* @return void
*/
public function testWriteQuotedString() {
Cache::config('file_test', array('engine' => 'File', 'path' => TMP . 'tests'));
Cache::write('App.doubleQuoteTest', '"this is a quoted string"', 'file_test');
$this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
$this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
Cache::config('file_test', array('isWindows' => true, 'path' => TMP . 'tests'));
Cache::drop('file_test');
Cache::config('file_test', array(
'className' => 'File',
'isWindows' => true,
'path' => TMP . 'tests'
));
$this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
$this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
@@ -371,14 +378,15 @@ public function testWriteQuotedString() {
public function testPathDoesNotExist() {
$this->skipIf(is_dir(TMP . 'tests' . DS . 'autocreate'), 'Cannot run if test directory exists.');
Cache::config('test', array(
Cache::drop('file_test');
Cache::config('file_test', array(
'engine' => 'File',
'path' => TMP . 'tests' . DS . 'autocreate'
'path' => TMP . 'tests/autocreate'
));
Cache::read('Test', 'test');
Cache::read('Test', 'file_test');
Cache::drop('test');
unlink(TMP . 'tests' . DS . 'autocreate');
$this->assertTrue(file_exists(TMP . 'tests/autocreate'), 'Dir should exist.');
unlink(TMP . 'tests/autocreate');
}
/**
@@ -391,7 +399,8 @@ public function testPathDoesNotExistDebugOff() {
$this->skipIf(is_dir(TMP . 'tests/autocreate'), 'Cannot run if test directory exists.');
Configure::write('debug', 0);
Cache::config('test', array(
Cache::drop('file_test');
Cache::config('file_test', array(
'engine' => 'File',
'duration' => '+1 year',
'prefix' => 'testing_invalid_',
@@ -26,7 +26,6 @@
/**
* Class TestMemcacheEngine
*
* @package Cake.Test.Case.Cache.Engine
*/
class TestMemcacheEngine extends MemcacheEngine {
@@ -64,7 +63,7 @@ public function setUp() {
Configure::write('Cache.disable', false);
Cache::config('memcache', array(
'engine' => 'Memcache',
'className' => 'Memcache',
'prefix' => 'cake_',
'duration' => 3600
));
@@ -97,7 +96,6 @@ public function testSettings() {
'servers' => array('127.0.0.1'),
'persistent' => true,
'compress' => false,
'engine' => 'Cake\Cache\Engine\MemcacheEngine',
'groups' => array()
);
$this->assertEquals($expecting, $settings);
@@ -378,6 +376,7 @@ public function testClear() {
* @return void
*/
public function testZeroDuration() {
Cache::drop('memcache');
Cache::config('memcache', [
'engine' => 'Memcache',
'prefix' => 'cake_',
@@ -67,7 +67,6 @@ public function testSettings() {
'duration' => 3600,
'probability' => 100,
'groups' => array(),
'engine' => 'Cake\Cache\Engine\RedisEngine',
'server' => '127.0.0.1',
'port' => 6379,
'timeout' => 0,
@@ -65,7 +65,6 @@ public function testSettings() {
'prefix' => 'cake_',
'duration' => 3600,
'probability' => 100,
'engine' => 'Xcache',
];
$this->assertTrue(isset($settings['PHP_AUTH_USER']));
$this->assertTrue(isset($settings['PHP_AUTH_PW']));

0 comments on commit ab70825

Please sign in to comment.
You can’t perform that action at this time.