Skip to content

Commit 29fcb2b

Browse files
author
Igor V. Gulyaev
committed
+ test for WatermarkedPeer. bit base CachePeer fix
1 parent e7cf910 commit 29fcb2b

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

core/Cache/CachePeer.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function getList($indexes)
150150

151151
foreach ($indexes as $key)
152152
if (null !== ($value = $this->get($key)))
153-
$out[] = $value;
153+
$out[$key] = $value;
154154

155155
return $out;
156156
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
final class WatermarkedPeerTest extends TestCase
4+
{
5+
6+
public function testMultiGet()
7+
{
8+
9+
$cache = new WatermarkedPeer(new RuntimeMemory());
10+
11+
$cache->clean();
12+
13+
$cache->set('a', 'a', Cache::EXPIRES_MEDIUM);
14+
$cache->set('b', 2, Cache::EXPIRES_MEDIUM);
15+
$cache->set('c', 42.28, Cache::EXPIRES_MEDIUM);
16+
17+
$this->assertEquals($cache->get('a'), 'a');
18+
$this->assertEquals($cache->get('b'), 2);
19+
$this->assertEquals($cache->get('c'), 42.28);
20+
21+
$list = $cache->getList(array('a', 'b', 'c'));
22+
23+
$this->assertEquals(count($list), 3);
24+
25+
$this->assertEquals($list['a'], 'a');
26+
$this->assertEquals($list['b'], 2);
27+
$this->assertEquals($list['c'], 42.28);
28+
29+
$list = $cache->getList(array('a'));
30+
31+
$this->assertEquals(count($list), 1);
32+
33+
$this->assertEquals($list['a'], 'a');
34+
35+
$list = $cache->getList(array('a', 'b', 'c', 'd'));
36+
37+
$this->assertEquals(count($list), 3);
38+
39+
$this->assertEquals($list['a'], 'a');
40+
$this->assertEquals($list['b'], 2);
41+
$this->assertEquals($list['c'], 42.28);
42+
43+
$list = $cache->getList(array('d'));
44+
45+
$this->assertEquals(count($list), 0);
46+
47+
$cache->clean();
48+
}
49+
}
50+
?>

0 commit comments

Comments
 (0)