Example #1
0
    /**
     * @covers ::setHeadersString
     */
    public function testParseHeaders()
    {
        $headerString = <<<TEXT
            HTTP/1.1 200 OK 

            Date: Wed, 02 Dec 2015 11:33:54 GMT 

            Content-Type: text/html; charset=utf-8 

            Transfer-Encoding: chunked 

            Connection: keep-alive 

            Cache-Control: public, no-cache=\\"Set-Cookie\\", max-age=35 

            Expires: Wed, 02 Dec 2015 11:34:29 GMT 

            Last-Modified: Wed, 02 Dec 2015 11:33:29 GMT 

            Vary: * 

            Server: nginx 

TEXT;
        $response = new Response();
        $response->setHeadersString($headerString);
        $responseHeaders = $response->getHeaders();
        $expectedArray = ['Date' => 'Wed, 02 Dec 2015 11:33:54 GMT', 'Content-Type' => 'text/html; charset=utf-8', 'Transfer-Encoding' => 'chunked', 'Connection' => 'keep-alive', 'Cache-Control' => 'public, no-cache=\\"Set-Cookie\\", max-age=35', 'Expires' => 'Wed, 02 Dec 2015 11:34:29 GMT', 'Last-Modified' => 'Wed, 02 Dec 2015 11:33:29 GMT', 'Vary' => '*', 'Server' => 'nginx'];
        $this->assertEquals($expectedArray, $responseHeaders);
    }