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\\Common\\Batch\\BatchTransferInterface'), $this->getMock('Guzzle\\Common\\Batch\\BatchDivisorInterface')); $decoratorA = $this->getMockBuilder('Guzzle\\Common\\Batch\\AbstractBatchDecorator')->setConstructorArgs(array($batch))->getMockForAbstractClass(); $decoratorB = $this->getMockBuilder('Guzzle\\Common\\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()); }