Пример #1
0
 public function testGetBodyAsArray()
 {
     $string1 = 'content for the response body';
     $string2 = 'more content for the response body';
     $string3 = 'even more content for the response body';
     $this->_response->appendBody($string1, 'string1');
     $this->_response->appendBody($string2, 'string2');
     $this->_response->appendBody($string3, 'string3');
     $expected = array('string1' => $string1, 'string2' => $string2, 'string3' => $string3);
     $this->assertEquals($expected, $this->_response->getBody(true));
 }
Пример #2
0
 public function test__toString()
 {
     $skipHeadersTest = headers_sent();
     $this->_response->setHeader('Content-Type', 'text/plain');
     $this->_response->setBody('Content');
     $this->_response->appendBody('; and more content.');
     $expected = 'Content; and more content.';
     $result = $this->_response->__toString();
     if (!$skipHeadersTest) {
         $this->assertTrue(headers_sent());
         $headers = headers_list();
         $found = false;
         foreach ($headers as $header) {
             if ('Content-Type: text/plain' == $header) {
                 $found = true;
             }
         }
         $this->assertTrue($found, var_export($headers, 1));
     }
 }