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_Request_Http
24
require_once 'Zend/Controller/Request/Http.php';
27
* Zend_Controller_Request_HttpTestCase
29
* HTTP request object for use with Zend_Controller family.
31
* @uses Zend_Controller_Request_Http
32
* @package Zend_Controller
35
class Zend_Controller_Request_HttpTestCase extends Zend_Controller_Request_Http
41
protected $_headers = array();
56
* Valid request method types
59
protected $_validMethodTypes = array(
71
* @return Zend_Controller_Request_HttpTestCase
73
public function clearQuery()
82
* @return Zend_Controller_Request_HttpTestCase
84
public function clearPost()
93
* @param string $content
94
* @return Zend_Controller_Request_HttpTestCase
96
public function setRawBody($content)
98
$this->_rawBody = (string) $content;
105
* @return string|null
107
public function getRawBody()
109
return $this->_rawBody;
113
* Clear raw POST body
115
* @return Zend_Controller_Request_HttpTestCase
117
public function clearRawBody()
119
$this->_rawBody = null;
127
* @param mixed $value
128
* @return Zend_Controller_Request_HttpTestCase
130
public function setCookie($key, $value)
132
$_COOKIE[(string) $key] = $value;
137
* Set multiple cookies at once
139
* @param array $cookies
142
public function setCookies(array $cookies)
144
foreach ($cookies as $key => $value) {
145
$_COOKIE[$key] = $value;
153
* @return Zend_Controller_Request_HttpTestCase
155
public function clearCookies()
164
* @param string $type
165
* @return Zend_Controller_Request_HttpTestCase
167
public function setMethod($type)
169
$type = strtoupper(trim((string) $type));
170
if (!in_array($type, $this->_validMethodTypes)) {
171
require_once 'Zend/Controller/Exception.php';
172
throw new Zend_Controller_Exception('Invalid request method specified');
174
$this->_method = $type;
181
* @return string|null
183
public function getMethod()
185
return $this->_method;
189
* Set a request header
192
* @param string $value
193
* @return Zend_Controller_Request_HttpTestCase
195
public function setHeader($key, $value)
197
$key = $this->_normalizeHeaderName($key);
198
$this->_headers[$key] = (string) $value;
203
* Set request headers
205
* @param array $headers
206
* @return Zend_Controller_Request_HttpTestCase
208
public function setHeaders(array $headers)
210
foreach ($headers as $key => $value) {
211
$this->setHeader($key, $value);
219
* @param string $header
220
* @param mixed $default
221
* @return string|null
223
public function getHeader($header, $default = null)
225
$header = $this->_normalizeHeaderName($header);
226
if (array_key_exists($header, $this->_headers)) {
227
return $this->_headers[$header];
233
* Get all request headers
237
public function getHeaders()
239
return $this->_headers;
243
* Clear request headers
245
* @return Zend_Controller_Request_HttpTestCase
247
public function clearHeaders()
249
$this->_headers = array();
256
* @return null|string
258
public function getRequestUri()
260
return $this->_requestUri;
264
* Normalize a header name for setting and retrieval
266
* @param string $name
269
protected function _normalizeHeaderName($name)
271
$name = strtoupper((string) $name);
272
$name = str_replace('-', '_', $name);