public function testInternalGetItemsCallsInternalGetItemForEachKey() { $this->markTestSkipped("This test doesn't work because of an issue with PHPUnit: " . 'https://github.com/sebastianbergmann/phpunit-mock-objects/issues/81'); $this->_storage = $this->getMockForAbstractAdapter(array('internalGetItem')); $items = array('key1' => 'value1', 'notFound' => false, 'key2' => 'value2'); $result = array('key1' => 'value1', 'key2' => 'value2'); $i = 0; // method call counter foreach ($items as $k => $v) { $this->_storage->expects($this->at($i++))->method('internalGetItem')->with($this->equalTo($k), $this->equalTo(null), $this->equalTo(null))->will($this->returnCallback(function ($k, &$success, &$casToken) use($items) { if ($items[$k]) { $success = true; return $items[$k]; } else { $success = false; return null; } })); } $rs = $this->_storage->getItems(array_keys($items), $options); $this->assertEquals($result, $rs); }
/** * Get multiple items. * * @param array $keys * @return array Associative array of keys and values * @throws Exception\ExceptionInterface * * @triggers getItems.pre(PreEvent) * @triggers getItems.post(PostEvent) * @triggers getItems.exception(ExceptionEvent) */ public function getItems(array $keys) { $options = $this->getOptions(); if ($options->getReadable() && $options->getClearStatCache()) { clearstatcache(); } return parent::getItems($keys); }