__toString() public method

The string representation of the Response is the same as the one that will be sent to the client only if the prepare() method has been called before.
See also: prepare()
public __toString ( ) : string
return string The Response as an HTTP string
Exemplo n.º 1
0
 public function __toString()
 {
     $this->headers->set('Content-Length', strlen($this->getContent()));
     return parent::__toString();
 }
Exemplo n.º 2
0
 public function testDefaultContentType()
 {
     $headerMock = $this->getMock('Symfony\\Component\\HttpFoundation\\ResponseHeaderBag', array('set'));
     $headerMock->expects($this->at(0))->method('set')->with('Content-Type', 'text/html; charset=UTF-8');
     $headerMock->expects($this->at(1))->method('set')->with('Content-Type', 'text/html; charset=Foo');
     $response = new Response();
     $response->headers = $headerMock;
     // verify first set()
     $response->__toString();
     $response->headers->remove('Content-Type');
     $response->setCharset('Foo');
     // verify second set()
     $response->__toString();
 }
Exemplo n.º 3
0
 public function testContentTypeCharset()
 {
     $response = new Response();
     $response->headers->set('Content-Type', 'text/css');
     // force fixContentType() to be called
     $response->__toString();
     $this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
 }