예제 #1
0
 public function testFlushReturnsItems()
 {
     $transfer = $this->getMockTransfer();
     $transfer->expects($this->exactly(2))->method('transfer');
     $divisor = $this->getMockDivisor();
     $divisor->expects($this->once())->method('createBatches')->will($this->returnValue(array(array('foo', 'baz'), array('bar'))));
     $batch = new Batch($transfer, $divisor);
     $batch->add('foo')->add('baz')->add('bar');
     $items = $batch->flush();
     $this->assertEquals(array('foo', 'baz', 'bar'), $items);
 }
 public function testProxiesToWrappedObject()
 {
     $batch = new Batch($this->getMock('Guzzle\\Batch\\BatchTransferInterface'), $this->getMock('Guzzle\\Batch\\BatchDivisorInterface'));
     $decoratorA = $this->getMockBuilder('Guzzle\\Batch\\AbstractBatchDecorator')->setConstructorArgs(array($batch))->getMockForAbstractClass();
     $decoratorB = $this->getMockBuilder('Guzzle\\Batch\\AbstractBatchDecorator')->setConstructorArgs(array($decoratorA))->getMockForAbstractClass();
     $decoratorA->add('foo');
     $this->assertFalse($decoratorB->isEmpty());
     $this->assertFalse($batch->isEmpty());
     $this->assertEquals(array($decoratorB, $decoratorA), $decoratorB->getDecorators());
     $this->assertEquals(array(), $decoratorB->flush());
 }
 /**
  * Initiate the transfer process
  *
  * @return array PUT responses
  */
 public function transfer()
 {
     $requests = $this->sendGetRequests();
     $this->readQueue = null;
     foreach ($requests as $key => $request) {
         $this->writeQueue->add($this->createPutRequest($request->getResponse()));
         unset($requests[$key]);
     }
     return $this->writeQueue->flush();
 }