Skip to content

Commit a0175ad

Browse files
committed
tests: removed deprecated ArrayAccess syntax
1 parent 689d648 commit a0175ad

24 files changed

+123
-142
lines changed

tests/Caching/Cache.save.phpt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ $dependencies = array(Cache::TAGS => 'tag');
2020

2121
$cache->save('key', 'value', $dependencies);
2222

23-
Assert::equal('value', $cache['key']['data']);
24-
Assert::equal($dependencies, $cache['key']['dependencies']);
23+
$res = $cache->load('key');
24+
Assert::equal('value', $res['data']);
25+
Assert::equal($dependencies, $res['dependencies']);
2526

2627

2728
// save callback return value
@@ -32,8 +33,9 @@ $cache->save('key', function() {
3233
return 'value';
3334
});
3435

35-
Assert::equal('value', $cache['key']['data']);
36-
Assert::equal(array(), $cache['key']['dependencies']);
36+
$res = $cache->load('key');
37+
Assert::equal('value', $res['data']);
38+
Assert::equal(array(), $res['dependencies']);
3739

3840

3941
// save callback return value with dependencies
@@ -45,5 +47,6 @@ $cache->save('key', function() {
4547
return 'value';
4648
}, $dependencies);
4749

48-
Assert::equal('value', $cache['key']['data']);
49-
Assert::equal($dependencies, $cache['key']['dependencies']);
50+
$res = $cache->load('key');
51+
Assert::equal('value', $res['data']);
52+
Assert::equal($dependencies, $res['dependencies']);

tests/Caching/DevNullStorage.phpt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,23 @@ $value = '"Hello World"';
1919
$cache = new Cache(new DevNullStorage, 'myspace');
2020

2121

22-
Assert::false( isset($cache[$key]) );
23-
24-
Assert::null( $cache[$key] );
22+
Assert::null( $cache->load($key) );
2523

2624

2725
// Writing cache...
28-
$cache[$key] = $value;
29-
30-
Assert::false( isset($cache[$key]) );
26+
$cache->save($key, $value);
3127

32-
Assert::notSame( $cache[$key], $value );
28+
Assert::null( $cache->load($key) );
3329

3430

35-
// Removing from cache using unset()...
36-
unset($cache[$key]);
31+
// Removing from cache using remove()...
32+
$cache->remove($key);
3733

38-
Assert::false( isset($cache[$key]) );
34+
Assert::null( $cache->load($key) );
3935

4036

4137
// Removing from cache using set NULL...
42-
$cache[$key] = $value;
43-
$cache[$key] = NULL;
38+
$cache->save($key, $value);
39+
$cache->save($key, NULL);
4440

45-
Assert::false( isset($cache[$key]) );
41+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.basic.phpt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,26 @@ $value = range("\x00", "\xFF");
1818

1919
$cache = new Cache(new FileStorage(TEMP_DIR));
2020

21-
Assert::false( isset($cache[$key]) );
22-
23-
Assert::null( $cache[$key] );
21+
Assert::null( $cache->load($key) );
2422

2523

2624
// Writing cache...
27-
$cache[$key] = $value;
28-
29-
Assert::true( isset($cache[$key]) );
25+
$cache->save($key, $value);
3026

31-
Assert::same( $cache[$key], $value );
27+
Assert::same( $cache->load($key), $value );
3228

3329

34-
// Removing from cache using unset()...
35-
unset($cache[$key]);
30+
// Removing from cache using remove()...
31+
$cache->remove($key);
3632

37-
Assert::false( isset($cache[$key]) );
33+
Assert::null( $cache->load($key) );
3834

3935

4036
// Removing from cache using set NULL...
41-
$cache[$key] = $value;
42-
$cache[$key] = NULL;
37+
$cache->save($key, $value);
38+
$cache->save($key, NULL);
4339

44-
Assert::false( isset($cache[$key]) );
40+
Assert::null( $cache->load($key) );
4541

4642

4743
// Writing cache...

tests/Caching/FileStorage.callbacks.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ $cache->save($key, $value, array(
2929
Cache::CALLBACKS => array(array('dependency', 1)),
3030
));
3131

32-
Assert::true( isset($cache[$key]) );
32+
Assert::truthy( $cache->load($key) );
3333

3434

3535
// Writing cache...
3636
$cache->save($key, $value, array(
3737
Cache::CALLBACKS => array(array('dependency', 0)),
3838
));
3939

40-
Assert::false( isset($cache[$key]) );
40+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.clean-all.phpt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,21 @@ $storage = new FileStorage(TEMP_DIR);
1616
$cacheA = new Cache($storage);
1717
$cacheB = new Cache($storage,'B');
1818

19-
$cacheA['test1'] = 'David';
20-
$cacheA['test2'] = 'Grudl';
21-
$cacheB['test1'] = 'divaD';
22-
$cacheB['test2'] = 'ldurG';
19+
$cacheA->save('test1', 'David');
20+
$cacheA->save('test2', 'Grudl');
21+
$cacheB->save('test1', 'divaD');
22+
$cacheB->save('test2', 'ldurG');
2323

2424
Assert::same( 'David Grudl divaD ldurG', implode(' ',array(
25-
$cacheA['test1'],
26-
$cacheA['test2'],
27-
$cacheB['test1'],
28-
$cacheB['test2'],
25+
$cacheA->load('test1'),
26+
$cacheA->load('test2'),
27+
$cacheB->load('test1'),
28+
$cacheB->load('test2'),
2929
)));
3030

3131
$storage->clean(array(Cache::ALL => TRUE));
3232

33-
Assert::null( $cacheA['test1'] );
34-
35-
Assert::null( $cacheA['test2'] );
36-
37-
Assert::null( $cacheB['test1'] );
38-
39-
Assert::null( $cacheB['test2'] );
33+
Assert::null( $cacheA->load('test1') );
34+
Assert::null( $cacheA->load('test2') );
35+
Assert::null( $cacheB->load('test1') );
36+
Assert::null( $cacheB->load('test2') );

tests/Caching/FileStorage.closure.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $value = range("\x00", "\xFF");
1818

1919
$cache = new Cache(new FileStorage(TEMP_DIR));
2020

21-
Assert::false( isset($cache[$key]) );
21+
Assert::null( $cache->load($key) );
2222

2323

2424
// Writing cache using Closure...
@@ -36,4 +36,4 @@ $cache->save($key, function() {
3636
return NULL;
3737
});
3838

39-
Assert::false( isset($cache[$key]) );
39+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.const.001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ $cache->save($key, $value, array(
2626
Cache::CONSTS => 'ANY_CONST',
2727
));
2828

29-
Assert::true( isset($cache[$key]) );
29+
Assert::truthy( $cache->load($key) );

tests/Caching/FileStorage.const.002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ $cache = new Cache(new FileStorage(TEMP_DIR));
2121

2222
// Deleting dependent const
2323

24-
Assert::false( isset($cache[$key]) );
24+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.expiration.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ $cache->save($key, $value, array(
2727
// Sleeping 1 second
2828
sleep(1);
2929
clearstatcache();
30-
Assert::true( isset($cache[$key]) );
30+
Assert::truthy( $cache->load($key) );
3131

3232

3333
// Sleeping 3 seconds
3434
sleep(3);
3535
clearstatcache();
36-
Assert::false( isset($cache[$key]) );
36+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.files.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ $cache->save($key, $value, array(
2929
),
3030
));
3131

32-
Assert::true( isset($cache[$key]) );
32+
Assert::truthy( $cache->load($key) );
3333

3434

3535
// Modifing dependent file
3636
file_put_contents($dependentFile, 'a');
3737

38-
Assert::false( isset($cache[$key]) );
38+
Assert::null( $cache->load($key) );
3939

4040

4141
// Writing cache...
4242
$cache->save($key, $value, array(
4343
Cache::FILES => $dependentFile,
4444
));
4545

46-
Assert::true( isset($cache[$key]) );
46+
Assert::truthy( $cache->load($key) );
4747

4848

4949
// Modifing dependent file
5050
sleep(2);
5151
file_put_contents($dependentFile, 'b');
5252
clearstatcache();
5353

54-
Assert::false( isset($cache[$key]) );
54+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.int.phpt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,23 @@ $value = range("\x00", "\xFF");
1818

1919
$cache = new Cache(new FileStorage(TEMP_DIR));
2020

21-
Assert::false( isset($cache[$key]) );
22-
23-
Assert::null( $cache[$key] );
21+
Assert::null( $cache->load($key) );
2422

2523

2624
// Writing cache...
27-
$cache[$key] = $value;
28-
29-
Assert::true( isset($cache[$key]) );
25+
$cache->save($key, $value);
3026

31-
Assert::same( $cache[$key], $value );
27+
Assert::same( $cache->load($key), $value );
3228

3329

34-
// Removing from cache using unset()...
35-
unset($cache[$key]);
30+
// Removing from cache using remove()...
31+
$cache->remove($key);
3632

37-
Assert::false( isset($cache[$key]) );
33+
Assert::null( $cache->load($key) );
3834

3935

4036
// Removing from cache using set NULL...
41-
$cache[$key] = $value;
42-
$cache[$key] = NULL;
37+
$cache->save($key, $value);
38+
$cache->save($key, NULL);
4339

44-
Assert::false( isset($cache[$key]) );
40+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.items.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,39 @@ $cache->save($key, $value, array(
2323
Cache::ITEMS => array('dependent'),
2424
));
2525

26-
Assert::true( isset($cache[$key]) );
26+
Assert::truthy( $cache->load($key) );
2727

2828

2929
// Modifing dependent cached item
30-
$cache['dependent'] = 'hello world';
30+
$cache->save('dependent', 'hello world');
3131

32-
Assert::false( isset($cache[$key]) );
32+
Assert::null( $cache->load($key) );
3333

3434

3535
// Writing cache...
3636
$cache->save($key, $value, array(
3737
Cache::ITEMS => 'dependent',
3838
));
3939

40-
Assert::true( isset($cache[$key]) );
40+
Assert::truthy( $cache->load($key) );
4141

4242

4343
// Modifing dependent cached item
4444
sleep(2);
45-
$cache['dependent'] = 'hello europe';
45+
$cache->save('dependent', 'hello europe');
4646

47-
Assert::false( isset($cache[$key]) );
47+
Assert::null( $cache->load($key) );
4848

4949

5050
// Writing cache...
5151
$cache->save($key, $value, array(
5252
Cache::ITEMS => 'dependent',
5353
));
5454

55-
Assert::true( isset($cache[$key]) );
55+
Assert::truthy( $cache->load($key) );
5656

5757

5858
// Deleting dependent cached item
59-
$cache['dependent'] = NULL;
59+
$cache->save('dependent', NULL);
6060

61-
Assert::false( isset($cache[$key]) );
61+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.loadOrSave.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $value = range("\x00", "\xFF");
1818

1919
$cache = new Cache(new FileStorage(TEMP_DIR));
2020

21-
Assert::false( isset($cache[$key]) );
21+
Assert::null( $cache->load($key) );
2222

2323

2424
// Writing cache using Closure...
@@ -36,4 +36,4 @@ Assert::same( $cache->load($key), $value );
3636
// Sleeping 3 seconds
3737
sleep(3);
3838
clearstatcache();
39-
Assert::false( isset($cache[$key]) );
39+
Assert::null( $cache->load($key) );

tests/Caching/FileStorage.namespace.phpt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@ $cacheB = new Cache($storage, 'b');
1818

1919

2020
// Writing cache...
21-
$cacheA['key'] = 'hello';
22-
$cacheB['key'] = 'world';
21+
$cacheA->save('key', 'hello');
22+
$cacheB->save('key', 'world');
2323

24-
Assert::true( isset($cacheA['key']) );
25-
Assert::true( isset($cacheB['key']) );
26-
Assert::same( $cacheA['key'], 'hello' );
27-
Assert::same( $cacheB['key'], 'world' );
24+
Assert::same( $cacheA->load('key'), 'hello' );
25+
Assert::same( $cacheB->load('key'), 'world' );
2826

2927

30-
// Removing from cache #2 using unset()...
31-
unset($cacheB['key']);
28+
// Removing from cache #2 using remove()...
29+
$cacheB->remove('key');
3230

33-
Assert::true( isset($cacheA['key']) );
34-
Assert::false( isset($cacheB['key']) );
31+
Assert::truthy( $cacheA->load('key') );
32+
Assert::null( $cacheB->load('key') );

tests/Caching/FileStorage.priority.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ $cache->save('key3', 'value3', array(
3030
Cache::PRIORITY => 300,
3131
));
3232

33-
$cache['key4'] = 'value4';
33+
$cache->save('key4', 'value4');
3434

3535

3636
// Cleaning by priority...
3737
$cache->clean(array(
3838
Cache::PRIORITY => '200',
3939
));
4040

41-
Assert::false( isset($cache['key1']) );
42-
Assert::false( isset($cache['key2']) );
43-
Assert::true( isset($cache['key3']) );
44-
Assert::true( isset($cache['key4']) );
41+
Assert::null( $cache->load('key1') );
42+
Assert::null( $cache->load('key2') );
43+
Assert::truthy( $cache->load('key3') );
44+
Assert::truthy( $cache->load('key4') );

tests/Caching/FileStorage.sliding.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ for ($i = 0; $i < 5; $i++) {
3030
sleep(1);
3131
clearstatcache();
3232

33-
Assert::true( isset($cache[$key]) );
33+
Assert::truthy( $cache->load($key) );
3434

3535
}
3636

3737
// Sleeping few seconds...
3838
sleep(5);
3939
clearstatcache();
4040

41-
Assert::false( isset($cache[$key]) );
41+
Assert::null( $cache->load($key) );

0 commit comments

Comments
 (0)