/** * Execute a callback on every ready adapter. * @param \Closure $callbackFunction * @return \Brickoo\Component\Storage\StorageProxy */ private function executeIterationCallback(\Closure $callbackFunction) { $this->rewindAdapterPool(); $callbackValue = null; while ($callbackValue !== self::BREAK_ITERATION_CALLBACK && $this->adapterPoolIterator->valid() && $this->adapterPoolIterator->isCurrentReady()) { $callbackValue = $callbackFunction($this->adapterPoolIterator->current()); $this->adapterPoolIterator->next(); } return $this; }
/** * @covers Brickoo\Component\Storage\Adapter\AdapterPoolIterator::current * @covers Brickoo\Component\Storage\Adapter\AdapterPoolIterator::isEmpty * @covers Brickoo\Component\Storage\Adapter\Exception\PoolIsEmptyException * @expectedException \Brickoo\Component\Storage\Adapter\Exception\PoolIsEmptyException */ public function testIteratorThrowsExceptionIfCurrentValueIsNotAvailable() { $adapter = $this->getAdapterStub(); $adapterPoolIterator = new AdapterPoolIterator(["adapter" => $adapter]); $adapterPoolIterator->rewind(); $this->assertSame($adapter, $adapterPoolIterator->current()); $adapterPoolIterator->next(); $adapterPoolIterator->current(); }