Skip to content

Commit aa14743

Browse files
author
Aurimas Niekis
committed
Fixed CachePoolTest to support \Traversable
1 parent 605217d commit aa14743

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/CachePoolTest.php

+23-6
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,23 @@ public function testGetItems()
153153

154154
$keys = ['foo', 'bar', 'baz'];
155155
$items = $this->cache->getItems($keys);
156-
$this->assertCount(3, $items);
156+
157+
$count = 0;
157158

158159
/** @type CacheItemInterface $item */
159160
foreach ($items as $i => $item) {
160161
$item->set($i);
161162
$this->cache->save($item);
163+
164+
$count++;
162165
}
163166

167+
$this->assertSame(3, $count);
168+
164169
$keys[] = 'biz';
165170
/** @type CacheItemInterface[] $items */
166-
$items = $this->cache->getItems($keys);
167-
$this->assertCount(4, $items);
168-
171+
$items = $this->cache->getItems($keys);
172+
$count = 0;
169173
foreach ($items as $key => $item) {
170174
$itemKey = $item->getKey();
171175
$this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items');
@@ -178,7 +182,11 @@ public function testGetItems()
178182
unset($keys[$k]);
179183
}
180184
}
185+
186+
$count++;
181187
}
188+
189+
$this->assertSame(4, $count);
182190
}
183191

184192
public function testGetItemsEmpty()
@@ -190,8 +198,17 @@ public function testGetItemsEmpty()
190198
}
191199

192200
$items = $this->cache->getItems([]);
193-
$this->assertCount(0, $items);
194-
$this->assertTrue(is_array($items) || $items instanceof \Traversable, 'A call to getItems with an empty array must always return an array or \Traversable.');
201+
$this->assertTrue(
202+
is_array($items) || $items instanceof \Traversable,
203+
'A call to getItems with an empty array must always return an array or \Traversable.'
204+
);
205+
206+
$count = 0;
207+
foreach ($items as $item) {
208+
$count++;
209+
}
210+
211+
$this->assertSame(0, $count);
195212
}
196213

197214
public function testHasItem()

0 commit comments

Comments
 (0)