Skip to content

Commit fc61be5

Browse files
committed
tests: removed deprecated ArrayAccess syntax
1 parent 6a2db86 commit fc61be5

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) );

0 commit comments

Comments
 (0)