public function testConstruct() { // Test no params $res = new Response(); $this->assertInstanceOf('Asika\\Http\\Stream\\Stream', $res->getBody()); $this->assertEquals('php://memory', $res->getBody()->getMetadata('uri')); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals(array(), $res->getHeaders()); // Test with params $body = fopen($tmpfile = tempnam(sys_get_temp_dir(), 'http'), 'wb+'); $headers = array('X-Foo' => array('Flower', 'Sakura'), 'Content-Type' => 'application/json'); $res = new Response($body, 404, $headers); $this->assertInstanceOf('Asika\\Http\\Stream\\Stream', $res->getBody()); $this->assertEquals($tmpfile, $res->getBody()->getMetadata('uri')); $this->assertEquals(array('Flower', 'Sakura'), $res->getHeader('x-foo')); $this->assertEquals(array('application/json'), $res->getHeader('content-type')); fclose($body); // Test with object params $body = new Stream(); $res = new Response($body); $this->assertSame($body, $res->getBody()); }