Controller/Request/HttpTestCase.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Controller  
Version
$Id: HttpTestCase.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Controller_Request_HttpTestCase

Package: Zend\Controller\Request
Zend_Controller_Request_HttpTestCase

HTTP request object for use with Zend_Controller family.

Parent(s)
\Zend_Controller_Request_Http < \Zend_Controller_Request_Abstract
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
Uses
\global\Zend_Controller_Request_Http  

Constants

>VConstant  SCHEME_HTTP = 'http'
inherited
Scheme for http
Inherited from: \Zend_Controller_Request_Http::SCHEME_HTTP
>VConstant  SCHEME_HTTPS = 'https'
inherited
Scheme for https
Inherited from: \Zend_Controller_Request_Http::SCHEME_HTTPS

Properties

>VPropertyprotectedstring $_actionKey = 'action'
inherited
Action key for retrieving action from params
Inherited from: \Zend_Controller_Request_Abstract::$$_actionKey\Zend_Controller_Request_Http::$$_actionKey
Default value'action'Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_actionKey  
Inherited_from
\Zend_Controller_Request_Http::$$_actionKey  
>VPropertyprotectedarray $_aliases = array()
inherited
Alias keys for request parameters
Inherited from: \Zend_Controller_Request_Http::$$_aliases
Default valuearray()Details
Type
array
Inherited_from
\Zend_Controller_Request_Http::$$_aliases  
>VPropertyprotectedstring $_basePath = null
inherited
Base path of request
Inherited from: \Zend_Controller_Request_Http::$$_basePath
Default valuenullDetails
Type
string
Inherited_from
\Zend_Controller_Request_Http::$$_basePath  
>VPropertyprotectedstring $_baseUrl = null
inherited
Base URL of request
Inherited from: \Zend_Controller_Request_Http::$$_baseUrl
Default valuenullDetails
Type
string
Inherited_from
\Zend_Controller_Request_Http::$$_baseUrl  
>VPropertyprotectedstring $_controllerKey = 'controller'
inherited
Controller key for retrieving controller from params
Inherited from: \Zend_Controller_Request_Abstract::$$_controllerKey\Zend_Controller_Request_Http::$$_controllerKey
Default value'controller'Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_controllerKey  
Inherited_from
\Zend_Controller_Request_Http::$$_controllerKey  
>VPropertyprotectedboolean $_dispatched = false
Default valuefalseDetails
Type
boolean
Inherited_from
\Zend_Controller_Request_Abstract::$$_dispatched  
Inherited_from
\Zend_Controller_Request_Http::$$_dispatched  
>VPropertyprotectedarray $_headers = array()
Request headers
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_method = 'GET'
Request method
Default value'GET'Details
Type
string
>VPropertyprotectedstring $_moduleKey = 'module'
inherited
Module key for retrieving module from params
Inherited from: \Zend_Controller_Request_Abstract::$$_moduleKey\Zend_Controller_Request_Http::$$_moduleKey
Default value'module'Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_moduleKey  
Inherited_from
\Zend_Controller_Request_Http::$$_moduleKey  
>VPropertyprotectedarray $_paramSources = array('_GET', '_POST')
inherited
Allowed parameter sources
Inherited from: \Zend_Controller_Request_Http::$$_paramSources
Default valuearray('_GET', '_POST')Details
Type
array
Inherited_from
\Zend_Controller_Request_Http::$$_paramSources  
>VPropertyprotectedarray $_params = array()
inherited
Instance parameters
Inherited from: \Zend_Controller_Request_Http::$$_params
Default valuearray()Details
Type
array
Inherited_from
\Zend_Controller_Request_Http::$$_params  
>VPropertyprotectedstring $_pathInfo = ''
inherited
PATH_INFO
Inherited from: \Zend_Controller_Request_Http::$$_pathInfo
Default value''Details
Type
string
Inherited_from
\Zend_Controller_Request_Http::$$_pathInfo  
>VPropertyprotectedstring|null $_rawBody
Raw POST body
Details
Type
string | null
>VPropertyprotected\string; $_requestUri
inherited
REQUEST_URI
Inherited from: \Zend_Controller_Request_Http::$$_requestUri
Details
Type
\string;
Inherited_from
\Zend_Controller_Request_Http::$$_requestUri  
>VPropertyprotectedarray $_validMethodTypes = array('DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT')
Valid request method types
Default valuearray('DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT')Details
Type
array

Methods

methodpublic__construct(string | \Zend_Uri $uri = null) : void
inherited

Constructor

Inherited from: \Zend_Controller_Request_Http::__construct()

If a $uri is passed, the object will attempt to populate itself using that information.

Parameters
NameTypeDescription
$uristring | \Zend_Uri
Throws
ExceptionDescription
\Zend_Controller_Request_Exceptionwhen invalid URI passed
methodpublic__get(string $key) : mixed
inherited

Access values contained in the superglobals as public members Order of precedence: 1.

Inherited from: \Zend_Controller_Request_Http::__get()

GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
Details
See
\http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx  
methodpublic__isset(string $key) : boolean
inherited

Check to see if a property is set

Inherited from: \Zend_Controller_Request_Http::__isset()
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
boolean
methodpublic__set(string $key, mixed $value) : void
inherited

Set values

Inherited from: \Zend_Controller_Request_Http::__set()

In order to follow __get(), which operates on a number of superglobals, setting values through overloading is not allowed and will raise an exception. Use setParam() instead.

Parameters
NameTypeDescription
$keystring
$valuemixed
Throws
ExceptionDescription
\Zend_Controller_Request_Exception
methodprotected_normalizeHeaderName(string $name) : string

Normalize a header name for setting and retrieval

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string
methodpublicclearCookies() : \Zend_Controller_Request_HttpTestCase

Clear all cookies

methodpublicclearHeaders() : \Zend_Controller_Request_HttpTestCase

Clear request headers

methodpublicclearPost() : \Zend_Controller_Request_HttpTestCase

Clear POST values

methodpublicclearQuery() : \Zend_Controller_Request_HttpTestCase

Clear GET values

methodpublicclearRawBody() : \Zend_Controller_Request_HttpTestCase

Clear raw POST body

methodpublicget(string $key) : mixed
inherited

Alias to __get

Inherited from: \Zend_Controller_Request_Http::get()
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublicgetActionKey() : string
Returns
TypeDescription
string
methodpublicgetActionName() : string
Returns
TypeDescription
string
methodpublicgetAlias(string $name) : string | null
inherited

Retrieve an alias

Inherited from: \Zend_Controller_Request_Http::getAlias()

Retrieve the actual key represented by the alias $name.

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string | nullReturns null when no alias exists
methodpublicgetAliases() : array
inherited

Retrieve the list of all aliases

Inherited from: \Zend_Controller_Request_Http::getAliases()
Returns
TypeDescription
array
methodpublicgetBasePath() : string
inherited

Everything in REQUEST_URI before PATH_INFO not including the filename

Inherited from: \Zend_Controller_Request_Http::getBasePath()
Returns
TypeDescription
string
methodpublicgetBaseUrl( $raw = false) : string
inherited

Everything in REQUEST_URI before PATH_INFO

Inherited from: \Zend_Controller_Request_Http::getBaseUrl()
Parameters
NameTypeDescription
$raw
Returns
TypeDescription
string
methodpublicgetClientIp(boolean $checkProxy = true) : string
inherited

Get the client's IP addres

Inherited from: \Zend_Controller_Request_Http::getClientIp()
Parameters
NameTypeDescription
$checkProxyboolean
Returns
TypeDescription
string
methodpublicgetControllerKey() : string
Returns
TypeDescription
string
methodpublicgetControllerName() : string
Returns
TypeDescription
string
methodpublicgetCookie(string $key = null, mixed $default = null) : mixed
inherited

Retrieve a member of the $_COOKIE superglobal

Inherited from: \Zend_Controller_Request_Http::getCookie()

If no $key is passed, returns the entire $_COOKIE array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetEnv(string $key = null, mixed $default = null) : mixed
inherited

Retrieve a member of the $_ENV superglobal

Inherited from: \Zend_Controller_Request_Http::getEnv()

If no $key is passed, returns the entire $_ENV array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetHeader(string $header, mixed $default = null) : string | null

Get request header

Pass the header name as the plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the Accept header, 'Accept-Encoding' to get the Accept-Encoding header.

Parameters
NameTypeDescription
$headerstring
$defaultmixed
Returns
TypeDescription
string | null
Throws
ExceptionDescription
\Zend_Controller_Request_Exception
methodpublicgetHeaders() : array

Get all request headers

Returns
TypeDescription
array
methodpublicgetHttpHost() : string
inherited

Get the HTTP host.

Inherited from: \Zend_Controller_Request_Http::getHttpHost()

"Host" ":" host [ ":" port ] ; Section 3.2.2 Note the HTTP Host header is not the same as the URI host. It includes the port while the URI host doesn't.

Returns
TypeDescription
string
methodpublicgetMethod() : string | null

Get request method

Returns
TypeDescription
string | null
methodpublicgetModuleKey() : string
Returns
TypeDescription
string
methodpublicgetModuleName() : string
Returns
TypeDescription
string
methodpublicgetParam(mixed $key, mixed $default = null) : mixed
inherited

Retrieve a parameter

Inherited from: \Zend_Controller_Request_Http::getParam()

Retrieves a parameter from the instance. Priority is in the order of userland parameters (see setParam()), $_GET, $_POST. If a parameter matching the $key is not found, null is returned.

If the $key is an alias, the actual key aliased will be used.

Parameters
NameTypeDescription
$keymixed
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixed
methodpublicgetParamSources() : array
inherited

Get list of allowed parameter sources

Inherited from: \Zend_Controller_Request_Http::getParamSources()
Returns
TypeDescription
array
methodpublicgetParams() : array
inherited

Retrieve an array of parameters

Inherited from: \Zend_Controller_Request_Http::getParams()

Retrieves a merged array of parameters, with precedence of userland params (see setParam()), $_GET, $_POST (i.e., values in the userland params will take precedence over all others).

Returns
TypeDescription
array
methodpublicgetPathInfo() : string
inherited

Returns everything between the BaseUrl and QueryString.

Inherited from: \Zend_Controller_Request_Http::getPathInfo()

This value is calculated instead of reading PATH_INFO directly from $_SERVER due to cross-platform differences.

Returns
TypeDescription
string
methodpublicgetPost(string $key = null, mixed $default = null) : mixed
inherited

Retrieve a member of the $_POST superglobal

Inherited from: \Zend_Controller_Request_Http::getPost()

If no $key is passed, returns the entire $_POST array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetQuery(string $key = null, mixed $default = null) : mixed
inherited

Retrieve a member of the $_GET superglobal

Inherited from: \Zend_Controller_Request_Http::getQuery()

If no $key is passed, returns the entire $_GET array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetRawBody() : string | null

Get RAW POST body

Returns
TypeDescription
string | null
methodpublicgetRequestUri() : null | string

Get REQUEST_URI

Returns
TypeDescription
null | string
methodpublicgetScheme() : string
inherited

Get the request URI scheme

Inherited from: \Zend_Controller_Request_Http::getScheme()
Returns
TypeDescription
string
methodpublicgetServer(string $key = null, mixed $default = null) : mixed
inherited

Retrieve a member of the $_SERVER superglobal

Inherited from: \Zend_Controller_Request_Http::getServer()

If no $key is passed, returns the entire $_SERVER array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetUserParam(string $key, string $default = null) : mixed
inherited

Retrieve a single user param (i.e, a param specific to the object and not the environment)

Inherited from: \Zend_Controller_Request_Abstract::getUserParam()\Zend_Controller_Request_Http::getUserParam()
Parameters
NameTypeDescription
$keystring
$defaultstring

Default value to use if key not found

Returns
TypeDescription
mixed
methodpublicgetUserParams() : array
inherited

Retrieve only user params (i.e, any param specific to the object and not the environment)

Inherited from: \Zend_Controller_Request_Abstract::getUserParams()\Zend_Controller_Request_Http::getUserParams()
Returns
TypeDescription
array
methodpublichas(string $key) : boolean
inherited

Alias to __isset()

Inherited from: \Zend_Controller_Request_Http::has()
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
boolean
methodpublicisDelete() : boolean
inherited

Was the request made by DELETE?

Inherited from: \Zend_Controller_Request_Http::isDelete()
Returns
TypeDescription
boolean
methodpublicisDispatched() : boolean
inherited

Determine if the request has been dispatched

Inherited from: \Zend_Controller_Request_Abstract::isDispatched()\Zend_Controller_Request_Http::isDispatched()
Returns
TypeDescription
boolean
methodpublicisFlashRequest() : boolean
inherited

Is this a Flash request?

Inherited from: \Zend_Controller_Request_Http::isFlashRequest()
Returns
TypeDescription
boolean
methodpublicisGet() : boolean
inherited

Was the request made by GET?

Inherited from: \Zend_Controller_Request_Http::isGet()
Returns
TypeDescription
boolean
methodpublicisHead() : boolean
inherited

Was the request made by HEAD?

Inherited from: \Zend_Controller_Request_Http::isHead()
Returns
TypeDescription
boolean
methodpublicisOptions() : boolean
inherited

Was the request made by OPTIONS?

Inherited from: \Zend_Controller_Request_Http::isOptions()
Returns
TypeDescription
boolean
methodpublicisPost() : boolean
inherited

Was the request made by POST?

Inherited from: \Zend_Controller_Request_Http::isPost()
Returns
TypeDescription
boolean
methodpublicisPut() : boolean
inherited

Was the request made by PUT?

Inherited from: \Zend_Controller_Request_Http::isPut()
Returns
TypeDescription
boolean
methodpublicisSecure() : boolean
inherited

Is https secure request

Inherited from: \Zend_Controller_Request_Http::isSecure()
Returns
TypeDescription
boolean
methodpublicisXmlHttpRequest() : boolean
inherited

Is the request a Javascript XMLHttpRequest?

Inherited from: \Zend_Controller_Request_Http::isXmlHttpRequest()

Should work with Prototype/Script.aculo.us, possibly others.

Returns
TypeDescription
boolean
methodpublicset(string $key, mixed $value) : void
inherited

Alias to __set()

Inherited from: \Zend_Controller_Request_Http::set()
Parameters
NameTypeDescription
$keystring
$valuemixed
methodpublicsetActionKey(string $key) : \Zend_Controller_Request_Abstract
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetActionName(string $value) : \Zend_Controller_Request_Abstract
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetAlias(string $name, string $target) : \Zend_Controller_Request_Http
inherited

Set a key alias

Inherited from: \Zend_Controller_Request_Http::setAlias()

Set an alias used for key lookups. $name specifies the alias, $target specifies the actual key to use.

Parameters
NameTypeDescription
$namestring
$targetstring
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetBasePath(string | null $basePath = null) : \Zend_Controller_Request_Http
inherited

Set the base path for the URL

Inherited from: \Zend_Controller_Request_Http::setBasePath()
Parameters
NameTypeDescription
$basePathstring | null
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetBaseUrl(mixed $baseUrl = null) : \Zend_Controller_Request_Http
inherited

Set the base URL of the request; i.e., the segment leading to the script name

Inherited from: \Zend_Controller_Request_Http::setBaseUrl()

E.g.: - /admin - /myapp - /subdir/index.php

Do not use the full URI when providing the base. The following are examples of what not to use: - http://example.com/admin (should be just /admin) - http://example.com/subdir/index.php (should be just /subdir/index.php)

If no $baseUrl is provided, attempts to determine the base URL from the environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and ORIG_SCRIPT_NAME in its determination.

Parameters
NameTypeDescription
$baseUrlmixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetControllerKey(string $key) : \Zend_Controller_Request_Abstract
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetControllerName(string $value) : \Zend_Controller_Request_Abstract
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetCookie(string $key, mixed $value) : \Zend_Controller_Request_HttpTestCase

Set a cookie

Parameters
NameTypeDescription
$keystring
$valuemixed
Returns
TypeDescription
\Zend_Controller_Request_HttpTestCase
methodpublicsetCookies(array $cookies) : void

Set multiple cookies at once

Parameters
NameTypeDescription
$cookiesarray
methodpublicsetDispatched(boolean $flag = true) : \Zend_Controller_Request_Abstract
inherited

Set flag indicating whether or not request has been dispatched

Inherited from: \Zend_Controller_Request_Abstract::setDispatched()\Zend_Controller_Request_Http::setDispatched()
Parameters
NameTypeDescription
$flagboolean
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetHeader(string $key, string $value) : \Zend_Controller_Request_HttpTestCase

Set a request header

Parameters
NameTypeDescription
$keystring
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_HttpTestCase
methodpublicsetHeaders(array $headers) : \Zend_Controller_Request_HttpTestCase

Set request headers

Parameters
NameTypeDescription
$headersarray
Returns
TypeDescription
\Zend_Controller_Request_HttpTestCase
methodpublicsetMethod(string $type) : \Zend_Controller_Request_HttpTestCase

Set request method

Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Controller_Request_HttpTestCase
methodpublicsetModuleKey(string $key) : \Zend_Controller_Request_Abstract
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetModuleName(string $value) : \Zend_Controller_Request_Abstract
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetParam(mixed $key, mixed $value) : \Zend_Controller_Request_Http
inherited

Set a userland parameter

Inherited from: \Zend_Controller_Request_Http::setParam()

Uses $key to set a userland parameter. If $key is an alias, the actual key will be retrieved and used to set the parameter.

Parameters
NameTypeDescription
$keymixed
$valuemixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetParamSources( $paramSources = array()) : \Zend_Controller_Request_Http
inherited

Set allowed parameter sources

Inherited from: \Zend_Controller_Request_Http::setParamSources()

Can be empty array, or contain one or more of '_GET' or '_POST'.

Parameters
NameTypeDescription
$paramSources
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetParams(array $params) : \Zend_Controller_Request_Http
inherited

Set parameters

Inherited from: \Zend_Controller_Request_Http::setParams()

Set one or more parameters. Parameters are set as userland parameters, using the keys specified in the array.

Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetPathInfo(string | null $pathInfo = null) : \Zend_Controller_Request_Http
inherited

Set the PATH_INFO string

Inherited from: \Zend_Controller_Request_Http::setPathInfo()
Parameters
NameTypeDescription
$pathInfostring | null
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetPost(string | array $spec, null | mixed $value = null) : \Zend_Controller_Request_Http
inherited

Set POST values

Inherited from: \Zend_Controller_Request_Http::setPost()
Parameters
NameTypeDescription
$specstring | array
$valuenull | mixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetQuery(string | array $spec, null | mixed $value = null) : \Zend_Controller_Request_Http
inherited

Set GET values

Inherited from: \Zend_Controller_Request_Http::setQuery()
Parameters
NameTypeDescription
$specstring | array
$valuenull | mixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetRawBody(string $content) : \Zend_Controller_Request_HttpTestCase

Set raw POST body

Parameters
NameTypeDescription
$contentstring
Returns
TypeDescription
\Zend_Controller_Request_HttpTestCase
methodpublicsetRequestUri(string $requestUri = null) : \Zend_Controller_Request_Http
inherited

Set the REQUEST_URI on which the instance operates

Inherited from: \Zend_Controller_Request_Http::setRequestUri()

If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'], $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].

Parameters
NameTypeDescription
$requestUristring
Returns
TypeDescription
\Zend_Controller_Request_Http
Documentation was generated by phpDocumentor 2.0.0a12.