private static function convertResponse(Response $response) { $headers = array_map(function ($h) { return implode(', ', $h); }, $response->getHeaders()); return ['status' => $response->getStatusCode(), 'reason' => $response->getReasonPhrase(), 'headers' => $headers, 'body' => base64_encode((string) $response->getBody())]; }
public function testGetsResponseStartLine() { $m = new Response(200); $this->assertEquals('HTTP/1.1 200 OK', Response::getStartLine($m)); }
public function testStatusAndReasonAreMutable() { $response = new Response(200); $response->setStatusCode(201); $this->assertEquals(201, $response->getStatusCode()); $response->setReasonPhrase('Foo'); $this->assertEquals('Foo', $response->getReasonPhrase()); }
public function testProxiesSetters() { $str = Stream::factory('foo'); $response = new Response(200, ['Foo' => 'bar'], $str); $future = MockTest::createFuture(function () use($response) { return $response; }); $future->setStatusCode(202); $this->assertEquals(202, $future->getStatusCode()); $this->assertEquals(202, $response->getStatusCode()); $future->setReasonPhrase('foo'); $this->assertEquals('foo', $future->getReasonPhrase()); $this->assertEquals('foo', $response->getReasonPhrase()); }