Class IntegrationTestCase
A test case class intended to make integration tests of your controllers easier.
This test class provides a number of helper methods and features that make dispatching requests and checking their responses simpler. It favours full integration tests over mock objects as you can test more of your code easily and avoid some of the maintenance pitfalls that mock objects create.
- PHPUnit\Framework\TestCase
- Cake\TestSuite\TestCase uses Cake\ORM\Locator\LocatorAwareTrait
- Cake\TestSuite\IntegrationTestCase uses Cake\TestSuite\IntegrationTestTrait
Namespace: Cake\TestSuite
Deprecated: 3.7.0 Use Cake\TestSuite\IntegrationTestTrait instead
Location: TestSuite/IntegrationTestCase.php
Inherited Properties
-
_configure
,_pathRestore
,autoFixtures
,dropTables
,fixtureManager
_tableLocator
_appArgs
,_appClass
,_controller
,_cookie
,_cookieEncryptionKey
,_csrfToken
,_exception
,_flashMessages
,_layoutName
,_request
,_requestSession
,_response
,_retainFlashMessages
,_securityToken
,_session
,_useHttpServer
,_viewName
Methods inherited from Cake\TestSuite\TestCase
_assertAttributes()source protected
_assertAttributes( array $assertions , string $string , boolean $fullDebug = false , array|string $regex = '' )
Check the attributes as part of an assertTags() check.
Parameters
- array
$assertions
- Assertions to run.
- string
$string
- The HTML string to check.
- boolean
$fullDebug
optional false - Whether or not more verbose output should be used.
- array|string
$regex
optional '' - Full regexp from
assertHtml
Returns
string|boolean_getTableClassName()source protected
_getTableClassName( string $alias , array $options )
Gets the class name for the table.
Parameters
- string
$alias
- The model to get a mock for.
- array
$options
- The config data for the mock's constructor.
Returns
stringThrows
Cake\ORM\Exception\MissingTableClassException
_normalizePath()source protected
_normalizePath( string $path )
Normalize a path for comparison.
Parameters
- string
$path
- Path separated by "/" slash.
Returns
stringNormalized path separated by DIRECTORY_SEPARATOR.
assertEventFired()source public
assertEventFired( string $name , Cake\Event\EventManager|null $eventManager = null , string $message = '' )
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
Parameters
- string
$name
- Event name
-
Cake\Event\EventManager
|null$eventManager
optional null - Event manager to check, defaults to global event manager
- string
$message
optional '' - Assertion failure message
assertEventFiredWith()source public
assertEventFiredWith( string $name , string $dataKey , string $dataValue , Cake\Event\EventManager|null $eventManager = null , string $message = '' )
Asserts an event was fired with data
If a third argument is passed, that value is used to compare with the value in $dataKey
Parameters
- string
$name
- Event name
- string
$dataKey
- Data key
- string
$dataValue
- Data value
-
Cake\Event\EventManager
|null$eventManager
optional null - Event manager to check, defaults to global event manager
- string
$message
optional '' - Assertion failure message
assertHtml()source public
assertHtml( array $expected , string $string , boolean $fullDebug = false )
Asserts HTML tags.
Takes an array $expected and generates a regex from it to match the provided $string. Samples for $expected:
Checks for an input tag with a name attribute (contains any non-empty value) and an id attribute that contains 'my-input':
['input' => ['name', 'id' => 'my-input']]
Checks for two p elements with some text in them:
[ ['p' => true], 'textA', '/p', ['p' => true], 'textB', '/p' ]
You can also specify a pattern expression as part of the attribute values, or the tag being defined, if you prepend the value with preg: and enclose it with slashes, like so:
[ ['input' => ['name', 'id' => 'preg:/FieldName\d+/']], 'preg:/My\s+field/' ]
Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order. It will also allow whitespace between specified tags.
Parameters
- array
$expected
- An array, see above
- string
$string
- An HTML/XHTML/XML string
- boolean
$fullDebug
optional false - Whether or not more verbose output should be used.
Returns
booleanassertNotWithinRange()source protected static
assertNotWithinRange( float $expected , float $result , float $margin , string $message = '' )
Compatibility function to test if a value is not between an acceptable range.
Parameters
- float
$expected
- float
$result
- float
$margin
- the rage of acceptation
- string
$message
optional '' - the text to display if the assertion is not correct
assertPathEquals()source protected static
assertPathEquals( string $expected , string $result , string $message = '' )
Compatibility function to test paths.
Parameters
- string
$expected
- string
$result
- string
$message
optional '' - the text to display if the assertion is not correct
assertTags()source public deprecated
assertTags( string $string , array $expected , boolean $fullDebug = false )
Asserts HTML tags.
Parameters
- string
$string
- An HTML/XHTML/XML string
- array
$expected
- An array, see above
- boolean
$fullDebug
optional false - Whether or not more verbose output should be used.
assertTextContains()source public
assertTextContains( string $needle , string $haystack , string $message = '' , boolean $ignoreCase = false )
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$needle
- The string to search for.
- string
$haystack
- The string to search through.
- string
$message
optional '' - The message to display on failure.
- boolean
$ignoreCase
optional false - Whether or not the search should be case-sensitive.
assertTextEndsNotWith()source public
assertTextEndsNotWith( string $suffix , string $string , string $message = '' )
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$suffix
- The suffix to not find.
- string
$string
- The string to search.
- string
$message
optional '' - The message to use for failure.
assertTextEndsWith()source public
assertTextEndsWith( string $suffix , string $string , string $message = '' )
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$suffix
- The suffix to find.
- string
$string
- The string to search.
- string
$message
optional '' - The message to use for failure.
assertTextEquals()source public
assertTextEquals( string $expected , string $result , string $message = '' )
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$expected
- The expected value.
- string
$result
- The actual value.
- string
$message
optional '' - The message to use for failure.
assertTextNotContains()source public
assertTextNotContains( string $needle , string $haystack , string $message = '' , boolean $ignoreCase = false )
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$needle
- The string to search for.
- string
$haystack
- The string to search through.
- string
$message
optional '' - The message to display on failure.
- boolean
$ignoreCase
optional false - Whether or not the search should be case-sensitive.
assertTextNotEquals()source public
assertTextNotEquals( string $expected , string $result , string $message = '' )
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$expected
- The expected value.
- string
$result
- The actual value.
- string
$message
optional '' - The message to use for failure.
assertTextStartsNotWith()source public
assertTextStartsNotWith( string $prefix , string $string , string $message = '' )
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$prefix
- The prefix to not find.
- string
$string
- The string to search.
- string
$message
optional '' - The message to use for failure.
assertTextStartsWith()source public
assertTextStartsWith( string $prefix , string $string , string $message = '' )
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
- string
$prefix
- The prefix to check for.
- string
$string
- The string to search in.
- string
$message
optional '' - The message to use for failure.
assertWithinRange()source protected static
assertWithinRange( float $expected , float $result , float $margin , string $message = '' )
Compatibility function to test if a value is between an acceptable range.
Parameters
- float
$expected
- float
$result
- float
$margin
- the rage of acceptation
- string
$message
optional '' - the text to display if the assertion is not correct
clearPlugins()source public
clearPlugins( )
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
deprecated()source public
deprecated( callable $callable )
Helper method for check deprecation methods
Parameters
- callable
$callable
- callable function that will receive asserts
getMockForModel()source public
getMockForModel( string $alias , array|null $methods = [] , array $options = [] )
Mock a model, maintain fixtures and table association
Parameters
- string
$alias
- The model to get a mock for.
- array|null
$methods
optional [] - The list of methods to mock
- array
$options
optional [] - The config data for the mock's constructor.
Returns
Cake\ORM\Table
|PHPUnit_Framework_MockObject_MockObjectThrows
Cake\ORM\Exception\MissingTableClassException
loadFixtures()source public
loadFixtures( )
Chooses which fixtures to load for a given test
Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc. Passing no parameters will cause all fixtures on the test case to load.
Throws
Exceptionwhen no fixture manager is available.
See
\Cake\TestSuite\TestCase::$autoFixturesloadPlugins()source public
loadPlugins( array $plugins = [] )
Load plugins into a simulated application.
Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.
Parameters
- array
$plugins
optional [] - List of Plugins to load.
Returns
Cake\Http\BaseApplication
removePlugins()source public
removePlugins( array $plugins = [] )
Remove plugins from the global plugin collection.
Useful in test case teardown methods.
Parameters
- array
$plugins
optional [] - A list of plugins you want to remove.
setAppNamespace()source public static
setAppNamespace( string $appNamespace = 'TestApp' )
Set the app namespace
Parameters
- string
$appNamespace
optional 'TestApp' - The app namespace, defaults to "TestApp".
setUp()source public
setUp( )
Setup the test case, backup the static object values so they can be restored. Specifically backs up the contents of Configure and paths in App if they have not already been backed up.
skipIf()source public
skipIf( boolean $shouldSkip , string $message = '' )
Overrides SimpleTestCase::skipIf to provide a boolean return value
Parameters
- boolean
$shouldSkip
- Whether or not the test should be skipped.
- string
$message
optional '' - The message to display.
Returns
booleanskipUnless()source protected
skipUnless( boolean $condition , string $message = '' )
Compatibility function for skipping.
Parameters
- boolean
$condition
- Condition to trigger skipping
- string
$message
optional '' - Message for skip
Returns
booleanwithErrorReporting()source public
withErrorReporting( integer $errorLevel , callable $callable )
Helper method for tests that needs to use error_reporting()
Parameters
- integer
$errorLevel
- value of error_reporting() that needs to use
- callable
$callable
- callable function that will receive asserts
Methods used from Cake\TestSuite\IntegrationTestTrait
_addTokens()source protected
_addTokens( string $url , array $data )
Add the CSRF and Security Component tokens if necessary.
Parameters
- string
$url
- The URL the form is being submitted on.
- array
$data
- The request body data.
Returns
arrayThe request body with tokens added.
_buildRequest()source protected
_buildRequest( string|array $url , string $method , string|array|null $data )
Creates a request object with the configured options and parameters.
Parameters
- string|array
$url
- The URL
- string
$method
- The HTTP method
- string|array|null
$data
- The request data.
Returns
arrayThe request context
_castToString()source protected
_castToString( array $data )
Recursively casts all data to string as that is how data would be POSTed in the real world
Parameters
- array
$data
- POST data
Returns
array_getBodyAsString()source protected
_getBodyAsString( )
Get the response body as string
Returns
stringThe response body.
_getCookieEncryptionKey()source protected
_getCookieEncryptionKey( )
Returns the encryption key to be used.
Returns
string_handleError()source protected
_handleError( Exception $exception )
Attempts to render an error response for a given exception.
This method will attempt to use the configured exception renderer. If that class does not exist, the built-in renderer will be used.
Parameters
- Exception
$exception
- Exception to handle.
Throws
Exception_makeDispatcher()source protected
_makeDispatcher( )
Get the correct dispatcher instance.
Returns
Cake\TestSuite\MiddlewareDispatcher|Cake\TestSuite\LegacyRequestDispatcherA dispatcher instance
_sendRequest()source protected
_sendRequest( string|array $url , string $method , string|array|null $data = [] )
Creates and send the request into a Dispatcher instance.
Receives and stores the response for future inspection.
Parameters
- string|array
$url
- The URL
- string
$method
- The HTTP method
- string|array|null
$data
optional [] - The request data.
Throws
PHPUnit\Exception_url()source protected
_url( string|array $url )
Creates a valid request url and parameter array more like Request::_url()
Parameters
- string|array
$url
- The URL
Returns
arrayQualified URL, the query parameters, and host data
assertContentType()source public
assertContentType( string $type , string $message = '' )
Asserts content type
Parameters
- string
$type
- The content-type to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertCookie()source public
assertCookie( string $expected , string $name , string $message = '' )
Asserts cookie values
Parameters
- string
$expected
- The expected contents.
- string
$name
- The cookie name.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertCookieEncrypted()source public
assertCookieEncrypted( string $expected , string $name , string|boolean $encrypt = 'aes' , string|null $key = null , string $message = '' )
Asserts cookie values which are encrypted by the CookieComponent.
The difference from assertCookie() is this decrypts the cookie value like the CookieComponent for this assertion.
Parameters
- string
$expected
- The expected contents.
- string
$name
- The cookie name.
- string|boolean
$encrypt
optional 'aes' - Encryption mode to use.
- string|null
$key
optional null Encryption key used. Defaults to Security.salt.
- string
$message
optional '' - The failure message that will be appended to the generated message.
See
\Cake\Utility\CookieCryptTrait::_encrypt()assertCookieNotSet()source public
assertCookieNotSet( string $cookie , string $message = '' )
Asserts a cookie has not been set in the response
Parameters
- string
$cookie
- The cookie name to check
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertFileResponse()source public
assertFileResponse( string $expected , string $message = '' )
Asserts that a file with the given name was sent in the response
Parameters
- string
$expected
- The absolute file path that should be sent in the response.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertFlashElement()source public
assertFlashElement( string $expected , string $key = 'flash' , string $message = '' )
Asserts a flash element was set
Parameters
- string
$expected
- Expected element name
- string
$key
optional 'flash' - Flash key
- string
$message
optional '' - Assertion failure message
assertFlashElementAt()source public
assertFlashElementAt( integer $at , string $expected , string $key = 'flash' , string $message = '' )
Asserts a flash element was set at a certain index
Parameters
- integer
$at
- Flash index
- string
$expected
- Expected element name
- string
$key
optional 'flash' - Flash key
- string
$message
optional '' - Assertion failure message
assertFlashMessage()source public
assertFlashMessage( string $expected , string $key = 'flash' , string $message = '' )
Asserts a flash message was set
Parameters
- string
$expected
- Expected message
- string
$key
optional 'flash' - Flash key
- string
$message
optional '' - Assertion failure message
assertFlashMessageAt()source public
assertFlashMessageAt( integer $at , string $expected , string $key = 'flash' , string $message = '' )
Asserts a flash message was set at a certain index
Parameters
- integer
$at
- Flash index
- string
$expected
- Expected message
- string
$key
optional 'flash' - Flash key
- string
$message
optional '' - Assertion failure message
assertHeader()source public
assertHeader( string $header , string $content , string $message = '' )
Asserts response headers
Parameters
- string
$header
- The header to check
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertHeaderContains()source public
assertHeaderContains( string $header , string $content , string $message = '' )
Asserts response header contains a string
Parameters
- string
$header
- The header to check
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertHeaderNotContains()source public
assertHeaderNotContains( string $header , string $content , string $message = '' )
Asserts response header does not contain a string
Parameters
- string
$header
- The header to check
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertLayout()source public
assertLayout( string $content , string $message = '' )
Asserts that the search string was in the layout name.
Parameters
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertNoRedirect()source public
assertNoRedirect( string $message = '' )
Asserts that the Location header is not set.
Parameters
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertRedirect()source public
assertRedirect( string|array|null $url = null , string $message = '' )
Asserts that the Location header is correct.
Parameters
- string|array|null
$url
optional null The URL you expected the client to go to. This can either be a string URL or an array compatible with Router::url(). Use null to simply check for the existence of this header.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertRedirectContains()source public
assertRedirectContains( string $url , string $message = '' )
Asserts that the Location header contains a substring
Parameters
- string
$url
- The URL you expected the client to go to.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertRedirectNotContains()source public
assertRedirectNotContains( string $url , string $message = '' )
Asserts that the Location header does not contain a substring
Parameters
- string
$url
- The URL you expected the client to go to.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseCode()source public
assertResponseCode( integer $code , string $message = null )
Asserts a specific response status code.
Parameters
- integer
$code
- Status code to assert.
- string
$message
optional null - Custom message for failure.
assertResponseContains()source public
assertResponseContains( string $content , string $message = '' , boolean $ignoreCase = false )
Asserts content exists in the response body.
Parameters
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
- boolean
$ignoreCase
optional false - A flag to check whether we should ignore case or not.
assertResponseEmpty()source public
assertResponseEmpty( string $message = '' )
Assert response content is empty.
Parameters
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseEquals()source public
assertResponseEquals( mixed $content , string $message = '' )
Asserts content in the response body equals.
Parameters
- mixed
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseError()source public
assertResponseError( string $message = null )
Asserts that the response status code is in the 4xx range.
Parameters
- string
$message
optional null - Custom message for failure.
assertResponseFailure()source public
assertResponseFailure( string $message = null )
Asserts that the response status code is in the 5xx range.
Parameters
- string
$message
optional null - Custom message for failure.
assertResponseNotContains()source public
assertResponseNotContains( string $content , string $message = '' , boolean $ignoreCase = false )
Asserts content does not exist in the response body.
Parameters
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
- boolean
$ignoreCase
optional false - A flag to check whether we should ignore case or not.
assertResponseNotEmpty()source public
assertResponseNotEmpty( string $message = '' )
Assert response content is not empty.
Parameters
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseNotEquals()source public
assertResponseNotEquals( mixed $content , string $message = '' )
Asserts content in the response body not equals.
Parameters
- mixed
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseNotRegExp()source public
assertResponseNotRegExp( string $pattern , string $message = '' )
Asserts that the response body does not match a given regular expression.
Parameters
- string
$pattern
- The pattern to compare against.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseOk()source public
assertResponseOk( string $message = null )
Asserts that the response status code is in the 2xx range.
Parameters
- string
$message
optional null - Custom message for failure.
assertResponseRegExp()source public
assertResponseRegExp( string $pattern , string $message = '' )
Asserts that the response body matches a given regular expression.
Parameters
- string
$pattern
- The pattern to compare against.
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertResponseSuccess()source public
assertResponseSuccess( string $message = null )
Asserts that the response status code is in the 2xx/3xx range.
Parameters
- string
$message
optional null - Custom message for failure.
assertSession()source public
assertSession( string $expected , string $path , string $message = '' )
Asserts session contents
Parameters
- string
$expected
- The expected contents.
- string
$path
- The session data path. Uses Hash::get() compatible notation
- string
$message
optional '' - The failure message that will be appended to the generated message.
assertTemplate()source public
assertTemplate( string $content , string $message = '' )
Asserts that the search string was in the template name.
Parameters
- string
$content
- The content to check for.
- string
$message
optional '' - The failure message that will be appended to the generated message.
configApplication()source public
configApplication( string $class , array|null $constructorArgs )
Configure the application class to use in integration tests.
Combined with useHttpServer()
to customize the class name and constructor arguments of your application class.
Parameters
- string
$class
- The application class name.
- array|null
$constructorArgs
- The constructor arguments for your application class.
configRequest()source public
configRequest( array $data )
Configures the data for the next request.
This data is cleared in the tearDown() method.
You can call this method multiple times to append into the current state.
Parameters
- array
$data
- The request data to use.
controllerSpy()source public
controllerSpy( Cake\Event\Event $event , Cake\Controller\Controller|null $controller = null )
Adds additional event spies to the controller/view event manager.
Parameters
-
Cake\Event\Event
$event
- A dispatcher event.
-
Cake\Controller\Controller
|null$controller
optional null - Controller instance.
cookie()source public
cookie( string $name , mixed $value )
Sets a request cookie for future requests.
This method lets you configure the session data you want to be used for requests that follow. The session state is reset in each tearDown().
You can call this method multiple times to append into the current state.
Parameters
- string
$name
- The cookie name to use.
- mixed
$value
- The value of the cookie.
cookieEncrypted()source public
cookieEncrypted( string $name , mixed $value , string|boolean $encrypt = 'aes' , string|null $key = null )
Sets a encrypted request cookie for future requests.
The difference from cookie() is this encrypts the cookie value like the CookieComponent.
Parameters
- string
$name
- The cookie name to use.
- mixed
$value
- The value of the cookie.
- string|boolean
$encrypt
optional 'aes' - Encryption mode to use.
- string|null
$key
optional null Encryption key used. Defaults to Security.salt.
See
\Cake\Utility\CookieCryptTrait::_encrypt()delete()source public
delete( string|array $url )
Performs a DELETE request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
Throws
PHPUnit\ExceptiondisableErrorHandlerMiddleware()source public
disableErrorHandlerMiddleware( )
Disable the error handler middleware.
By using this function, exceptions are no longer caught by the ErrorHandlerMiddleware and are instead re-thrown by the TestExceptionRenderer. This can be helpful when trying to diagnose/debug unexpected failures in test cases.
enableCsrfToken()source public
enableCsrfToken( )
Calling this method will add a CSRF token to the request.
Both the POST data and cookie will be populated when this option is enabled. The default parameter names will be used.
enableRetainFlashMessages()source public
enableRetainFlashMessages( )
Calling this method will re-store flash messages into the test session after being removed by the FlashHelper
enableSecurityToken()source public
enableSecurityToken( )
Calling this method will enable a SecurityComponent compatible token to be added to request data. This lets you easily test actions protected by SecurityComponent.
extractExceptionMessage()source protected
extractExceptionMessage( Exception $exception )
Extract verbose message for existing exception
Parameters
- Exception
$exception
- Exception to extract
Returns
stringextractVerboseMessage()source protected
extractVerboseMessage( string $message = null )
Inspect controller to extract possible causes of the failed assertion
Parameters
- string
$message
optional null - Original message to use as a base
Returns
null|stringget()source public
get( string|array $url )
Performs a GET request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
Throws
PHPUnit\Exceptionhead()source public
head( string|array $url )
Performs a HEAD request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
Throws
PHPUnit\Exceptionoptions()source public
options( string|array $url )
Performs an OPTIONS request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
Throws
PHPUnit\Exceptionpatch()source public
patch( string|array $url , string|array|null $data = [] )
Performs a PATCH request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
- string|array|null
$data
optional [] - The data for the request.
Throws
PHPUnit\Exceptionpost()source public
post( string|array $url , string|array|null $data = [] )
Performs a POST request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
- string|array|null
$data
optional [] - The data for the request.
Throws
PHPUnit\Exceptionput()source public
put( string|array $url , string|array|null $data = [] )
Performs a PUT request using the current request data.
The response of the dispatched request will be stored as a property. You can use various assert methods to check the response.
Parameters
- string|array
$url
- The URL to request.
- string|array|null
$data
optional [] - The data for the request.
Throws
PHPUnit\Exceptionsession()source public
session( array $data )
Sets session data.
This method lets you configure the session data you want to be used for requests that follow. The session state is reset in each tearDown().
You can call this method multiple times to append into the current state.
Parameters
- array
$data
- The session data to use.
setupServer()source public
setupServer( )
Auto-detect if the HTTP middleware stack should be used.
Before
useHttpServer()source public
useHttpServer( boolean $enable )
Toggle whether or not you want to use the HTTP Server stack.
Parameters
- boolean
$enable
- Enable/disable the usage of the HTTP Stack.
viewVariable()source public
viewVariable( string $name )
Fetches a view variable by name.
If the view variable does not exist, null will be returned.
Parameters
- string
$name
- The view variable to get.
Returns
mixedThe view variable if set.
Methods used from Cake\ORM\Locator\LocatorAwareTrait
getTableLocator()source public
getTableLocator( )
Gets the table locator.
Returns
Cake\ORM\Locator\LocatorInterface
setTableLocator()source public
setTableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator )
Sets the table locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface
$tableLocator
- LocatorInterface instance.
Returns
$this
tableLocator()source public deprecated
tableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator = null )
Sets the table locator. If no parameters are passed, it will return the currently used locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface
$tableLocator
optional null - LocatorInterface instance.
Returns
Cake\ORM\Locator\LocatorInterface
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.7/class-Cake.TestSuite.IntegrationTestCase.html