Open Journal Systems  3.3.0
BatchCommandTransferTest.php
1 <?php
2 
3 namespace Guzzle\Tests\Batch;
4 
8 
13 {
15  {
16  $client1 = new Client('http://www.example.com');
17  $client2 = new Client('http://www.example.com');
18 
19  $commands = array(new Mc(), new Mc(), new Mc(), new Mc(), new Mc());
20 
21  $queue = new \SplQueue();
22  foreach ($commands as $i => $command) {
23  if ($i % 2) {
24  $command->setClient($client1);
25  } else {
26  $command->setClient($client2);
27  }
28  $queue[] = $command;
29  }
30 
31  $batch = new BatchCommandTransfer(2);
32  $this->assertEquals(array(
33  array($commands[0], $commands[2]),
34  array($commands[4]),
35  array($commands[1], $commands[3])
36  ), $batch->createBatches($queue));
37  }
38 
43  {
44  $queue = new \SplQueue();
45  $queue[] = 'foo';
46  $batch = new BatchCommandTransfer(2);
47  $batch->createBatches($queue);
48  }
49 
50  public function testTransfersBatches()
51  {
52  $client = $this->getMockBuilder('Guzzle\Service\Client')
53  ->setMethods(array('send'))
54  ->getMock();
55  $client->expects($this->once())
56  ->method('send');
57  $command = new Mc();
58  $command->setClient($client);
59  $batch = new BatchCommandTransfer(2);
60  $batch->transfer(array($command));
61  }
62 
64  {
65  $batch = new BatchCommandTransfer(2);
66  $batch->transfer(array());
67  }
68 
73  {
74  $batch = new BatchCommandTransfer(2);
75  $client1 = new Client('http://www.example.com');
76  $client2 = new Client('http://www.example.com');
77  $command1 = new Mc();
78  $command1->setClient($client1);
79  $command2 = new Mc();
80  $command2->setClient($client2);
81  $batch->transfer(array($command1, $command2));
82  }
83 }
Guzzle\Tests\Batch\BatchCommandTransferTest\testEnsuresAllCommandsUseTheSameClient
testEnsuresAllCommandsUseTheSameClient()
Definition: BatchCommandTransferTest.php:72
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Tests\Batch\BatchCommandTransferTest\testDoesNotTransfersEmptyBatches
testDoesNotTransfersEmptyBatches()
Definition: BatchCommandTransferTest.php:63
Guzzle\Service\Client
Definition: lib/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:25
Guzzle\Tests\Batch\BatchCommandTransferTest
Definition: BatchCommandTransferTest.php:12
Guzzle\Tests\Service\Mock\Command\MockCommand
Definition: MockCommand.php:7
Guzzle\Tests\Batch\BatchCommandTransferTest\testCreatesBatchesBasedOnClient
testCreatesBatchesBasedOnClient()
Definition: BatchCommandTransferTest.php:14
Guzzle\Tests\Batch
Definition: AbstractBatchDecoratorTest.php:3
Guzzle\Tests\Batch\BatchCommandTransferTest\testTransfersBatches
testTransfersBatches()
Definition: BatchCommandTransferTest.php:50
Guzzle\Http\Client
Definition: lib/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php:24
Guzzle\Tests\Batch\BatchCommandTransferTest\testEnsuresAllItemsAreCommands
testEnsuresAllItemsAreCommands()
Definition: BatchCommandTransferTest.php:42
Guzzle\Batch\BatchCommandTransfer
Definition: BatchCommandTransfer.php:15