Functional testing scaffold for MVC applications

uses
category Zend
package Zend_Test
subpackage PHPUnit
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Overloading for common properties

__get(mixed $name) : null | \Zend_Controller_Front | \Zend_Controller_Request_HttpTestCase | \Zend_Controller_Response_HttpTestCase

Provides overloading for request, response, and frontController objects.

Parameters

$name

mixed

Returns

null\Zend_Controller_Front\Zend_Controller_Request_HttpTestCase\Zend_Controller_Response_HttpTestCase

Overloading: prevent overloading to special properties

__set(string $name, mixed $value) 

Parameters

$name

string

$value

mixed

Exceptions

\Zend_Exception

Assert that the last handled request used the given action

assertAction(string $action, string $message = ''

Parameters

$action

string

$message

string

Assert that the last handled request used the given controller

assertController(string $controller, string $message = ''

Parameters

$controller

string

$message

string

Assert response header exists

assertHeader(string $header, string $message = ''

Parameters

$header

string

$message

string

Assert response header exists and contains the given string

assertHeaderContains(string $header, string $match, string $message = ''

Parameters

$header

string

$match

string

$message

string

Assert response header exists and matches the given pattern

assertHeaderRegex(string $header, string $pattern, string $message = ''

Parameters

$header

string

$pattern

string

$message

string

Assert that the last handled request used the given module

assertModule(string $module, string $message = ''

Parameters

$module

string

$message

string

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

assertNotAction(string $action, string $message = ''

Parameters

$action

string

$message

string

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

assertNotController(string $controller, string $message = ''

Parameters

$controller

string

$message

string

Assert response header does not exist

assertNotHeader(string $header, string $message = ''

Parameters

$header

string

$message

string

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

assertNotHeaderContains(string $header, string $match, string $message = ''

Parameters

$header

string

$match

string

$message

string

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

assertNotHeaderRegex(string $header, string $pattern, string $message = ''

Parameters

$header

string

$pattern

string

$message

string

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

assertNotModule(string $module, string $message = ''

Parameters

$module

string

$message

string

Assert against DOM selection

assertNotQuery(string $path, string $message = ''

Parameters

$path

string

CSS selector path

$message

string

Assert against DOM selection; node should NOT contain content

assertNotQueryContentContains(string $path, string $match, string $message = ''

Parameters

$path

string

CSS selector path

$match

string

content that should NOT be contained in matched nodes

$message

string

Assert against DOM selection; node should NOT match content

assertNotQueryContentRegex(string $path, string $pattern, string $message = ''

Parameters

$path

string

CSS selector path

$pattern

string

pattern that should NOT be contained in matched nodes

$message

string

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

assertNotQueryCount(string $path, string $count, string $message = ''

Parameters

$path

string

CSS selector path

$count

string

Number of nodes that should NOT match

$message

string

Assert that response is NOT a redirect

assertNotRedirect(string $message = ''

Parameters

$message

string

Assert that redirect location does not match pattern

assertNotRedirectRegex(string $pattern, string $message = ''

Parameters

$pattern

string

$message

string

Assert that response does not redirect to given URL

assertNotRedirectTo(string $url, string $message = ''

Parameters

$url

string

$message

string

Assert response code

assertNotResponseCode(integer $code, string $message = ''

Parameters

$code

integer

$message

string

Assert that the route matched is NOT as specified

assertNotRoute(string $route, string $message = ''

Parameters

$route

string

$message

string

Assert against XPath selection

assertNotXpath(string $path, string $message = ''

Parameters

$path

string

XPath path

$message

string

Assert against XPath selection; node should NOT contain content

assertNotXpathContentContains(string $path, string $match, string $message = ''

Parameters

$path

string

XPath path

$match

string

content that should NOT be contained in matched nodes

$message

string

Assert against XPath selection; node should NOT match content

assertNotXpathContentRegex(string $path, string $pattern, string $message = ''

Parameters

$path

string

XPath path

$pattern

string

pattern that should NOT be contained in matched nodes

$message

string

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

assertNotXpathCount(string $path, string $count, string $message = ''

Parameters

$path

string

XPath path

$count

string

Number of nodes that should NOT match

$message

string

Assert against DOM selection

assertQuery(string $path, string $message = ''

Parameters

$path

string

CSS selector path

$message

string

Assert against DOM selection; node should contain content

assertQueryContentContains(string $path, string $match, string $message = ''

Parameters

$path

string

CSS selector path

$match

string

content that should be contained in matched nodes

$message

string

Assert against DOM selection; node should match content

assertQueryContentRegex(string $path, string $pattern, string $message = ''

Parameters

$path

string

CSS selector path

$pattern

string

Pattern that should be contained in matched nodes

$message

string

Assert against DOM selection; should contain exact number of nodes

assertQueryCount(string $path, string $count, string $message = ''

Parameters

$path

string

CSS selector path

$count

string

Number of nodes that should match

$message

string

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

assertQueryCountMax(string $path, string $count, string $message = ''

Parameters

$path

string

CSS selector path

$count

string

Maximum number of nodes that should match

$message

string

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

assertQueryCountMin(string $path, string $count, string $message = ''

Parameters

$path

string

CSS selector path

$count

string

Minimum number of nodes that should match

$message

string

Assert that response is a redirect

assertRedirect(string $message = ''

Parameters

$message

string

Assert that redirect location matches pattern

assertRedirectRegex(string $pattern, string $message = ''

Parameters

$pattern

string

$message

string

Assert that response redirects to given URL

assertRedirectTo(string $url, string $message = ''

Parameters

$url

string

$message

string

Assert response code

assertResponseCode(integer $code, string $message = ''

Parameters

$code

integer

$message

string

Assert that the specified route was used

assertRoute(string $route, string $message = ''

Parameters

$route

string

$message

string

Assert against XPath selection

assertXpath(string $path, string $message = ''

Parameters

$path

string

XPath path

$message

string

Assert against XPath selection; node should contain content

assertXpathContentContains(string $path, string $match, string $message = ''

Parameters

$path

string

XPath path

$match

string

content that should be contained in matched nodes

$message

string

Assert against XPath selection; node should match content

assertXpathContentRegex(string $path, string $pattern, string $message = ''

Parameters

$path

string

XPath path

$pattern

string

Pattern that should be contained in matched nodes

$message

string

Assert against XPath selection; should contain exact number of nodes

assertXpathCount(string $path, string $count, string $message = ''

Parameters

$path

string

XPath path

$count

string

Number of nodes that should match

$message

string

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

assertXpathCountMax(string $path, string $count, string $message = ''

Parameters

$path

string

XPath path

$count

string

Maximum number of nodes that should match

$message

string

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

assertXpathCountMin(string $path, string $count, string $message = ''

Parameters

$path

string

XPath path

$count

string

Minimum number of nodes that should match

$message

string

Bootstrap the front controller

bootstrap() 

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.

Dispatch the MVC

dispatch(string|null $url = null

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

$url

stringnull

Retrieve front controller instance

getFrontController() : \Zend_Controller_Front

Returns

\Zend_Controller_Front

Retrieve DOM query object

getQuery() : \Zend_Dom_Query

Returns

\Zend_Dom_Query

Retrieve test case request object

getRequest() : \Zend_Controller_Request_HttpTestCase

Returns

\Zend_Controller_Request_HttpTestCase

Retrieve test case response object

getResponse() : \Zend_Controller_Response_HttpTestCase

Returns

\Zend_Controller_Response_HttpTestCase

Register XPath namespaces

registerXpathNamespaces(array $xpathNamespaces) 

Parameters

$xpathNamespaces

array

Reset MVC state

reset() 

Creates new request/response objects, resets the front controller instance, and resets the action helper broker.

todo Need to update Zend_Layout to add a resetInstance() method

Reset the request object

resetRequest() : \Zend_Test_PHPUnit_ControllerTestCase

Useful for test cases that need to test multiple trips to the server.

Returns

\Zend_Test_PHPUnit_ControllerTestCase

Reset the response object

resetResponse() : \Zend_Test_PHPUnit_ControllerTestCase

Useful for test cases that need to test multiple trips to the server.

Returns

\Zend_Test_PHPUnit_ControllerTestCase

URL Helper

url(array $urlOptions = array(), string $name = null, boolean $reset = false, boolean $encode = true) : string

Parameters

$urlOptions

array

$name

string

$reset

boolean

$encode

boolean

Exceptions

\Exception
\Zend_Controller_Router_Exception

Returns

string

Urlize options

urlizeOptions(array $urlOptions, boolean $actionControllerModuleOnly = true) : mixed

Parameters

$urlOptions

array

$actionControllerModuleOnly

boolean

Returns

mixed

Increment assertion count

_incrementAssertionCount() 

Rest all view placeholders

_resetPlaceholders() 

Set up MVC app

setUp() 

Calls \bootstrap() by default

 Properties

 

Bootstrap file path or callback

$bootstrap : mixed

Default

 

$_frontController

$_frontController : \Zend_Controller_Front

Default

 

$_query

$_query : \Zend_Dom_Query

Default

 

$_request

$_request : \Zend_Controller_Request_Abstract

Default

 

$_response

$_response : \Zend_Controller_Response_Abstract

Default

 

XPath namespaces

$_xpathNamespaces : array

Default

array()