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());
         }
     }
 }
Exemple #2
0
 /**
  * @covers Guzzle\Service\Client::getIterator
  */
 public function testClientCreatesIteratorsWithCommands()
 {
     $client = new Mock\MockClient();
     $command = new MockCommand();
     $iterator = $client->getIterator($command);
     $this->assertInstanceOf('Guzzle\\Tests\\Service\\Mock\\Model\\MockCommandIterator', $iterator);
     $iteratorCommand = $this->readAttribute($iterator, 'originalCommand');
     $this->assertSame($command, $iteratorCommand);
 }
 /**
  * @covers Guzzle\Service\Client::getCommand
  * @depends testMagicCallBehaviorExecuteExecutesCommands
  */
 public function testEnablesMagicMethodCallsOnCommandsIfEnabledOnClient()
 {
     $client = new Mock\MockClient();
     $command = $client->getCommand('other_command');
     $this->assertNull($command->get('command.magic_method_call'));
     $client->setMagicCallBehavior(Client::MAGIC_CALL_EXECUTE);
     $command = $client->getCommand('other_command');
     $this->assertTrue($command->get('command.magic_method_call'));
 }
Exemple #4
0
 public function testMergesDefaultCommandParamsCorrectly()
 {
     $client = new Mock\MockClient('http://www.foo.com', array(Client::COMMAND_PARAMS => array('mesa' => 'bar', 'jar' => 'jar')));
     $command = $client->getCommand('mock_command', array('jar' => 'test'));
     $this->assertEquals('bar', $command->get('mesa'));
     $this->assertEquals('test', $command->get('jar'));
 }
Exemple #5
0
 /**
  * @covers Guzzle\Service\Client::getInflector
  * @covers Guzzle\Service\Client::setInflector
  */
 public function testClientHoldsInflector()
 {
     $client = new Mock\MockClient();
     $this->assertInstanceOf('Guzzle\\Common\\Inflection\\MemoizingInflector', $client->getInflector());
     $inflector = new Inflector();
     $client->setInflector($inflector);
     $this->assertSame($inflector, $client->getInflector());
 }
Exemple #6
0
 public function testGetCommandAfterTwoSetDescriptions()
 {
     $service1 = ServiceDescription::factory(__DIR__ . '/../TestData/test_service.json');
     $service2 = ServiceDescription::factory(__DIR__ . '/../TestData/test_service_3.json');
     $client = new Mock\MockClient();
     $client->setDescription($service1);
     $client->getCommand('foo_bar');
     $client->setDescription($service2);
     $client->getCommand('baz_qux');
 }