__toString() публичный Метод

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.
См. также: prepare()
public __toString ( ) : string
Результат string The Response as an HTTP string
Пример #1
0
 public function __toString()
 {
     $this->headers->set('Content-Length', strlen($this->getContent()));
     return parent::__toString();
 }
Пример #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();
 }
Пример #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'));
 }