Beispiel #1
0
 public function testCanChangeResponseBody()
 {
     $body = EntityBody::factory();
     $command = new MockCommand();
     $command->setClient(new \Guzzle\Service\Client());
     $command->set(AbstractCommand::RESPONSE_BODY, $body);
     $request = $command->prepare();
     $this->assertSame($body, $this->readAttribute($request, 'responseBody'));
 }
Beispiel #2
0
 /**
  * @covers Guzzle\Service\Command\AbstractCommand::setOnComplete
  * @covers Guzzle\Service\Command\AbstractCommand::__construct
  * @covers Guzzle\Service\Command\AbstractCommand::getResult
  */
 public function testHasOnCompleteMethod()
 {
     $that = $this;
     $called = 0;
     $testFunction = function ($command) use(&$called, $that) {
         $called++;
         $that->assertInstanceOf('Guzzle\\Service\\Command\\CommandInterface', $command);
     };
     $client = $this->getClient();
     $command = new MockCommand(array('command.on_complete' => $testFunction), $this->getApiCommand());
     $command->setClient($client);
     $command->prepare()->setResponse(new Response(200));
     $command->execute();
     $this->assertEquals(1, $called);
 }
 /**
  * @covers Guzzle\Service\Command\AbstractCommand::prepare
  * @expectedException RuntimeException
  */
 public function testPrepareThrowsExceptionWhenNoClientIsSet()
 {
     $command = new MockCommand();
     $command->prepare();
 }
Beispiel #4
0
 /**
  * @covers Guzzle\Service\Command\AbstractCommand::prepare
  */
 public function testAddsCurlOptionsToRequestsWhenPreparing()
 {
     $command = new MockCommand(array('foo' => 'bar', 'curl.CURLOPT_PROXYPORT' => 8080));
     $client = new Client();
     $command->setClient($client);
     $request = $command->prepare();
     $this->assertEquals(8080, $request->getCurlOptions()->get(CURLOPT_PROXYPORT));
 }