7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
16
* @package Zend_Controller
17
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
18
* @license http://framework.zend.com/license/new-bsd New BSD License
22
* @see Zend_Controller_Response_Http
24
require_once 'Zend/Controller/Response/Http.php';
27
* Zend_Controller_Response_HttpTestCase
29
* @uses Zend_Controller_Response_Http
30
* @package Zend_Controller
33
class Zend_Controller_Response_HttpTestCase extends Zend_Controller_Response_Http
36
* "send" headers by returning array of all headers that would be sent
40
public function sendHeaders()
43
foreach ($this->_headersRaw as $header) {
46
foreach ($this->_headers as $header) {
47
$name = $header['name'];
48
$key = strtolower($name);
49
if (array_key_exists($name, $headers)) {
50
if ($header['replace']) {
51
$headers[$key] = $header['name'] . ': ' . $header['value'];
54
$headers[$key] = $header['name'] . ': ' . $header['value'];
61
* Can we send headers?
66
public function canSendHeaders($throw = false)
72
* Return the concatenated body segments
76
public function outputBody()
79
foreach ($this->_body as $content) {
80
$fullContent .= $content;
86
* Get body and/or body segments
88
* @param bool|string $spec
89
* @return string|array|null
91
public function getBody($spec = false)
93
if (false === $spec) {
94
return $this->outputBody();
95
} elseif (true === $spec) {
97
} elseif (is_string($spec) && isset($this->_body[$spec])) {
98
return $this->_body[$spec];
107
* Concats all response headers, and then final body (separated by two
112
public function sendResponse()
114
$headers = $this->sendHeaders();
115
$content = implode("\n", $headers) . "\n\n";
117
if ($this->isException() && $this->renderExceptions()) {
119
foreach ($this->getException() as $e) {
120
$exceptions .= $e->__toString() . "\n";
122
$content .= $exceptions;
124
$content .= $this->outputBody();