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.
Property Summary
- 
        $_configure protectedarrayConfigure values to restore at end of test. 
- 
        $_controller protectedCake\Controller\ControllerThe controller used in the last request. 
- 
        $_cookie protectedarrayCookie data to use in the next request. 
- 
        $_cookieEncriptionKey protectednull|string
- 
        $_csrfToken protectedboolBoolean flag for whether or not the request should have a CSRF token added. 
- 
        $_exception protectedCake\Core\Exception\ExceptionThe exception being thrown if the case. 
- 
        $_layoutName protectedstringThe last rendered layout 
- 
        $_pathRestore protectedarrayPath settings to restore at the end of the test. 
- 
        $_request protectedarrayThe data used to build the next request. 
- 
        $_requestSession protectedCake\Network\SessionThe session instance from the last request 
- 
        $_response protectedCake\Network\ResponseThe response for the most recent request. 
- 
        $_securityToken protectedboolBoolean flag for whether or not the request should have a SecurityComponent token added. 
- 
        $_session protectedarraySession data to use in the next request. 
- 
        $_validCiphers protectedarrayValid cipher names for encrypted cookies. 
- 
        $_viewName protectedstringThe last rendered view 
- 
        $autoFixtures publicarrayBy default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually 
- 
        $dropTables publicboolControl table create/drops on each test method. 
- 
        $fixtureManager publicCake\TestSuite\Fixture\FixtureManagerThe class responsible for managing the creation, loading and removing of fixtures 
Method Summary
- 
          _addTokens() protectedAdd the CSRF and Security Component tokens if necessary. 
- 
          _assertAttributes() protectedCheck the attributes as part of an assertTags() check. 
- 
          _assertStatus() protectedHelper method for status assertions. 
- 
          _buildFieldToken() protectedGenerate the token data for the provided inputs. 
- 
          _buildRequest() protectedCreates a request object with the configured options and parameters. 
- 
          _checkCipher() protectedHelper method for validating encryption cipher names. 
- 
          _decode() protectedDecodes and decrypts a single value. 
- 
          _decrypt() protectedDecrypts $value using public $type method in Security class 
- 
          _encrypt() protectedEncrypts $value using public $type method in Security class 
- 
          _explode() protectedExplode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode(). 
- 
          _getCookieEncryptionKey() protectedReturns the encryption key to be used. 
- 
          _handleError() protectedAttempts to render an error response for a given exception. 
- 
          _implode() protectedImplode method to keep keys are multidimensional arrays 
- 
          _normalizePath() protectedNormalize a path for comparison. 
- 
          _sendRequest() protectedCreates and send the request into a Dispatcher instance. 
- 
          _url() protectedCreates a valid request url and parameter array more like Request::_url() 
- 
          assertContentType() publicAsserts content type 
- 
          assertCookie() publicAsserts cookie values 
- 
          assertCookieEncrypted() publicAsserts cookie values which are encrypted by the CookieComponent. 
- 
          assertHeader() publicAsserts response headers 
- 
          assertHtml() publicAsserts HTML tags. 
- 
          assertLayout() publicAsserts that the search string was in the layout name. 
- 
          assertNoRedirect() publicAsserts that the Location header is not set. 
- 
          assertNotWithinRange() protected staticCompatibility function to test if a value is not between an acceptable range. 
- 
          assertPathEquals() protected staticCompatibility function to test paths. 
- 
          assertRedirect() publicAsserts that the Location header is correct. 
- 
          assertRedirectContains() publicAsserts that the Location header contains a substring 
- 
          assertResponseCode() publicAsserts a specific response status code. 
- 
          assertResponseContains() publicAsserts content exists in the response body. 
- 
          assertResponseEmpty() publicAssert response content is empty. 
- 
          assertResponseEquals() publicAsserts content exists in the response body. 
- 
          assertResponseError() publicAsserts that the response status code is in the 4xx range. 
- 
          assertResponseFailure() publicAsserts that the response status code is in the 5xx range. 
- 
          assertResponseNotContains() publicAsserts content does not exist in the response body. 
- 
          assertResponseNotEmpty() publicAssert response content is not empty. 
- 
          assertResponseOk() publicAsserts that the response status code is in the 2xx range. 
- 
          assertResponseSuccess() publicAsserts that the response status code is in the 2xx/3xx range. 
- 
          assertSession() publicAsserts session contents 
- 
          assertTags() public deprecatedAsserts HTML tags. 
- 
          assertTemplate() publicAsserts that the search string was in the template name. 
- 
          assertTextContains() publicAssert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextEndsNotWith() publicAsserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextEndsWith() publicAsserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextEquals() publicAssert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextNotContains() publicAssert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextNotEquals() publicAssert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextStartsNotWith() publicAsserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertTextStartsWith() publicAsserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text. 
- 
          assertWithinRange() protected staticCompatibility function to test if a value is between an acceptable range. 
- 
          configRequest() publicConfigures the data for the next request. 
- 
          controllerSpy() publicAdds additional event spies to the controller/view event manager. 
- 
          cookie() publicSets a request cookie for future requests. 
- 
          cookieEncrypted() publicSets a encrypted request cookie for future requests. 
- 
          delete() publicPerforms a DELETE request using the current request data. 
- 
          enableCsrfToken() publicCalling this method will add a CSRF token to the request. 
- 
          enableSecurityToken() publicCalling this method will enable a SecurityComponent compatible token to be added to request data. This lets you easily test actions protected by SecurityComponent. 
- 
          get() publicPerforms a GET request using the current request data. 
- 
          getMockForModel() publicMock a model, maintain fixtures and table association 
- 
          loadFixtures() publicChooses which fixtures to load for a given test 
- 
          patch() publicPerforms a PATCH request using the current request data. 
- 
          post() publicPerforms a POST request using the current request data. 
- 
          put() publicPerforms a PUT request using the current request data. 
- 
          session() publicSets session data. 
- 
          setUp() publicSetup 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() publicOverrides SimpleTestCase::skipIf to provide a boolean return value 
- 
          skipUnless() protectedCompatibility function for skipping. 
- 
          tearDown() publicClears the state used for requests. 
- 
          viewVariable() publicFetches a view variable by name. 
Method Detail
_addTokens() ¶ protected
_addTokens(string $url, array $data): arrayAdd 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.
_assertAttributes() ¶ protected
_assertAttributes(array $assertions, string $string, bool $fullDebug = false, array $regex = ''): stringCheck the attributes as part of an assertTags() check.
Parameters
- 
                array$assertions
- Assertions to run. 
- 
                string$string
- The HTML string to check. 
- 
                bool$fullDebug optional
- Whether or not more verbose output should be used. 
- 
                array$regex optional
- Full regexp from - assertHtml
Returns
string_assertStatus() ¶ protected
_assertStatus(int $min, int $max, string $message): voidHelper method for status assertions.
Parameters
- 
                int$min
- Min status code. 
- 
                int$max
- Max status code. 
- 
                string$message
- The error message. 
Returns
void_buildFieldToken() ¶ protected
_buildFieldToken(string $url, array $fields, array $unlockedFields = []): arrayGenerate the token data for the provided inputs.
Parameters
- 
                string$url
- The URL the form is being submitted to. 
- 
                array$fields
- If set specifies the list of fields to use when generating the hash. 
- 
                array$unlockedFields optional
- The list of fields that are excluded from field validation. 
Returns
arrayThe token data.
_buildRequest() ¶ protected
_buildRequest(string|array $url, string $method, array|null $data): Cake\Network\RequestCreates a request object with the configured options and parameters.
Parameters
- 
                string|array$url
- The URL 
- 
                string$method
- The HTTP method 
- 
                array|null$data
- The request data. 
Returns
Cake\Network\RequestThe built request.
_checkCipher() ¶ protected
_checkCipher(string $encrypt): voidHelper method for validating encryption cipher names.
Parameters
- 
                string$encrypt
- The cipher name. 
Returns
voidThrows
RuntimeExceptionWhen an invalid cipher is provided.
_decode() ¶ protected
_decode(string $value, string|false $encrypt): stringDecodes and decrypts a single value.
Parameters
- 
                string$value
- The value to decode & decrypt. 
- 
                string|false$encrypt
- The encryption cipher to use. 
Returns
stringDecoded value.
_decrypt() ¶ protected
_decrypt(array $values, string|bool $mode): stringDecrypts $value using public $type method in Security class
Parameters
- 
                array$values
- Values to decrypt 
- 
                string|bool$mode
- Encryption mode 
Returns
stringdecrypted string
_encrypt() ¶ protected
_encrypt(string $value, string|bool $encrypt, string|null $key = null): stringEncrypts $value using public $type method in Security class
Parameters
- 
                string$value
- Value to encrypt 
- 
                string|bool$encrypt
- Encryption mode to use. False disabled encryption. 
- 
                string|null$key optional
- Used as the security salt only in this time for tests if specified. 
Returns
stringEncoded values
_explode() ¶ protected
_explode(string $string): arrayExplode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().
Parameters
- 
                string$string
- A string containing JSON encoded data, or a bare string. 
Returns
arrayMap of key and values
_getCookieEncryptionKey() ¶ protected
_getCookieEncryptionKey(): stringReturns the encryption key to be used.
Returns
string_handleError() ¶ protected
_handleError(Exception $exception): voidAttempts 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. 
Returns
voidThrows
Exception_implode() ¶ protected
_implode(array $array): stringImplode method to keep keys are multidimensional arrays
Parameters
- 
                array$array
- Map of key and values 
Returns
stringA json encoded string.
_normalizePath() ¶ protected
_normalizePath(string $path): stringNormalize a path for comparison.
Parameters
- 
                string$path
- Path separated by "/" slash. 
Returns
stringNormalized path separated by DS.
_sendRequest() ¶ protected
_sendRequest(string|array $url, string $method, array|null $data = []): voidCreates 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 
- 
                array|null$data optional
- The request data. 
Returns
voidThrows
Exception_url() ¶ protected
_url(string|array $url): arrayCreates a valid request url and parameter array more like Request::_url()
Parameters
- 
                string|array$url
- The URL 
Returns
arrayQualified URL and the query parameters
assertContentType() ¶ public
assertContentType(string $type, string $message = ''): voidAsserts 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. 
Returns
voidassertCookie() ¶ public
assertCookie(string $expected, string $name, string $message = ''): voidAsserts 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. 
Returns
voidassertCookieEncrypted() ¶ public
assertCookieEncrypted(string $expected, string $name, string|bool $encrypt = 'aes', string|null $key = null, string $message = ''): voidAsserts 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|bool$encrypt optional
- Encryption mode to use. 
- 
                string|null$key optional
- Encryption key used. Defaults to Security.salt. 
- 
                string$message optional
- The failure message that will be appended to the generated message. 
Returns
voidSee Also
assertHeader() ¶ public
assertHeader(string $header, string $content, string $message = ''): voidAsserts 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. 
Returns
voidassertHtml() ¶ public
assertHtml(array $expected, string $string, bool $fullDebug = false): boolAsserts 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 
- 
                bool$fullDebug optional
- Whether or not more verbose output should be used. 
Returns
boolassertLayout() ¶ public
assertLayout(string $content, string $message = ''): voidAsserts 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. 
Returns
voidassertNoRedirect() ¶ public
assertNoRedirect(string $message = ''): voidAsserts that the Location header is not set.
Parameters
- 
                string$message optional
- The failure message that will be appended to the generated message. 
Returns
voidassertNotWithinRange() ¶ protected static
assertNotWithinRange(float $expected, float $result, float $margin, string $message = ''): voidCompatibility 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 
Returns
voidassertPathEquals() ¶ protected static
assertPathEquals(string $expected, string $result, string $message = ''): voidCompatibility function to test paths.
Parameters
- 
                string$expected
- 
                string$result
- 
                string$message optional
- the text to display if the assertion is not correct 
Returns
voidassertRedirect() ¶ public
assertRedirect(string|array|null $url = null, string $message = ''): voidAsserts that the Location header is correct.
Parameters
- 
                string|array|null$url optional
- 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. 
Returns
voidassertRedirectContains() ¶ public
assertRedirectContains(string $url, string $message = ''): voidAsserts 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. 
Returns
voidassertResponseCode() ¶ public
assertResponseCode(int $code): voidAsserts a specific response status code.
Parameters
- 
                int$code
- Status code to assert. 
Returns
voidassertResponseContains() ¶ public
assertResponseContains(string $content, string $message = ''): voidAsserts 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. 
Returns
voidassertResponseEmpty() ¶ public
assertResponseEmpty(string $message = ''): voidAssert response content is empty.
Parameters
- 
                string$message optional
- The failure message that will be appended to the generated message. 
Returns
voidassertResponseEquals() ¶ public
assertResponseEquals(mixed $content, string $message = ''): voidAsserts content exists in the response body.
Parameters
- 
                mixed$content
- The content to check for. 
- 
                string$message optional
- The failure message that will be appended to the generated message. 
Returns
voidassertResponseError() ¶ public
assertResponseError(): voidAsserts that the response status code is in the 4xx range.
Returns
voidassertResponseFailure() ¶ public
assertResponseFailure(): voidAsserts that the response status code is in the 5xx range.
Returns
voidassertResponseNotContains() ¶ public
assertResponseNotContains(string $content, string $message = ''): voidAsserts 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. 
Returns
voidassertResponseNotEmpty() ¶ public
assertResponseNotEmpty(string $message = ''): voidAssert response content is not empty.
Parameters
- 
                string$message optional
- The failure message that will be appended to the generated message. 
Returns
voidassertResponseOk() ¶ public
assertResponseOk(): voidAsserts that the response status code is in the 2xx range.
Returns
voidassertResponseSuccess() ¶ public
assertResponseSuccess(): voidAsserts that the response status code is in the 2xx/3xx range.
Returns
voidassertSession() ¶ public
assertSession(string $expected, string $path, string $message = ''): voidAsserts 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. 
Returns
voidassertTags() ¶ public
assertTags(string $string, array $expected, bool $fullDebug = false): voidAsserts HTML tags.
Parameters
- 
                string$string
- An HTML/XHTML/XML string 
- 
                array$expected
- An array, see above 
- 
                bool$fullDebug optional
- Whether or not more verbose output should be used. 
Returns
voidassertTemplate() ¶ public
assertTemplate(string $content, string $message = ''): voidAsserts 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. 
Returns
voidassertTextContains() ¶ public
assertTextContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): voidAssert 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. 
- 
                bool$ignoreCase optional
- Whether or not the search should be case-sensitive. 
Returns
voidassertTextEndsNotWith() ¶ public
assertTextEndsNotWith(string $suffix, string $string, string $message = ''): voidAsserts 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. 
Returns
voidassertTextEndsWith() ¶ public
assertTextEndsWith(string $suffix, string $string, string $message = ''): voidAsserts 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. 
Returns
voidassertTextEquals() ¶ public
assertTextEquals(string $expected, string $result, string $message = ''): voidAssert 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. 
Returns
voidassertTextNotContains() ¶ public
assertTextNotContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): voidAssert 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. 
- 
                bool$ignoreCase optional
- Whether or not the search should be case-sensitive. 
Returns
voidassertTextNotEquals() ¶ public
assertTextNotEquals(string $expected, string $result, string $message = ''): voidAssert 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. 
Returns
voidassertTextStartsNotWith() ¶ public
assertTextStartsNotWith(string $prefix, string $string, string $message = ''): voidAsserts 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. 
Returns
voidassertTextStartsWith() ¶ public
assertTextStartsWith(string $prefix, string $string, string $message = ''): voidAsserts 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. 
Returns
voidassertWithinRange() ¶ protected static
assertWithinRange(float $expected, float $result, float $margin, string $message = ''): voidCompatibility 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 
Returns
voidconfigRequest() ¶ public
configRequest(array $data): voidConfigures 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. 
Returns
voidcontrollerSpy() ¶ public
controllerSpy(Cake\Event\Event $event): voidAdds additional event spies to the controller/view event manager.
Parameters
- 
                Cake\Event\Event$event
- A dispatcher event. 
Returns
voidcookie() ¶ public
cookie(string $name, mixed $value): voidSets 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. 
Returns
voidcookieEncrypted() ¶ public
cookieEncrypted(string $name, mixed $value, string|bool $encrypt = 'aes', string|null $key = null): voidSets 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|bool$encrypt optional
- Encryption mode to use. 
- 
                string|null$key optional
- Encryption key used. Defaults to Security.salt. 
Returns
voidSee Also
delete() ¶ public
delete(string|array $url): voidPerforms 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. 
Returns
voidenableCsrfToken() ¶ public
enableCsrfToken(): voidCalling 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.
Returns
voidenableSecurityToken() ¶ public
enableSecurityToken(): voidCalling this method will enable a SecurityComponent compatible token to be added to request data. This lets you easily test actions protected by SecurityComponent.
Returns
voidget() ¶ public
get(string|array $url): voidPerforms 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. 
Returns
voidgetMockForModel() ¶ public
getMockForModel(string $alias, mixed $methods = [], array $options = []): Cake\ORM\Table|PHPUnit_Framework_MockObject_MockObjectMock a model, maintain fixtures and table association
Parameters
- 
                string$alias
- The model to get a mock for. 
- 
                mixed$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\MissingTableClassExceptionloadFixtures() ¶ public
loadFixtures(): voidChooses which fixtures to load for a given test
Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc.
Returns
voidThrows
Exceptionwhen no fixture manager is available.
See Also
patch() ¶ public
patch(string|array $url, array $data = []): voidPerforms 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. 
- 
                array$data optional
- The data for the request. 
Returns
voidpost() ¶ public
post(string|array $url, array $data = []): voidPerforms 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. 
- 
                array$data optional
- The data for the request. 
Returns
voidput() ¶ public
put(string|array $url, array $data = []): voidPerforms 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. 
- 
                array$data optional
- The data for the request. 
Returns
voidsession() ¶ public
session(array $data): voidSets 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. 
Returns
voidsetUp() ¶ public
setUp(): voidSetup 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.
Returns
voidskipIf() ¶ public
skipIf(bool $shouldSkip, string $message = ''): boolOverrides SimpleTestCase::skipIf to provide a boolean return value
Parameters
- 
                bool$shouldSkip
- Whether or not the test should be skipped. 
- 
                string$message optional
- The message to display. 
Returns
boolskipUnless() ¶ protected
skipUnless(bool $condition, string $message = ''): boolCompatibility function for skipping.
Parameters
- 
                bool$condition
- Condition to trigger skipping 
- 
                string$message optional
- Message for skip 
Returns
boolviewVariable() ¶ public
viewVariable(string $name): mixedFetches 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.
Property Detail
$_csrfToken ¶ protected
Boolean flag for whether or not the request should have a CSRF token added.
Type
bool$_securityToken ¶ protected
Boolean flag for whether or not the request should have a SecurityComponent token added.
Type
bool$autoFixtures ¶ public
By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
Type
array$dropTables ¶ public
Control table create/drops on each test method.
If true, tables will still be dropped at the end of each test runner execution.
Type
bool$fixtureManager ¶ public
The class responsible for managing the creation, loading and removing of fixtures
Type
Cake\TestSuite\Fixture\FixtureManager