Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * @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();
 }