From aa14743af1b00e467626857e20e81f68fefea7dc Mon Sep 17 00:00:00 2001 From: Aurimas Niekis Date: Tue, 19 Jan 2016 09:56:37 +0100 Subject: [PATCH] Fixed CachePoolTest to support \Traversable --- src/CachePoolTest.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/CachePoolTest.php b/src/CachePoolTest.php index 1e0b020..0104e62 100644 --- a/src/CachePoolTest.php +++ b/src/CachePoolTest.php @@ -153,19 +153,23 @@ public function testGetItems() $keys = ['foo', 'bar', 'baz']; $items = $this->cache->getItems($keys); - $this->assertCount(3, $items); + + $count = 0; /** @type CacheItemInterface $item */ foreach ($items as $i => $item) { $item->set($i); $this->cache->save($item); + + $count++; } + $this->assertSame(3, $count); + $keys[] = 'biz'; /** @type CacheItemInterface[] $items */ - $items = $this->cache->getItems($keys); - $this->assertCount(4, $items); - + $items = $this->cache->getItems($keys); + $count = 0; foreach ($items as $key => $item) { $itemKey = $item->getKey(); $this->assertEquals($itemKey, $key, 'Keys must be preserved when fetching multiple items'); @@ -178,7 +182,11 @@ public function testGetItems() unset($keys[$k]); } } + + $count++; } + + $this->assertSame(4, $count); } public function testGetItemsEmpty() @@ -190,8 +198,17 @@ public function testGetItemsEmpty() } $items = $this->cache->getItems([]); - $this->assertCount(0, $items); - $this->assertTrue(is_array($items) || $items instanceof \Traversable, 'A call to getItems with an empty array must always return an array or \Traversable.'); + $this->assertTrue( + is_array($items) || $items instanceof \Traversable, + 'A call to getItems with an empty array must always return an array or \Traversable.' + ); + + $count = 0; + foreach ($items as $item) { + $count++; + } + + $this->assertSame(0, $count); } public function testHasItem()