API Documentation

Test/PHPUnit/ControllerTestCase.php

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-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Test  
version
$Id: ControllerTestCase.php 24213 2011-07-08 21:16:45Z rdohms $  

\Zend_Test_PHPUnit_ControllerTestCase

Functional testing scaffold for MVC applications

Extends from
\PHPUnit_Framework_TestCase
category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Test  
subpackage
PHPUnit  
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 valuearrayDetails
Type
array
Propertypublicmixed  $bootstrap= ''

Bootstrap file path or callback
Details
Type
mixed

Methods

methodpublic__construct( ) : void

Inherited from:
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

methodpublicaddToAssertionCount( ) : void

Inherited from:
methodpublicany( ) : void
static

Inherited from:
methodpublicanything( ) : void
static

Inherited from:
methodpublicarrayHasKey( ) : void
static

Inherited from:
methodpublicassertAction( string $action, string $message ) : void

Assert that the last handled request used the given action

Parameters
Name Type Description
$action string
$message string
methodpublicassertArrayHasKey( ) : void
static

Inherited from:
methodpublicassertArrayNotHasKey( ) : void
static

Inherited from:
methodpublicassertAttributeContains( ) : void
static

Inherited from:
methodpublicassertAttributeContainsOnly( ) : void
static

Inherited from:
methodpublicassertAttributeEmpty( ) : void
static

Inherited from:
methodpublicassertAttributeEquals( ) : void
static

Inherited from:
methodpublicassertAttributeGreaterThan( ) : void
static

Inherited from:
methodpublicassertAttributeGreaterThanOrEqual( ) : void
static

Inherited from:
methodpublicassertAttributeInstanceOf( ) : void
static

Inherited from:
methodpublicassertAttributeInternalType( ) : void
static

Inherited from:
methodpublicassertAttributeLessThan( ) : void
static

Inherited from:
methodpublicassertAttributeLessThanOrEqual( ) : void
static

Inherited from:
methodpublicassertAttributeNotContains( ) : void
static

Inherited from:
methodpublicassertAttributeNotContainsOnly( ) : void
static

Inherited from:
methodpublicassertAttributeNotEmpty( ) : void
static

Inherited from:
methodpublicassertAttributeNotEquals( ) : void
static

Inherited from:
methodpublicassertAttributeNotInstanceOf( ) : void
static

Inherited from:
methodpublicassertAttributeNotInternalType( ) : void
static

Inherited from:
methodpublicassertAttributeNotSame( ) : void
static

Inherited from:
methodpublicassertAttributeNotType( ) : void
static

Inherited from:
methodpublicassertAttributeSame( ) : void
static

Inherited from:
methodpublicassertAttributeType( ) : void
static

Inherited from:
methodpublicassertClassHasAttribute( ) : void
static

Inherited from:
methodpublicassertClassHasStaticAttribute( ) : void
static

Inherited from:
methodpublicassertClassNotHasAttribute( ) : void
static

Inherited from:
methodpublicassertClassNotHasStaticAttribute( ) : void
static

Inherited from:
methodpublicassertContains( ) : void
static

Inherited from:
methodpublicassertContainsOnly( ) : void
static

Inherited from:
methodpublicassertController( string $controller, string $message ) : void

Assert that the last handled request used the given controller

Parameters
Name Type Description
$controller string
$message string
methodpublicassertEmpty( ) : void
static

Inherited from:
methodpublicassertEqualXMLStructure( ) : void
static

Inherited from:
methodpublicassertEquals( ) : void
static

Inherited from:
methodpublicassertFalse( ) : void
static

Inherited from:
methodpublicassertFileEquals( ) : void
static

Inherited from:
methodpublicassertFileExists( ) : void
static

Inherited from:
methodpublicassertFileNotEquals( ) : void
static

Inherited from:
methodpublicassertFileNotExists( ) : void
static

Inherited from:
methodpublicassertGreaterThan( ) : void
static

Inherited from:
methodpublicassertGreaterThanOrEqual( ) : void
static

Inherited from:
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
methodpublicassertInstanceOf( ) : void
static

Inherited from:
methodpublicassertInternalType( ) : void
static

Inherited from:
methodpublicassertLessThan( ) : void
static

Inherited from:
methodpublicassertLessThanOrEqual( ) : void
static

Inherited from:
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
methodpublicassertNotContains( ) : void
static

Inherited from:
methodpublicassertNotContainsOnly( ) : void
static

Inherited from:
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
methodpublicassertNotEmpty( ) : void
static

Inherited from:
methodpublicassertNotEquals( ) : void
static

Inherited from:
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
methodpublicassertNotInstanceOf( ) : void
static

Inherited from:
methodpublicassertNotInternalType( ) : void
static

Inherited from:
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
methodpublicassertNotNull( ) : void
static

Inherited from:
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
methodpublicassertNotRegExp( ) : void
static

Inherited from:
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
methodpublicassertNotSame( ) : void
static

Inherited from:
methodpublicassertNotTag( ) : void
static

Inherited from:
methodpublicassertNotType( ) : void
static

Inherited from:
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
methodpublicassertNull( ) : void
static

Inherited from:
methodpublicassertObjectHasAttribute( ) : void
static

Inherited from:
methodpublicassertObjectNotHasAttribute( ) : void
static

Inherited from:
methodprotectedassertPostConditions( ) : void

Inherited from:
methodprotectedassertPreConditions( ) : void

Inherited from:
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
methodpublicassertRegExp( ) : void
static

Inherited from:
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
methodpublicassertSame( ) : void
static

Inherited from:
methodpublicassertSelectCount( ) : void
static

Inherited from:
methodpublicassertSelectEquals( ) : void
static

Inherited from:
methodpublicassertSelectRegExp( ) : void
static

Inherited from:
methodpublicassertStringEndsNotWith( ) : void
static

Inherited from:
methodpublicassertStringEndsWith( ) : void
static

Inherited from:
methodpublicassertStringEqualsFile( ) : void
static

Inherited from:
methodpublicassertStringMatchesFormat( ) : void
static

Inherited from:
methodpublicassertStringMatchesFormatFile( ) : void
static

Inherited from:
methodpublicassertStringNotEqualsFile( ) : void
static

Inherited from:
methodpublicassertStringNotMatchesFormat( ) : void
static

Inherited from:
methodpublicassertStringNotMatchesFormatFile( ) : void
static

Inherited from:
methodpublicassertStringStartsNotWith( ) : void
static

Inherited from:
methodpublicassertStringStartsWith( ) : void
static

Inherited from:
methodpublicassertTag( ) : void
static

Inherited from:
methodpublicassertThat( ) : void
static

Inherited from:
methodpublicassertTrue( ) : void
static

Inherited from:
methodpublicassertType( ) : void
static

Inherited from:
methodpublicassertXmlFileEqualsXmlFile( ) : void
static

Inherited from:
methodpublicassertXmlFileNotEqualsXmlFile( ) : void
static

Inherited from:
methodpublicassertXmlStringEqualsXmlFile( ) : void
static

Inherited from:
methodpublicassertXmlStringEqualsXmlString( ) : void
static

Inherited from:
methodpublicassertXmlStringNotEqualsXmlFile( ) : void
static

Inherited from:
methodpublicassertXmlStringNotEqualsXmlString( ) : void
static

Inherited from:
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
methodpublicat( ) : void
static

Inherited from:
methodpublicatLeastOnce( ) : void
static

Inherited from:
methodpublicattribute( ) : void
static

Inherited from:
methodpublicattributeEqualTo( ) : void
static

Inherited from:
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.

methodpublicclassHasAttribute( ) : void
static

Inherited from:
methodpublicclassHasStaticAttribute( ) : void
static

Inherited from:
methodpubliccontains( ) : void
static

Inherited from:
methodpubliccontainsOnly( ) : void
static

Inherited from:
methodpubliccount( ) : void

Inherited from:
methodprotectedcreateResult( ) : void

Inherited from:
methodprotecteddataToString( ) : void

Inherited from:
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
methodpublicequalTo( ) : void
static

Inherited from:
methodpublicexactly( ) : void
static

Inherited from:
methodpublicfail( ) : void
static

Inherited from:
methodpublicfileExists( ) : void
static

Inherited from:
methodpublicgetAnnotations( ) : void

Inherited from:
methodpublicgetCount( ) : void
static

Inherited from:
methodprotectedgetDataSetAsString( ) : void

Inherited from:
methodpublicgetExpectedException( ) : void

Inherited from:
methodpublicgetFrontController( ) : \Zend_Controller_Front

Retrieve front controller instance

Returns
Type Description
\Zend_Controller_Front
methodpublicgetMock( ) : void

Inherited from:
methodpublicgetMockBuilder( ) : void

Inherited from:
methodprotectedgetMockClass( ) : void

Inherited from:
methodpublicgetMockForAbstractClass( ) : void

Inherited from:
methodprotectedgetMockFromWsdl( ) : void

Inherited from:
methodpublicgetName( ) : void

Inherited from:
methodpublicgetNumAssertions( ) : void

Inherited from:
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
methodpublicgetResult( ) : void

Inherited from:
methodpublicgetStatus( ) : void

Inherited from:
methodpublicgetStatusMessage( ) : void

Inherited from:
methodpublicgetTestResultObject( ) : void

Inherited from:
methodpublicgreaterThan( ) : void
static

Inherited from:
methodpublicgreaterThanOrEqual( ) : void
static

Inherited from:
methodprotectedhandleDependencies( ) : void

Inherited from:
methodpublichasFailed( ) : void

Inherited from:
methodpublicidenticalTo( ) : void
static

Inherited from:
methodprotectediniSet( ) : void

Inherited from:
methodpublicisEmpty( ) : void
static

Inherited from:
methodpublicisFalse( ) : void
static

Inherited from:
methodpublicisInstanceOf( ) : void
static

Inherited from:
methodpublicisNull( ) : void
static

Inherited from:
methodpublicisTrue( ) : void
static

Inherited from:
methodpublicisType( ) : void
static

Inherited from:
methodpubliclessThan( ) : void
static

Inherited from:
methodpubliclessThanOrEqual( ) : void
static

Inherited from:
methodpubliclogicalAnd( ) : void
static

Inherited from:
methodpubliclogicalNot( ) : void
static

Inherited from:
methodpubliclogicalOr( ) : void
static

Inherited from:
methodpubliclogicalXor( ) : void
static

Inherited from:
methodpublicmarkTestIncomplete( ) : void
static

Inherited from:
methodpublicmarkTestSkipped( ) : void
static

Inherited from:
methodpublicmatches( ) : void
static

Inherited from:
methodpublicmatchesRegularExpression( ) : void
static

Inherited from:
methodpublicnever( ) : void
static

Inherited from:
methodpublicobjectHasAttribute( ) : void
static

Inherited from:
methodpubliconConsecutiveCalls( ) : void
static

Inherited from:
methodprotectedonNotSuccessfulTest( ) : void

Inherited from:
methodpubliconce( ) : void
static

Inherited from:
methodprotectedprepareTemplate( ) : void

Inherited from:
methodpublicreadAttribute( ) : void
static

Inherited from:
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  
methodpublicresetCount( ) : void
static

Inherited from:
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
methodpublicreturnArgument( ) : void
static

Inherited from:
methodpublicreturnCallback( ) : void
static

Inherited from:
methodpublicreturnValue( ) : void
static

Inherited from:
methodpublicrun( ) : void

Inherited from:
methodpublicrunBare( ) : void

Inherited from:
methodprotectedrunTest( ) : void

Inherited from:
methodpublicsetBackupGlobals( ) : void

Inherited from:
methodpublicsetBackupStaticAttributes( ) : void

Inherited from:
methodpublicsetDependencies( ) : void

Inherited from:
methodpublicsetDependencyInput( ) : void

Inherited from:
methodpublicsetExpectedException( ) : void

Inherited from:
methodprotectedsetExpectedExceptionFromAnnotation( ) : void

Inherited from:
methodpublicsetInIsolation( ) : void

Inherited from:
methodprotectedsetLocale( ) : void

Inherited from:
methodpublicsetName( ) : void

Inherited from:
methodpublicsetPreserveGlobalState( ) : void

Inherited from:
methodpublicsetResult( ) : void

Inherited from:
methodpublicsetRunTestInSeparateProcess( ) : void

Inherited from:
methodprotectedsetUp( ) : void

Set up MVC app

Calls {@link bootstrap()} by default

methodpublicsetUpBeforeClass( ) : void
static

Inherited from:
methodpublicsetUseErrorHandler( ) : void

Inherited from:
methodprotectedsetUseErrorHandlerFromAnnotation( ) : void

Inherited from:
methodpublicsetUseOutputBuffering( ) : void

Inherited from:
methodprotectedsetUseOutputBufferingFromAnnotation( ) : void

Inherited from:
methodpublicstringContains( ) : void
static

Inherited from:
methodpublicstringEndsWith( ) : void
static

Inherited from:
methodpublicstringStartsWith( ) : void
static

Inherited from:
methodpublicsyntheticFail( ) : void
static

Inherited from:
methodprotectedtearDown( ) : void

Inherited from:
methodpublictearDownAfterClass( ) : void
static

Inherited from:
methodpublicthrowException( ) : void
static

Inherited from:
methodpublictoString( ) : void

Inherited from:
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
methodprotectedverifyMockObjects( ) : void

Inherited from:
Documentation was generated by DocBlox 0.13.3.