public function testInternalHasItemsCallsInternalHasItem() { $this->_storage = $this->getMockForAbstractAdapter(array('internalHasItem')); $items = array('key1' => true); $this->_storage->expects($this->atLeastOnce())->method('internalHasItem')->with($this->equalTo('key1'))->will($this->returnValue(true)); $rs = $this->_storage->hasItems(array_keys($items)); $this->assertEquals(array('key1'), $rs); }
public function testHasItems() { $keys = array('key1', 'key2', 'key3'); foreach ($keys as $i => $key) { $this->_storage->expects($this->at($i))->method('getItem')->with($this->equalTo($key))->will($i % 2 ? $this->returnValue('value') : $this->returnValue(false)); } $rs = $this->_storage->hasItems($keys); $this->assertInternalType('array', $rs); $this->assertEquals(floor(count($keys) / 2), count($rs)); }
public function testInternalHasItemsCallsInternalHasItem() { $this->_storage = $this->getMockForAbstractAdapter(array('internalHasItem')); $items = array('key1' => true, 'key2' => false); $result = array('key1'); $i = 0; // method call counter foreach ($items as $k => $v) { $this->_storage->expects($this->at($i++))->method('internalHasItem')->with($this->equalTo($k))->will($this->returnValue($v)); } $rs = $this->_storage->hasItems(array_keys($items)); $this->assertEquals($result, $rs); }