public function testCanMutateData() { $client = $this->getMockForAbstractClass('GuzzleHttp\\Command\\ServiceClientInterface'); $command = new Command('foo', []); $trans = new CommandTransaction($client, $command, ['foo' => 'bar']); $request = new Request('GET', 'http://foo.com'); $trans->setRequest($request); $this->assertSame($request, $trans->getRequest()); $response = new Response(200); $trans->setResponse($response); $this->assertSame($response, $trans->getResponse()); $trans->setResult('foo'); $this->assertSame('foo', $trans->getResult()); $e = new \Exception('foo'); $trans->setException($e); $this->assertSame($e, $trans->getException()); }
public function createCommandException(CommandTransaction $transaction, RequestException $previous) { $cn = 'GuzzleHttp\\Command\\Exception\\CommandException'; if ($response = $transaction->getResponse()) { $statusCode = (string) $response->getStatusCode(); if ($statusCode[0] == '4') { $cn = 'GuzzleHttp\\Command\\Exception\\CommandClientException'; } elseif ($statusCode[0] == '5') { $cn = 'GuzzleHttp\\Command\\Exception\\CommandServerException'; } } return new $cn("Error executing command: " . $previous->getMessage(), $transaction, $previous); }