public function testWrapsMultipleCommandExceptions()
 {
     $client = new Mock\MockClient('http://foobaz.com');
     $mock = new MockPlugin(array(new Response(200), new Response(200), new Response(404), new Response(500)));
     $client->addSubscriber($mock);
     $cmds = array(new MockCommand(), new MockCommand(), new MockCommand(), new MockCommand());
     try {
         $client->execute($cmds);
     } catch (CommandTransferException $e) {
         $this->assertEquals(2, count($e->getFailedRequests()));
         $this->assertEquals(2, count($e->getSuccessfulRequests()));
         $this->assertEquals(2, count($e->getFailedCommands()));
         $this->assertEquals(2, count($e->getSuccessfulCommands()));
         foreach ($e->getSuccessfulCommands() as $c) {
             $this->assertTrue($c->getResponse()->isSuccessful());
         }
         foreach ($e->getFailedCommands() as $c) {
             $this->assertFalse($c->getRequest()->getResponse()->isSuccessful());
         }
     }
 }
Example #2
0
 /**
  * @covers Guzzle\Service\Client::execute
  */
 public function testClientResetsRequestsBeforeExecutingCommands()
 {
     $this->getServer()->flush();
     $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nHi", "HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\nI"));
     $client = new Mock\MockClient($this->getServer()->getUrl());
     $command = $client->getCommand('mock_command');
     $client->execute($command);
     $client->execute($command);
     $this->assertEquals('I', $command->getResponse()->getBody(true));
 }