API Documentation

Zend/Test/PHPUnit/ControllerTestCase.php

Show: inherited
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_Test  
Version
$Id: ControllerTestCase.php 24594 2012-01-05 21:27:01Z matthew $  

\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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Uses
\PHPUnit_Framework_TestCase  

Properties

Propertyprotected\Zend_Controller_Front  $_frontController= ''

Details
Type
\Zend_Controller_Front
Propertyprotected\Zend_Dom_Query  $_query= ''

Details
Type
\Zend_Dom_Query
Propertyprotected\Zend_Controller_Request_Abstract  $_request= ''

Propertyprotected\Zend_Controller_Response_Abstract  $_response= ''

Propertyprotectedarray  $_xpathNamespaces= 'array()'

XPath namespaces

Default valuearray()Details
Type
array
Propertypublicmixed  $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
Name Type Description
$name mixed
methodpublic__set( string $name, mixed $value ) : void

Overloading: prevent overloading to special properties

Parameters
Name Type Description
$name string
$value mixed
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
Name Type Description
$action string
$message string
methodpublicassertController( string $controller, string $message = '' ) : void

Assert that the last handled request used the given controller

Parameters
Name Type Description
$controller string
$message string
methodpublicassertHeader( string $header, string $message = '' ) : void

Assert response header exists

Parameters
Name Type Description
$header string
$message string
methodpublicassertHeaderContains( string $header, string $match, string $message = '' ) : void

Assert response header exists and contains the given string

Parameters
Name Type Description
$header string
$match string
$message string
methodpublicassertHeaderRegex( string $header, string $pattern, string $message = '' ) : void

Assert response header exists and matches the given pattern

Parameters
Name Type Description
$header string
$pattern string
$message string
methodpublicassertModule( string $module, string $message = '' ) : void

Assert that the last handled request used the given module

Parameters
Name Type Description
$module string
$message string
methodpublicassertNotAction( string $action, string $message = '' ) : void

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

Parameters
Name Type Description
$action string
$message string
methodpublicassertNotController( string $controller, string $message = '' ) : void

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

Parameters
Name Type Description
$controller string
$message string
methodpublicassertNotHeader( string $header, string $message = '' ) : void

Assert response header does not exist

Parameters
Name Type Description
$header string
$message string
methodpublicassertNotHeaderContains( string $header, string $match, string $message = '' ) : void

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

Parameters
Name Type Description
$header string
$match string
$message string
methodpublicassertNotHeaderRegex( string $header, string $pattern, string $message = '' ) : void

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

Parameters
Name Type Description
$header string
$pattern string
$message string
methodpublicassertNotModule( string $module, string $message = '' ) : void

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

Parameters
Name Type Description
$module string
$message string
methodpublicassertNotQuery( string $path, string $message = '' ) : void

Assert against DOM selection

Parameters
Name Type Description
$path string

CSS selector path

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

Assert against DOM selection; node should NOT contain content

Parameters
Name Type Description
$path string

CSS selector path

$match string

content that should NOT be contained in matched nodes

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

Assert against DOM selection; node should NOT match content

Parameters
Name Type Description
$path string

CSS selector path

$pattern string

pattern that should NOT be contained in matched nodes

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

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

Parameters
Name Type Description
$path string

CSS selector path

$count string

Number of nodes that should NOT match

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

Assert that response is NOT a redirect

Parameters
Name Type Description
$message string
methodpublicassertNotRedirectRegex( string $pattern, string $message = '' ) : void

Assert that redirect location does not match pattern

Parameters
Name Type Description
$pattern string
$message string
methodpublicassertNotRedirectTo( string $url, string $message = '' ) : void

Assert that response does not redirect to given URL

Parameters
Name Type Description
$url string
$message string
methodpublicassertNotResponseCode( int $code, string $message = '' ) : void

Assert response code

Parameters
Name Type Description
$code int
$message string
methodpublicassertNotRoute( string $route, string $message = '' ) : void

Assert that the route matched is NOT as specified

Parameters
Name Type Description
$route string
$message string
methodpublicassertNotXpath( string $path, string $message = '' ) : void

Assert against XPath selection

Parameters
Name Type Description
$path string

XPath path

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

Assert against XPath selection; node should NOT contain content

Parameters
Name Type Description
$path string

XPath path

$match string

content that should NOT be contained in matched nodes

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

Assert against XPath selection; node should NOT match content

Parameters
Name Type Description
$path string

XPath path

$pattern string

pattern that should NOT be contained in matched nodes

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

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

Parameters
Name Type Description
$path string

XPath path

$count string

Number of nodes that should NOT match

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

Assert against DOM selection

Parameters
Name Type Description
$path string

CSS selector path

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

Assert against DOM selection; node should contain content

Parameters
Name Type Description
$path string

CSS selector path

$match string

content that should be contained in matched nodes

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

Assert against DOM selection; node should match content

Parameters
Name Type Description
$path string

CSS selector path

$pattern string

Pattern that should be contained in matched nodes

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

Assert against DOM selection; should contain exact number of nodes

Parameters
Name Type Description
$path string

CSS selector path

$count string

Number of nodes that should match

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

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

Parameters
Name Type Description
$path string

CSS selector path

$count string

Maximum number of nodes that should match

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

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

Parameters
Name Type Description
$path string

CSS selector path

$count string

Minimum number of nodes that should match

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

Assert that response is a redirect

Parameters
Name Type Description
$message string
methodpublicassertRedirectRegex( string $pattern, string $message = '' ) : void

Assert that redirect location matches pattern

Parameters
Name Type Description
$pattern string
$message string
methodpublicassertRedirectTo( string $url, string $message = '' ) : void

Assert that response redirects to given URL

Parameters
Name Type Description
$url string
$message string
methodpublicassertResponseCode( int $code, string $message = '' ) : void

Assert response code

Parameters
Name Type Description
$code int
$message string
methodpublicassertRoute( string $route, string $message = '' ) : void

Assert that the specified route was used

Parameters
Name Type Description
$route string
$message string
methodpublicassertXpath( string $path, string $message = '' ) : void

Assert against XPath selection

Parameters
Name Type Description
$path string

XPath path

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

Assert against XPath selection; node should contain content

Parameters
Name Type Description
$path string

XPath path

$match string

content that should be contained in matched nodes

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

Assert against XPath selection; node should match content

Parameters
Name Type Description
$path string

XPath path

$pattern string

Pattern that should be contained in matched nodes

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

Assert against XPath selection; should contain exact number of nodes

Parameters
Name Type Description
$path string

XPath path

$count string

Number of nodes that should match

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

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

Parameters
Name Type Description
$path string

XPath path

$count string

Maximum number of nodes that should match

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

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

Parameters
Name Type Description
$path string

XPath path

$count string

Minimum number of nodes that should match

$message string
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
Name Type Description
$url string|null
methodpublicgetFrontController( ) : \Zend_Controller_Front

Retrieve front controller instance

Returns
Type Description
\Zend_Controller_Front
methodpublicgetQuery( ) : \Zend_Dom_Query

Retrieve DOM query object

Returns
Type Description
\Zend_Dom_Query
methodpublicgetRequest( ) : \Zend_Controller_Request_HttpTestCase

Retrieve test case request object

Returns
Type Description
\Zend_Controller_Request_HttpTestCase
methodpublicgetResponse( ) : \Zend_Controller_Response_HttpTestCase

Retrieve test case response object

Returns
Type Description
\Zend_Controller_Response_HttpTestCase
methodpublicregisterXpathNamespaces( array $xpathNamespaces ) : void

Register XPath namespaces

Parameters
Name Type Description
$xpathNamespaces array
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
Type Description
\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
Type Description
\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
Name Type Description
$urlOptions array
$name string
$reset bool
$encode bool
methodpublicurlizeOptions(  $urlOptions,  $actionControllerModuleOnly = true ) : void

Parameters
Name Type Description
$urlOptions
$actionControllerModuleOnly
Documentation was generated by DocBlox 0.15.1.