Esempio n. 1
0
 public function testToString()
 {
     $body = new StringStream();
     $body->write('foobar');
     $response = new Response(200);
     $response->setHeader('Content-Type', 'text/html; charset=UTF-8');
     $response->setBody($body);
     $httpResponse = 'HTTP/1.1 200 OK' . Http::$newLine;
     $httpResponse .= 'content-type: text/html; charset=UTF-8' . Http::$newLine;
     $httpResponse .= Http::$newLine;
     $httpResponse .= 'foobar';
     $this->assertEquals($httpResponse, (string) $response);
 }
Esempio n. 2
0
 public function testToString()
 {
     $body = new StringStream();
     $body->write('foobar');
     $request = new Request(new Url('http://127.0.0.1'), 'POST');
     $request->setHeader('Content-Type', 'text/html; charset=UTF-8');
     $request->setBody($body);
     $httpRequest = 'POST / HTTP/1.1' . Http::$newLine;
     $httpRequest .= 'content-type: text/html; charset=UTF-8' . Http::$newLine;
     $httpRequest .= Http::$newLine;
     $httpRequest .= 'foobar';
     $this->assertEquals($httpRequest, $request->toString());
     $this->assertEquals($httpRequest, (string) $request);
 }