|
@@ 222-240 (lines=19) @@
|
| 219 |
|
$this->cache->hasItem('first'); |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
public function testGetItemsOnlyCalledOnce() |
| 223 |
|
{ |
| 224 |
|
$items = [ |
| 225 |
|
'first' => $this->getCacheItem('first'), |
| 226 |
|
'second' => $this->getCacheItem('second'), |
| 227 |
|
]; |
| 228 |
|
|
| 229 |
|
$this->innerCacheMock |
| 230 |
|
->expects($this->once()) |
| 231 |
|
->method('getItems') |
| 232 |
|
->with(['first', 'second']) |
| 233 |
|
->willReturn($items); |
| 234 |
|
|
| 235 |
|
$returnedItems = iterator_to_array($this->cache->getItems(['first', 'second'])); |
| 236 |
|
$this->assertSame($items, $returnedItems); |
| 237 |
|
|
| 238 |
|
$returnedItems = iterator_to_array($this->cache->getItems(['first', 'second'])); |
| 239 |
|
$this->assertSame($items, $returnedItems); |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
/** |
| 243 |
|
* Symfony uses generators with getItems() so we need to make sure we handle that. |
|
@@ 245-263 (lines=19) @@
|
| 242 |
|
/** |
| 243 |
|
* Symfony uses generators with getItems() so we need to make sure we handle that. |
| 244 |
|
*/ |
| 245 |
|
public function testGetItemsWithGenerator() |
| 246 |
|
{ |
| 247 |
|
$items = [ |
| 248 |
|
'first' => $this->getCacheItem('first'), |
| 249 |
|
'second' => $this->getCacheItem('second'), |
| 250 |
|
]; |
| 251 |
|
|
| 252 |
|
$this->innerCacheMock |
| 253 |
|
->expects($this->once()) |
| 254 |
|
->method('getItems') |
| 255 |
|
->with(['first', 'second']) |
| 256 |
|
->willReturn($this->arrayAsGenerator($items)); |
| 257 |
|
|
| 258 |
|
$returnedItems = iterator_to_array($this->cache->getItems(['first', 'second'])); |
| 259 |
|
$this->assertSame($items, $returnedItems); |
| 260 |
|
|
| 261 |
|
$returnedItems = iterator_to_array($this->cache->getItems(['first', 'second'])); |
| 262 |
|
$this->assertSame($items, $returnedItems); |
| 263 |
|
} |
| 264 |
|
|
| 265 |
|
/** |
| 266 |
|
* @depends testGetItemsOnlyCalledOnce |