Skip to content

Commit b4df110

Browse files
committed
Update xcache tests
1 parent 2ed9ff9 commit b4df110

File tree

1 file changed

+40
-47
lines changed

1 file changed

+40
-47
lines changed

lib/Cake/Test/TestCase/Cache/Engine/XcacheEngineTest.php

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
<?php
22
/**
3-
* XcacheEngineTest file
4-
*
5-
* PHP 5
6-
*
7-
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
3+
* CakePHP(tm) <http://book.cakephp.org/2.0/en/development/testing.html>
84
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
95
*
106
* Licensed under The MIT License
117
* Redistributions of files must retain the above copyright notice
128
*
139
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
1410
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
15-
* @package Cake.Test.Case.Cache.Engine
1611
* @since CakePHP(tm) v 1.2.0.5434
1712
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1813
*/
1914
namespace Cake\Test\TestCase\Cache\Engine;
15+
2016
use Cake\Cache\Cache;
2117
use Cake\Core\Configure;
2218
use Cake\TestSuite\TestCase;
@@ -38,9 +34,8 @@ public function setUp() {
3834
if (!function_exists('xcache_set')) {
3935
$this->markTestSkipped('Xcache is not installed or configured properly');
4036
}
41-
$this->_cacheDisable = Configure::read('Cache.disable');
4237
Configure::write('Cache.disable', false);
43-
Cache::config('xcache', array('engine' => 'Xcache', 'prefix' => 'cake_'));
38+
Configure::write('Cache.xcache', ['engine' => 'Xcache', 'prefix' => 'cake_']);
4439
}
4540

4641
/**
@@ -50,10 +45,8 @@ public function setUp() {
5045
*/
5146
public function tearDown() {
5247
parent::tearDown();
53-
Configure::write('Cache.disable', $this->_cacheDisable);
5448
Cache::drop('xcache');
5549
Cache::drop('xcache_groups');
56-
Cache::config('default');
5750
}
5851

5952
/**
@@ -63,12 +56,12 @@ public function tearDown() {
6356
*/
6457
public function testSettings() {
6558
$settings = Cache::settings();
66-
$expecting = array(
59+
$expecting = [
6760
'prefix' => 'cake_',
6861
'duration' => 3600,
6962
'probability' => 100,
7063
'engine' => 'Xcache',
71-
);
64+
];
7265
$this->assertTrue(isset($settings['PHP_AUTH_USER']));
7366
$this->assertTrue(isset($settings['PHP_AUTH_PW']));
7467

@@ -82,21 +75,21 @@ public function testSettings() {
8275
* @return void
8376
*/
8477
public function testReadAndWriteCache() {
85-
Cache::set(array('duration' => 1));
78+
Cache::set(['duration' => 1], 'xcache');
8679

87-
$result = Cache::read('test');
80+
$result = Cache::read('test', 'xcache');
8881
$expecting = '';
8982
$this->assertEquals($expecting, $result);
9083

9184
$data = 'this is a test of the emergency broadcasting system';
92-
$result = Cache::write('test', $data);
85+
$result = Cache::write('test', $data, 'xcache');
9386
$this->assertTrue($result);
9487

95-
$result = Cache::read('test');
88+
$result = Cache::read('test', 'xcache');
9689
$expecting = $data;
9790
$this->assertEquals($expecting, $result);
9891

99-
Cache::delete('test');
92+
Cache::delete('test', 'xcache');
10093
}
10194

10295
/**
@@ -105,26 +98,26 @@ public function testReadAndWriteCache() {
10598
* @return void
10699
*/
107100
public function testExpiry() {
108-
Cache::set(array('duration' => 1));
109-
$result = Cache::read('test');
101+
Cache::set(['duration' => 1], 'xcache');
102+
$result = Cache::read('test', 'xcache');
110103
$this->assertFalse($result);
111104

112105
$data = 'this is a test of the emergency broadcasting system';
113-
$result = Cache::write('other_test', $data);
106+
$result = Cache::write('other_test', $data, 'xcache');
114107
$this->assertTrue($result);
115108

116109
sleep(2);
117-
$result = Cache::read('other_test');
110+
$result = Cache::read('other_test', 'xcache');
118111
$this->assertFalse($result);
119112

120-
Cache::set(array('duration' => "+1 second"));
113+
Cache::set(['duration' => "+1 second"], 'xcache');
121114

122115
$data = 'this is a test of the emergency broadcasting system';
123-
$result = Cache::write('other_test', $data);
116+
$result = Cache::write('other_test', $data, 'xcache');
124117
$this->assertTrue($result);
125118

126119
sleep(2);
127-
$result = Cache::read('other_test');
120+
$result = Cache::read('other_test', 'xcache');
128121
$this->assertFalse($result);
129122
}
130123

@@ -135,10 +128,10 @@ public function testExpiry() {
135128
*/
136129
public function testDeleteCache() {
137130
$data = 'this is a test of the emergency broadcasting system';
138-
$result = Cache::write('delete_test', $data);
131+
$result = Cache::write('delete_test', $data, 'xcache');
139132
$this->assertTrue($result);
140133

141-
$result = Cache::delete('delete_test');
134+
$result = Cache::delete('delete_test', 'xcache');
142135
$this->assertTrue($result);
143136
}
144137

@@ -149,10 +142,10 @@ public function testDeleteCache() {
149142
*/
150143
public function testClearCache() {
151144
$data = 'this is a test of the emergency broadcasting system';
152-
$result = Cache::write('clear_test_1', $data);
145+
$result = Cache::write('clear_test_1', $data, 'xcache');
153146
$this->assertTrue($result);
154147

155-
$result = Cache::write('clear_test_2', $data);
148+
$result = Cache::write('clear_test_2', $data, 'xcache');
156149
$this->assertTrue($result);
157150

158151
$result = Cache::clear();
@@ -165,19 +158,19 @@ public function testClearCache() {
165158
* @return void
166159
*/
167160
public function testDecrement() {
168-
$result = Cache::write('test_decrement', 5);
161+
$result = Cache::write('test_decrement', 5, 'xcache');
169162
$this->assertTrue($result);
170163

171-
$result = Cache::decrement('test_decrement');
164+
$result = Cache::decrement('test_decrement', 'xcache');
172165
$this->assertEquals(4, $result);
173166

174-
$result = Cache::read('test_decrement');
167+
$result = Cache::read('test_decrement', 'xcache');
175168
$this->assertEquals(4, $result);
176169

177-
$result = Cache::decrement('test_decrement', 2);
170+
$result = Cache::decrement('test_decrement', 2, 'xcache');
178171
$this->assertEquals(2, $result);
179172

180-
$result = Cache::read('test_decrement');
173+
$result = Cache::read('test_decrement', 'xcache');
181174
$this->assertEquals(2, $result);
182175
}
183176

@@ -187,19 +180,19 @@ public function testDecrement() {
187180
* @return void
188181
*/
189182
public function testIncrement() {
190-
$result = Cache::write('test_increment', 5);
183+
$result = Cache::write('test_increment', 5, 'xcache');
191184
$this->assertTrue($result);
192185

193-
$result = Cache::increment('test_increment');
186+
$result = Cache::increment('test_increment', 'xcache');
194187
$this->assertEquals(6, $result);
195188

196-
$result = Cache::read('test_increment');
189+
$result = Cache::read('test_increment', 'xcache');
197190
$this->assertEquals(6, $result);
198191

199-
$result = Cache::increment('test_increment', 2);
192+
$result = Cache::increment('test_increment', 2, 'xcache');
200193
$this->assertEquals(8, $result);
201194

202-
$result = Cache::read('test_increment');
195+
$result = Cache::read('test_increment', 'xcache');
203196
$this->assertEquals(8, $result);
204197
}
205198

@@ -211,12 +204,12 @@ public function testIncrement() {
211204
* @return void
212205
*/
213206
public function testGroupsReadWrite() {
214-
Cache::config('xcache_groups', array(
207+
Configure::write('Cache.xcache_groups', [
215208
'engine' => 'Xcache',
216209
'duration' => 0,
217-
'groups' => array('group_a', 'group_b'),
210+
'groups' => ['group_a', 'group_b'],
218211
'prefix' => 'test_'
219-
));
212+
]);
220213
$this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
221214
$this->assertEquals('value', Cache::read('test_groups', 'xcache_groups'));
222215

@@ -237,12 +230,12 @@ public function testGroupsReadWrite() {
237230
* @return void
238231
*/
239232
public function testGroupDelete() {
240-
Cache::config('xcache_groups', array(
233+
Configure::write('Cache.xcache_groups', [
241234
'engine' => 'Xcache',
242235
'duration' => 0,
243-
'groups' => array('group_a', 'group_b'),
236+
'groups' => ['group_a', 'group_b'],
244237
'prefix' => 'test_'
245-
));
238+
]);
246239
$this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
247240
$this->assertEquals('value', Cache::read('test_groups', 'xcache_groups'));
248241
$this->assertTrue(Cache::delete('test_groups', 'xcache_groups'));
@@ -256,12 +249,12 @@ public function testGroupDelete() {
256249
* @return void
257250
**/
258251
public function testGroupClear() {
259-
Cache::config('xcache_groups', array(
252+
Configure::write('Cache.xcache_groups', [
260253
'engine' => 'Xcache',
261254
'duration' => 0,
262-
'groups' => array('group_a', 'group_b'),
255+
'groups' => ['group_a', 'group_b'],
263256
'prefix' => 'test_'
264-
));
257+
]);
265258

266259
$this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
267260
$this->assertTrue(Cache::clearGroup('group_a', 'xcache_groups'));

0 commit comments

Comments
 (0)