Open Journal Systems  3.3.0
FlushingBatchTest.php
1 <?php
2 
3 namespace Guzzle\Tests\Batch;
4 
7 
12 {
14  {
15  $t = $this->getMock('Guzzle\Batch\BatchTransferInterface', array('transfer'));
16  $d = $this->getMock('Guzzle\Batch\BatchDivisorInterface', array('createBatches'));
17 
18  $batch = new Batch($t, $d);
19  $queue = $this->readAttribute($batch, 'queue');
20 
21  $d->expects($this->exactly(2))
22  ->method('createBatches')
23  ->will($this->returnCallback(function () use ($queue) {
24  $items = array();
25  foreach ($queue as $item) {
26  $items[] = $item;
27  }
28  return array($items);
29  }));
30 
31  $t->expects($this->exactly(2))
32  ->method('transfer');
33 
34  $flush = new FlushingBatch($batch, 3);
35  $this->assertEquals(3, $flush->getThreshold());
36  $flush->setThreshold(2);
37  $flush->add('foo')->add('baz')->add('bar')->add('bee')->add('boo');
38  $this->assertEquals(1, count($flush));
39  }
40 }
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Batch\FlushingBatch
Definition: FlushingBatch.php:8
Guzzle\Tests\Batch\FlushingBatchTest
Definition: FlushingBatchTest.php:11
Guzzle\Tests\Batch
Definition: AbstractBatchDecoratorTest.php:3
Guzzle\Tests\Batch\FlushingBatchTest\testFlushesWhenSizeMeetsThreshold
testFlushesWhenSizeMeetsThreshold()
Definition: FlushingBatchTest.php:13
Guzzle\Batch\Batch
Definition: Batch.php:15