blob: 4da09d30e797542086c8c2e4f9dd3739f6765780 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
namespace Guzzle\Tests\Batch;
use Guzzle\Batch\BatchBuilder;
/**
* @covers Guzzle\Batch\BatchBuilder
*/
class BatchBuilderTest extends \Guzzle\Tests\GuzzleTestCase
{
private function getMockTransfer()
{
return $this->getMock('Guzzle\Batch\BatchTransferInterface');
}
private function getMockDivisor()
{
return $this->getMock('Guzzle\Batch\BatchDivisorInterface');
}
private function getMockBatchBuilder()
{
return BatchBuilder::factory()
->transferWith($this->getMockTransfer())
->createBatchesWith($this->getMockDivisor());
}
public function testFactoryCreatesInstance()
{
$builder = BatchBuilder::factory();
$this->assertInstanceOf('Guzzle\Batch\BatchBuilder', $builder);
}
public function testAddsAutoFlush()
{
$batch = $this->getMockBatchBuilder()->autoFlushAt(10)->build();
$this->assertInstanceOf('Guzzle\Batch\FlushingBatch', $batch);
}
public function testAddsExceptionBuffering()
{
$batch = $this->getMockBatchBuilder()->bufferExceptions()->build();
$this->assertInstanceOf('Guzzle\Batch\ExceptionBufferingBatch', $batch);
}
public function testAddHistory()
{
$batch = $this->getMockBatchBuilder()->keepHistory()->build();
$this->assertInstanceOf('Guzzle\Batch\HistoryBatch', $batch);
}
public function testAddsNotify()
{
$batch = $this->getMockBatchBuilder()->notify(function() {})->build();
$this->assertInstanceOf('Guzzle\Batch\NotifyingBatch', $batch);
}
/**
* @expectedException Guzzle\Common\Exception\RuntimeException
*/
public function testTransferStrategyMustBeSet()
{
$batch = BatchBuilder::factory()->createBatchesWith($this->getMockDivisor())->build();
}
/**
* @expectedException Guzzle\Common\Exception\RuntimeException
*/
public function testDivisorStrategyMustBeSet()
{
$batch = BatchBuilder::factory()->transferWith($this->getMockTransfer())->build();
}
public function testTransfersRequests()
{
$batch = BatchBuilder::factory()->transferRequests(10)->build();
$this->assertInstanceOf('Guzzle\Batch\BatchRequestTransfer', $this->readAttribute($batch, 'transferStrategy'));
}
public function testTransfersCommands()
{
$batch = BatchBuilder::factory()->transferCommands(10)->build();
$this->assertInstanceOf('Guzzle\Batch\BatchCommandTransfer', $this->readAttribute($batch, 'transferStrategy'));
}
}
|