25 $mockError =
'Guzzle\Tests\Mock\ErrorResponseMock';
27 'operations' => array(
29 'httpMethod' =>
'GET',
30 'errorResponses' => array(
31 array(
'code' => 500,
'class' => $mockError),
32 array(
'code' => 503,
'reason' =>
'foo',
'class' => $mockError),
33 array(
'code' => 200,
'reason' =>
'Error!',
'class' => $mockError)
37 'httpMethod' =>
'GET',
38 'errorResponses' => array(
39 array(
'code' => 500,
'class' =>
'Does\\Not\\Exist')
42 'does_not_implement' => array(
43 'httpMethod' =>
'GET',
44 'errorResponses' => array(
45 array(
'code' => 500,
'class' => __CLASS__)
48 'no_errors' => array(
'httpMethod' =>
'GET'),
50 'httpMethod' =>
'GET',
51 'errorResponses' => array(
58 $this->client->setDescription($description);
66 $this->
getServer()->enqueue(
"HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
68 $this->client->getCommand(
'no_errors')->execute();
73 $this->
getServer()->enqueue(
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
75 $this->client->getCommand(
'no_errors')->execute();
84 $this->
getServer()->enqueue(
"HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
86 $this->client->getCommand(
'bad_class')->execute();
95 $this->
getServer()->enqueue(
"HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
97 $this->client->getCommand(
'does_not_implement')->execute();
103 $this->
getServer()->enqueue(
"HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
105 $command = $this->client->getCommand(
'works');
107 $this->fail(
'Exception not thrown');
109 $this->assertSame($command, $e->command);
110 $this->assertEquals(500, $e->response->getStatusCode());
119 $this->
getServer()->enqueue(
"HTTP/1.1 200 Error!\r\nContent-Length: 0\r\n\r\n");
121 $this->client->getCommand(
'works')->execute();
126 $this->
getServer()->enqueue(
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
128 $this->client->getCommand(
'works')->execute();
133 $this->
getServer()->enqueue(
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
135 $this->client->getCommand(
'no_class')->execute();