Skip to content

Commit

Permalink
Merge pull request #34 from gcds/master
Browse files Browse the repository at this point in the history
Fixed CachePoolTest to support \Traversable
  • Loading branch information
cryptiklemur committed Jan 19, 2016
2 parents 605217d + aa14743 commit 190a3f4
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/CachePoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -178,7 +182,11 @@ public function testGetItems()
unset($keys[$k]);
}
}

$count++;
}

$this->assertSame(4, $count);
}

public function testGetItemsEmpty()
Expand All @@ -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()
Expand Down

0 comments on commit 190a3f4

Please sign in to comment.