Test/PHPUnit/ControllerTestCase.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 [email protected] so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Test  
Version
$Id$  

\Zend_Test_PHPUnit_ControllerTestCase

Package: Zend_Test\PHPUnit
Functional testing scaffold for MVC applications
Parent(s)
\PHPUnit_Framework_TestCase
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Uses
 

Properties

>VPropertyprotected\Zend_Controller_Front $_frontController
>VPropertyprotected\Zend_Dom_Query $_query
Details
Type
\Zend_Dom_Query
>VPropertyprotected\Zend_Controller_Request_Abstract $_request
>VPropertyprotected\Zend_Controller_Response_Abstract $_response
>VPropertyprotectedarray $_xpathNamespaces = array()
XPath namespaces
Default valuearray()Details
Type
array
>VPropertypublicmixed $bootstrap

Bootstrap file path or callback

Details
Type
mixed

Methods

methodpublic__get(mixed $name) : void

Overloading for common properties

Provides overloading for request, response, and frontController objects.
Parameters
NameTypeDescription
$namemixed
methodpublic__set(string $name, mixed $value) : void

Overloading: prevent overloading to special properties

Parameters
NameTypeDescription
$namestring
$valuemixed
methodprotected_incrementAssertionCount() : void

Increment assertion count

methodprotected_resetPlaceholders() : void

Rest all view placeholders

methodpublicassertAction(string $action, string $message = '') : void

Assert that the last handled request used the given action

Parameters
NameTypeDescription
$actionstring
$messagestring
methodpublicassertController(string $controller, string $message = '') : void

Assert that the last handled request used the given controller

Parameters
NameTypeDescription
$controllerstring
$messagestring
methodpublicassertHeader(string $header, string $message = '') : void

Assert response header exists

Parameters
NameTypeDescription
$headerstring
$messagestring
methodpublicassertHeaderContains(string $header, string $match, string $message = '') : void

Assert response header exists and contains the given string

Parameters
NameTypeDescription
$headerstring
$matchstring
$messagestring
methodpublicassertHeaderRegex(string $header, string $pattern, string $message = '') : void

Assert response header exists and matches the given pattern

Parameters
NameTypeDescription
$headerstring
$patternstring
$messagestring
methodpublicassertModule(string $module, string $message = '') : void

Assert that the last handled request used the given module

Parameters
NameTypeDescription
$modulestring
$messagestring
methodpublicassertNotAction(string $action, string $message = '') : void

Assert that the last handled request did NOT use the given action

Parameters
NameTypeDescription
$actionstring
$messagestring
methodpublicassertNotController(string $controller, string $message = '') : void

Assert that the last handled request did NOT use the given controller

Parameters
NameTypeDescription
$controllerstring
$messagestring
methodpublicassertNotHeader(string $header, string $message = '') : void

Assert response header does not exist

Parameters
NameTypeDescription
$headerstring
$messagestring
methodpublicassertNotHeaderContains(string $header, string $match, string $message = '') : void

Assert response header does not exist and/or does not contain the given string

Parameters
NameTypeDescription
$headerstring
$matchstring
$messagestring
methodpublicassertNotHeaderRegex(string $header, string $pattern, string $message = '') : void

Assert response header does not exist and/or does not match the given regex

Parameters
NameTypeDescription
$headerstring
$patternstring
$messagestring
methodpublicassertNotModule(string $module, string $message = '') : void

Assert that the last handled request did NOT use the given module

Parameters
NameTypeDescription
$modulestring
$messagestring
methodpublicassertNotQuery(string $path, string $message = '') : void

Assert against DOM selection

Parameters
NameTypeDescription
$pathstring

CSS selector path

$messagestring
methodpublicassertNotQueryContentContains(string $path, string $match, string $message = '') : void

Assert against DOM selection; node should NOT contain content

Parameters
NameTypeDescription
$pathstring

CSS selector path

$matchstring

content that should NOT be contained in matched nodes

$messagestring
methodpublicassertNotQueryContentRegex(string $path, string $pattern, string $message = '') : void

Assert against DOM selection; node should NOT match content

Parameters
NameTypeDescription
$pathstring

CSS selector path

$patternstring

pattern that should NOT be contained in matched nodes

$messagestring
methodpublicassertNotQueryCount(string $path, string $count, string $message = '') : void

Assert against DOM selection; should NOT contain exact number of nodes

Parameters
NameTypeDescription
$pathstring

CSS selector path

$countstring

Number of nodes that should NOT match

$messagestring
methodpublicassertNotRedirect(string $message = '') : void

Assert that response is NOT a redirect

Parameters
NameTypeDescription
$messagestring
methodpublicassertNotRedirectRegex(string $pattern, string $message = '') : void

Assert that redirect location does not match pattern

Parameters
NameTypeDescription
$patternstring
$messagestring
methodpublicassertNotRedirectTo(string $url, string $message = '') : void

Assert that response does not redirect to given URL

Parameters
NameTypeDescription
$urlstring
$messagestring
methodpublicassertNotResponseCode(int $code, string $message = '') : void

Assert response code

Parameters
NameTypeDescription
$codeint
$messagestring
methodpublicassertNotRoute(string $route, string $message = '') : void

Assert that the route matched is NOT as specified

Parameters
NameTypeDescription
$routestring
$messagestring
methodpublicassertNotXpath(string $path, string $message = '') : void

Assert against XPath selection

Parameters
NameTypeDescription
$pathstring

XPath path

$messagestring
methodpublicassertNotXpathContentContains(string $path, string $match, string $message = '') : void

Assert against XPath selection; node should NOT contain content

Parameters
NameTypeDescription
$pathstring

XPath path

$matchstring

content that should NOT be contained in matched nodes

$messagestring
methodpublicassertNotXpathContentRegex(string $path, string $pattern, string $message = '') : void

Assert against XPath selection; node should NOT match content

Parameters
NameTypeDescription
$pathstring

XPath path

$patternstring

pattern that should NOT be contained in matched nodes

$messagestring
methodpublicassertNotXpathCount(string $path, string $count, string $message = '') : void

Assert against XPath selection; should NOT contain exact number of nodes

Parameters
NameTypeDescription
$pathstring

XPath path

$countstring

Number of nodes that should NOT match

$messagestring
methodpublicassertQuery(string $path, string $message = '') : void

Assert against DOM selection

Parameters
NameTypeDescription
$pathstring

CSS selector path

$messagestring
methodpublicassertQueryContentContains(string $path, string $match, string $message = '') : void

Assert against DOM selection; node should contain content

Parameters
NameTypeDescription
$pathstring

CSS selector path

$matchstring

content that should be contained in matched nodes

$messagestring
methodpublicassertQueryContentRegex(string $path, string $pattern, string $message = '') : void

Assert against DOM selection; node should match content

Parameters
NameTypeDescription
$pathstring

CSS selector path

$patternstring

Pattern that should be contained in matched nodes

$messagestring
methodpublicassertQueryCount(string $path, string $count, string $message = '') : void

Assert against DOM selection; should contain exact number of nodes

Parameters
NameTypeDescription
$pathstring

CSS selector path

$countstring

Number of nodes that should match

$messagestring
methodpublicassertQueryCountMax(string $path, string $count, string $message = '') : void

Assert against DOM selection; should contain no more than this number of nodes

Parameters
NameTypeDescription
$pathstring

CSS selector path

$countstring

Maximum number of nodes that should match

$messagestring
methodpublicassertQueryCountMin(string $path, string $count, string $message = '') : void

Assert against DOM selection; should contain at least this number of nodes

Parameters
NameTypeDescription
$pathstring

CSS selector path

$countstring

Minimum number of nodes that should match

$messagestring
methodpublicassertRedirect(string $message = '') : void

Assert that response is a redirect

Parameters
NameTypeDescription
$messagestring
methodpublicassertRedirectRegex(string $pattern, string $message = '') : void

Assert that redirect location matches pattern

Parameters
NameTypeDescription
$patternstring
$messagestring
methodpublicassertRedirectTo(string $url, string $message = '') : void

Assert that response redirects to given URL

Parameters
NameTypeDescription
$urlstring
$messagestring
methodpublicassertResponseCode(int $code, string $message = '') : void

Assert response code

Parameters
NameTypeDescription
$codeint
$messagestring
methodpublicassertRoute(string $route, string $message = '') : void

Assert that the specified route was used

Parameters
NameTypeDescription
$routestring
$messagestring
methodpublicassertXpath(string $path, string $message = '') : void

Assert against XPath selection

Parameters
NameTypeDescription
$pathstring

XPath path

$messagestring
methodpublicassertXpathContentContains(string $path, string $match, string $message = '') : void

Assert against XPath selection; node should contain content

Parameters
NameTypeDescription
$pathstring

XPath path

$matchstring

content that should be contained in matched nodes

$messagestring
methodpublicassertXpathContentRegex(string $path, string $pattern, string $message = '') : void

Assert against XPath selection; node should match content

Parameters
NameTypeDescription
$pathstring

XPath path

$patternstring

Pattern that should be contained in matched nodes

$messagestring
methodpublicassertXpathCount(string $path, string $count, string $message = '') : void

Assert against XPath selection; should contain exact number of nodes

Parameters
NameTypeDescription
$pathstring

XPath path

$countstring

Number of nodes that should match

$messagestring
methodpublicassertXpathCountMax(string $path, string $count, string $message = '') : void

Assert against XPath selection; should contain no more than this number of nodes

Parameters
NameTypeDescription
$pathstring

XPath path

$countstring

Maximum number of nodes that should match

$messagestring
methodpublicassertXpathCountMin(string $path, string $count, string $message = '') : void

Assert against XPath selection; should contain at least this number of nodes

Parameters
NameTypeDescription
$pathstring

XPath path

$countstring

Minimum number of nodes that should match

$messagestring
methodpublicbootstrap() : void
final

Bootstrap the front controller

Resets the front controller, and then bootstraps it. If {@link $bootstrap} is a callback, executes it; if it is a file, it include's it. When done, sets the test case request and response objects into the front controller.
methodpublicdispatch(string | null $url = null) : void

Dispatch the MVC

If a URL is provided, sets it as the request URI in the request object. Then sets test case request and response objects in front controller, disables throwing exceptions, and disables returning the response. Finally, dispatches the front controller.
Parameters
NameTypeDescription
$urlstring | null
methodpublicgetFrontController() : \Zend_Controller_Front

Retrieve front controller instance

Returns
TypeDescription
\Zend_Controller_Front
methodpublicgetQuery() : \Zend_Dom_Query

Retrieve DOM query object

Returns
TypeDescription
\Zend_Dom_Query
methodpublicgetRequest() : \Zend_Controller_Request_HttpTestCase

Retrieve test case request object

methodpublicgetResponse() : \Zend_Controller_Response_HttpTestCase

Retrieve test case response object

methodpublicregisterXpathNamespaces(array $xpathNamespaces) : void

Register XPath namespaces

Parameters
NameTypeDescription
$xpathNamespacesarray
methodpublicreset() : void

Reset MVC state

Creates new request/response objects, resets the front controller instance, and resets the action helper broker.
Details
Todo
Need to update Zend_Layout to add a resetInstance() method  
methodpublicresetRequest() : \Zend_Test_PHPUnit_ControllerTestCase

Reset the request object

Useful for test cases that need to test multiple trips to the server.
Returns
TypeDescription
\Zend_Test_PHPUnit_ControllerTestCase
methodpublicresetResponse() : \Zend_Test_PHPUnit_ControllerTestCase

Reset the response object

Useful for test cases that need to test multiple trips to the server.
Returns
TypeDescription
\Zend_Test_PHPUnit_ControllerTestCase
methodprotectedsetUp() : void

Set up MVC app

Calls {@link bootstrap()} by default
methodpublicurl(array $urlOptions = array(), string $name = null, bool $reset = false, bool $encode = true) : void

URL Helper

Parameters
NameTypeDescription
$urlOptionsarray
$namestring
$resetbool
$encodebool
methodpublicurlizeOptions( $urlOptions,  $actionControllerModuleOnly = true) : void

Parameters
NameTypeDescription
$urlOptions
$actionControllerModuleOnly
Documentation was generated by phpDocumentor 2.2.0 .