コード例 #1
0
    function testGeneral()
    {
        $str = <<<EOF
HTTP/1.1 500 Server error
Host: localhost:8080
X-Powered-By: PHP/5.4.31
bc-param1: hello, world
Content-Type: text/plain

Exception: exception 'PDOException'
EOF;
        $res = new HttpResponse($str);
        $this->assertEquals(500, $res->code);
        $this->assertEquals("Server error", $res->message);
        $this->assertEquals("localhost:8080", $res->headers["HOST"]);
        $this->assertEquals("Exception: exception 'PDOException'", $res->body);
        $this->assertEquals("hello, world", $res->getHeader("bc-param1"));
        $this->assertEquals("hello, world", $res->getBCParam("param1"));
        $this->assertNull($res->getHeader("bc-param2"));
        $this->assertNull($res->getBCParam("param2"));
        $this->assertEquals($str, $res->toString());
    }