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.
array|nullThe customized application constructor arguments.
string|nullThe customized application class name.
arrayConfigure values to restore at end of test.
Cake\Controller\Controller|nullThe controller used in the last request.
arrayCookie data to use in the next request.
string|nullstringThe name that will be used when retrieving the csrf token.
boolBoolean flag for whether the request should have a CSRF token added.
Throwable|nullThe exception being thrown if the case.
arrayStored flash messages before render
stringThe last rendered layout
arrayThe data used to build the next request.
Cake\Http\SessionThe session instance from the last request
Psr\Http\Message\ResponseInterface|nullThe response for the most recent request.
boolBoolean flag for whether the request should re-store flash messages
boolBoolean flag for whether the request should have a SecurityComponent token added.
arraySession data to use in the next request.
Cake\ORM\Locator\LocatorInterface|nullTable locator instance
array<string>List of fields that are excluded from field validation.
array<string>Valid cipher names for encrypted cookies.
stringThe last rendered view
boolBy default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
?boolstring[]string[]boolarray<string, array<int, string>>array<string, array<int, string>>string|nullThis object's default table alias.
boolControl table create/drops on each test method.
Cake\TestSuite\Fixture\FixtureManager|nullThe class responsible for managing the creation, loading and removing of fixtures
Cake\TestSuite\Fixture\FixtureStrategyInterface|nullarray<string>Fixtures used by this test case.
boollist<ExecutionOrderDependency>boolAdd the CSRF and Security Component tokens if necessary.
Check the attributes as part of an assertTags() check.
Creates a request object with the configured options and parameters.
Recursively casts all data to string as that is how data would be POSTed in the real world
Helper method for validating encryption cipher names.
Decodes and decrypts a single value.
Decrypts $value using public $type method in Security class
Encrypts $value using public $type method in Security class
Explode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().
Get the response body as string
Returns the encryption key to be used.
Gets the class name for the table.
Attempts to render an error response for a given exception.
Implode method to keep keys are multidimensional arrays
Get the correct dispatcher instance.
Normalize a path for comparison.
Creates and send the request into a Dispatcher instance.
Creates a valid request url and parameter array more like Request::_url()
Adds a fixture to this test case.
Returns a matcher that matches when the method is executed zero or more times.
Asserts that an array has a specified key.
Asserts that an array does not have a specified key.
Asserts that a class has a specified attribute.
Asserts that a class has a specified static attribute.
Asserts that a class does not have a specified attribute.
Asserts that a class does not have a specified static attribute.
Asserts that a haystack contains a needle.
Asserts that a haystack contains only values of a given type.
Asserts that a haystack contains only instances of a given class name.
Asserts content type
Asserts cookie values
Asserts cookie values which are encrypted by the CookieComponent.
Asserts a cookie has not been set in the response
Asserts the number of elements of an array, Countable or Traversable.
Asserts that a directory does not exist.
Asserts that a directory exists.
Asserts that a directory exists and is not readable.
Asserts that a directory exists and is not writable.
Asserts that a directory exists and is readable.
Asserts that a directory exists and is writable.
Asserts that a directory does not exist.
Asserts that a directory exists and is not readable.
Asserts that a directory exists and is not writable.
Asserts that a string does not match a given regular expression.
Asserts that a variable is empty.
Asserts that a hierarchy of DOMElements matches.
Asserts that two variables are equal.
Asserts that two variables are equal (canonicalizing).
Asserts that two variables are equal (ignoring case).
Assert that a string matches SQL with db-specific characters like quotes removed.
Asserts that two variables are equal (with delta).
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
Asserts an event was fired with data
Asserts that a condition is false.
Asserts that a file does not exist.
Asserts that the contents of one file is equal to the contents of another file.
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
Asserts that a file exists.
Asserts that a file exists and is not readable.
Asserts that a file exists and is not writable.
Asserts that a file exists and is readable.
Asserts that a file exists and is writable.
Asserts that the contents of one file is not equal to the contents of another file.
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
Asserts that a file does not exist.
Asserts that a file exists and is not readable.
Asserts that a file exists and is not writable.
Asserts that a file with the given name was sent in the response
Asserts that a variable is finite.
Asserts a flash element was set
Asserts a flash element was set at a certain index
Asserts a flash message was set
Asserts a flash message was set at a certain index
Asserts that a value is greater than another value.
Asserts that a value is greater than or equal to another value.
Asserts response headers
Asserts response header contains a string
Asserts response header does not contain a string
Asserts HTML tags.
Asserts that a variable is infinite.
Asserts that a variable is of a given type.
Asserts that a variable is of type array.
Asserts that a variable is of type bool.
Asserts that a variable is of type callable.
Asserts that a variable is of type resource and is closed.
Asserts that a variable is of type float.
Asserts that a variable is of type int.
Asserts that a variable is of type iterable.
Asserts that a variable is not of type array.
Asserts that a variable is not of type bool.
Asserts that a variable is not of type callable.
Asserts that a variable is not of type resource.
Asserts that a variable is not of type float.
Asserts that a variable is not of type int.
Asserts that a variable is not of type iterable.
Asserts that a variable is not of type numeric.
Asserts that a variable is not of type object.
Asserts that a file/dir exists and is not readable.
Asserts that a variable is not of type resource.
Asserts that a variable is not of type scalar.
Asserts that a variable is not of type string.
Asserts that a file/dir exists and is not writable.
Asserts that a variable is of type numeric.
Asserts that a variable is of type object.
Asserts that a file/dir is readable.
Asserts that a variable is of type resource.
Asserts that a variable is of type scalar.
Asserts that a variable is of type string.
Asserts that a file/dir exists and is writable.
Asserts that a string is a valid JSON string.
Asserts that two JSON files are equal.
Asserts that two JSON files are not equal.
Asserts that the generated JSON encoded object and the content of the given file are equal.
Asserts that two given JSON encoded objects or arrays are equal.
Asserts that the generated JSON encoded object and the content of the given file are not equal.
Asserts that two given JSON encoded objects or arrays are not equal.
Asserts that the search string was in the layout name.
Asserts that a value is smaller than another value.
Asserts that a value is smaller than or equal to another value.
Asserts that a string matches a given regular expression.
Asserts that a variable is nan.
Asserts that the Location header is not set.
Asserts that a haystack does not contain a needle.
Asserts that a haystack does not contain only values of a given type.
Asserts the number of elements of an array, Countable or Traversable.
Asserts that a variable is not empty.
Asserts that two variables are not equal.
Asserts that two variables are not equal (canonicalizing).
Asserts that two variables are not equal (ignoring case).
Asserts that two variables are not equal (with delta).
Asserts that a condition is not false.
Asserts that a variable is not of a given type.
Asserts that a file/dir exists and is not readable.
Asserts that a file/dir exists and is not writable.
Asserts that a variable is not null.
Asserts that a string does not match a given regular expression.
Asserts that two variables do not have the same type and value. Used on objects, it asserts that two variables do not reference the same object.
Assert that the size of two arrays (or Countable or Traversable objects) is not the same.
Asserts that a condition is not true.
Compatibility function to test if a value is not between an acceptable range.
Asserts that a variable is null.
Asserts that an object has a specified attribute.
Asserts that an object does not have a specified attribute.
Compatibility function to test paths.
Performs assertions shared by all tests of a test case.
Performs assertions shared by all tests of a test case.
Asserts that the Location header is correct. Comparison is made against a full URL.
Asserts that the Location header contains a substring
Asserts that the Location header is correct. Comparison is made against exactly the URL provided.
Asserts that the Location header does not contain a substring
Asserts that a string matches a given regular expression.
Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters < and >. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries
Asserts a specific response status code.
Asserts content exists in the response body.
Assert response content is empty.
Asserts content in the response body equals.
Asserts that the response status code is in the 4xx range.
Asserts that the response status code is in the 5xx range.
Asserts content does not exist in the response body.
Assert response content is not empty.
Asserts content in the response body not equals.
Asserts that the response body does not match a given regular expression.
Asserts that the response status code is in the 2xx range.
Asserts that the response body matches a given regular expression.
Asserts that the response status code is in the 2xx/3xx range.
Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.
Assert that the size of two arrays (or Countable or Traversable objects) is the same.
Asserts session contents
Asserts session key exists.
Asserts a session key does not exist.
Asserts that a string ends not with a given suffix.
Asserts that a string ends with a given suffix.
Asserts that the contents of a string is equal to the contents of a file.
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
Asserts that a string matches a given format string.
Asserts that a string matches a given format file.
Asserts that the contents of a string is not equal to the contents of a file.
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
Asserts that a string does not match a given format string.
Asserts that a string does not match a given format string.
Asserts that a string starts not with a given prefix.
Asserts that a string starts with a given prefix.
Asserts that the search string was in the template name.
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Evaluates a PHPUnit\Framework\Constraint matcher object.
Asserts that a condition is true.
Compatibility function to test if a value is between an acceptable range.
Asserts that two XML files are equal.
Asserts that two XML files are not equal.
Asserts that two XML documents are equal.
Asserts that two XML documents are equal.
Asserts that two XML documents are not equal.
Asserts that two XML documents are not equal.
Returns a matcher that matches when the method is executed at the given index.
Returns a matcher that matches when the method is executed at least N times.
Returns a matcher that matches when the method is executed at least once.
Returns a matcher that matches when the method is executed at most N times.
Clears the state used for requests.
Clears any mocks that were defined and cleans up application class configuration.
Clear all plugins from the global plugin collection.
Configure the application class to use in integration tests.
Configures the data for the next request.
Adds additional event spies to the controller/view event manager.
Sets a request cookie for future requests.
Sets a encrypted request cookie for future requests.
Create an application instance.
Returns a configured mock object for the specified class.
Returns a mock object for the specified class.
Returns a partial mock object for the specified class.
Creates a default TestResult object.
Makes configurable stub for the specified class.
Returns a test proxy for the specified class.
Performs a DELETE request using the current request data.
Helper method for check deprecation methods
Disable the error handler middleware.
Calling this method will add a CSRF token to the request.
Calling this method will re-store flash messages into the test session after being removed by the FlashHelper
Calling this method will enable a SecurityComponent compatible token to be added to request data. This lets you easily test actions protected by SecurityComponent.
Returns a matcher that matches when the method is executed exactly $count times.
Sets up an expectation for an exception to be raised by the code under test. Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.
Extract verbose message for existing exception
Inspect controller to extract possible causes of the failed assertion
Fails a test with the given message.
Convenience method to get a table instance.
Performs a GET request using the current request data.
Return the current assertion count.
Returns fixture strategy used by these tests.
Get the fixtures this test should use.
Returns a builder object to create mock objects using a fluent interface.
Mocks the specified class and returns the name of the mocked class.
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default. To mock concrete methods, use the 7th parameter ($mockedMethods).
Mock a model, maintain fixtures and table association
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the $mockedMethods parameter.
Returns a mock object based on the given WSDL file.
Returns the number of assertions performed by this test.
Returns an object for the specified trait.
Gets the data set of a TestCase.
Returns the size of the test.
Gets the table locator.
Performs a HEAD request using the current request data.
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
Chooses which fixtures to load for a given test
Load plugins into a simulated application.
Load routes for the application.
Mark the test as incomplete.
Mark the test as skipped.
Add a mocked service to the container.
Wrap the application's container with one containing mocks.
Returns a matcher that matches when the method is never executed.
This method is called when a test method did not execute successfully.
Returns a matcher that matches when the method is executed exactly once.
Performs an OPTIONS request using the current request data.
Performs a PATCH request using the current request data.
Performs a POST request using the current request data.
Returns the normalized test name as class::method.
Performs a PUT request using the current request data.
Remove a mocked service to the container.
Remove plugins from the global plugin collection.
Returns a list of normalized dependency names, class::method.
Reset the assertion counter.
Returns the current object.
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.
Override to run the test and assert its state.
Sets session data.
Set the app namespace
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
Sets the table locator.
Set list of fields that are excluded from field validation.
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.
This method is called before the first test of this test class is run.
Initialized and loads any use fixtures.
Overrides SimpleTestCase::skipIf to provide a boolean return value
Compatibility function for skipping.
teardown any static object changes and restore them.
This method is called after the last test of this test class is run.
Unloads any use fixtures.
Returns a string representation of the test case.
No-op method.
Fetches a view variable by name.
Helper method for tests that needs to use error_reporting()
__construct(?string $name = null, array $data = [], int|string $dataName = '')
?string $name optional array $data optional int|string $dataName optional _addTokens(string $url, array $data): array
Add the CSRF and Security Component tokens if necessary.
string $url The URL the form is being submitted on.
array $data The request body data.
array_assertAttributes(array<string, mixed> $assertions, string $string, bool $fullDebug = false, array|string $regex = ''): string|false
Check the attributes as part of an assertTags() check.
array<string, mixed> $assertions Assertions to run.
string $string The HTML string to check.
bool $fullDebug optional Whether more verbose output should be used.
array|string $regex optional Full regexp from assertHtml
string|false_buildRequest(string $url, string $method, array|string $data = []): array
Creates a request object with the configured options and parameters.
string $url The URL
string $method The HTTP method
array|string $data optional The request data.
array_castToString(array $data): array
Recursively casts all data to string as that is how data would be POSTed in the real world
array $data POST data
array_checkCipher(string $encrypt): void
Helper method for validating encryption cipher names.
string $encrypt The cipher name.
voidRuntimeException_decode(string $value, string|false $encrypt, string|null $key): array|string
Decodes and decrypts a single value.
string $value The value to decode & decrypt.
string|false $encrypt The encryption cipher to use.
string|null $key Used as the security salt if specified.
array|string_decrypt(array<string>|string $values, string|false $mode, string|null $key = null): array|string
Decrypts $value using public $type method in Security class
array<string>|string $values Values to decrypt
string|false $mode Encryption mode
string|null $key optional Used as the security salt if specified.
array|string_encrypt(array|string $value, string|false $encrypt, string|null $key = null): string
Encrypts $value using public $type method in Security class
array|string $value Value to encrypt
string|false $encrypt Encryption mode to use. False disabled encryption.
string|null $key optional Used as the security salt if specified.
string_explode(string $string): array|string
Explode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().
string $string A string containing JSON encoded data, or a bare string.
array|string_getBodyAsString(): string
Get the response body as string
string_getCookieEncryptionKey(): string
Returns the encryption key to be used.
string_getTableClassName(string $alias, array<string, mixed> $options): string
Gets the class name for the table.
string $alias The model to get a mock for.
array<string, mixed> $options The config data for the mock's constructor.
stringCake\ORM\Exception\MissingTableClassException_handleError(Throwable $exception): void
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.
Throwable $exception Exception to handle.
void_implode(array $array): string
Implode method to keep keys are multidimensional arrays
array $array Map of key and values
string_makeDispatcher(): Cake\TestSuite\MiddlewareDispatcher
Get the correct dispatcher instance.
Cake\TestSuite\MiddlewareDispatcher_normalizePath(string $path): string
Normalize a path for comparison.
string $path Path separated by "/" slash.
string_sendRequest(array|string $url, string $method, array|string $data = []): void
Creates and send the request into a Dispatcher instance.
Receives and stores the response for future inspection.
array|string $url The URL
string $method The HTTP method
array|string $data optional The request data.
voidPHPUnit\ExceptionThrowable_url(string $url): array
Creates a valid request url and parameter array more like Request::_url()
string $url The URL
arrayaddFixture(string $fixture): $this
Adds a fixture to this test case.
Examples:
Use this method inside your test cases' {@link getFixtures()} method to build up the fixture list.
string $fixture Fixture
$thisaddToAssertionCount(int $count): void
int $count voidaddWarning(string $warning): void
string $warning voidany(): AnyInvokedCountMatcher
Returns a matcher that matches when the method is executed zero or more times.
AnyInvokedCountMatcheranything(): IsAnything
IsAnythingarrayHasKey(int|string $key): ArrayHasKey
int|string $key ArrayHasKeyassertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
Asserts that an array has a specified key.
int|string $key array|ArrayAccess $array string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
Asserts that an array does not have a specified key.
int|string $key array|ArrayAccess $array string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassHasAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class has a specified attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class has a specified static attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class does not have a specified attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class does not have a specified static attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertContains(mixed $needle, iterable $haystack, string $message = ''): void
Asserts that a haystack contains a needle.
iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
iterable $haystack string $message optional voidassertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack contains only values of a given type.
string $type iterable $haystack ?bool $isNativeType optional string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void
Asserts that a haystack contains only instances of a given class name.
string $className iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertContentType(string $type, string $message = ''): void
Asserts content type
string $type The content-type to check for.
string $message optional The failure message that will be appended to the generated message.
voidassertCookie(mixed $expected, string $name, string $message = ''): void
Asserts cookie values
mixed $expected The expected contents.
string $name The cookie name.
string $message optional The failure message that will be appended to the generated message.
voidassertCookieEncrypted(mixed $expected, string $name, string $encrypt = 'aes', string|null $key = null, string $message = ''): void
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.
mixed $expected The expected contents.
string $name The cookie name.
string $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.
voidassertCookieNotSet(string $cookie, string $message = ''): void
Asserts a cookie has not been set in the response
string $cookie The cookie name to check
string $message optional The failure message that will be appended to the generated message.
voidassertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
int $expectedCount Countable|iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertDirectoryDoesNotExist(string $directory, string $message = ''): void
Asserts that a directory does not exist.
string $directory Directory
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertDirectoryExists(string $directory, string $message = ''): void
Asserts that a directory exists.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsNotReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsNotWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is readable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is writable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryNotExists(string $directory, string $message = ''): void
Asserts that a directory does not exist.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryNotIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryNotIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void
Asserts that a string does not match a given regular expression.
string $pattern Regex pattern
string $string String to test
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is empty.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void
Asserts that a hierarchy of DOMElements matches.
DOMElement $expectedElement DOMElement $actualElement bool $checkAttributes optional string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionAssertionFailedErrorExpectationFailedExceptionassertEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (canonicalizing).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (ignoring case).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualsSql(string $expected, string $actual, string $message = ''): void
Assert that a string matches SQL with db-specific characters like quotes removed.
string $expected The expected sql
string $actual The sql to compare
string $message optional The message to display on failure
voidassertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are equal (with delta).
float $delta string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEventFired(string $name, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
string $name Event name
Cake\Event\EventManager|null $eventManager optional Event manager to check, defaults to global event manager
string $message optional Assertion failure message
voidassertEventFiredWith(string $name, string $dataKey, mixed $dataValue, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void
Asserts an event was fired with data
If a third argument is passed, that value is used to compare with the value in $dataKey
string $name Event name
string $dataKey Data key
mixed $dataValue Data value
Cake\Event\EventManager|null $eventManager optional Event manager to check, defaults to global event manager
string $message optional Assertion failure message
voidassertFalse(mixed $condition, string $message = ''): void
Asserts that a condition is false.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileDoesNotExist(string $filename, string $message = ''): void
Asserts that a file does not exist.
string $filename Filename
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertFileEquals(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file.
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileExists(string $filename, string $message = ''): void
Asserts that a file exists.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsNotReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsNotWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is readable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is writable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotEquals(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file.
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotExists(string $filename, string $message = ''): void
Asserts that a file does not exist.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileResponse(string $expected, string $message = ''): void
Asserts that a file with the given name was sent in the response
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.
voidassertFinite(mixed $actual, string $message = ''): void
Asserts that a variable is finite.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFlashElement(string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash element was set
string $expected Expected element name
string $key optional Flash key
string $message optional Assertion failure message
voidassertFlashElementAt(int $at, string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash element was set at a certain index
int $at Flash index
string $expected Expected element name
string $key optional Flash key
string $message optional Assertion failure message
voidassertFlashMessage(string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash message was set
string $expected Expected message
string $key optional Flash key
string $message optional Assertion failure message
voidassertFlashMessageAt(int $at, string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash message was set at a certain index
int $at Flash index
string $expected Expected message
string $key optional Flash key
string $message optional Assertion failure message
voidassertGreaterThan(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is greater than another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is greater than or equal to another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertHeader(string $header, string $content, string $message = ''): void
Asserts response headers
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.
voidassertHeaderContains(string $header, string $content, string $message = ''): void
Asserts response header contains a string
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.
voidassertHeaderNotContains(string $header, string $content, string $message = ''): void
Asserts response header does not contain a string
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.
voidassertHtml(array $expected, string $string, bool $fullDebug = false): bool
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.
array $expected An array, see above
string $string An HTML/XHTML/XML string
bool $fullDebug optional Whether more verbose output should be used.
boolassertInfinite(mixed $actual, string $message = ''): void
Asserts that a variable is infinite.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertInstanceOf(string $expected, mixed $actual, string $message = ''): void
Asserts that a variable is of a given type.
string $expected string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertIsArray(mixed $actual, string $message = ''): void
Asserts that a variable is of type array.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsBool(mixed $actual, string $message = ''): void
Asserts that a variable is of type bool.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsCallable(mixed $actual, string $message = ''): void
Asserts that a variable is of type callable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource and is closed.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsFloat(mixed $actual, string $message = ''): void
Asserts that a variable is of type float.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsInt(mixed $actual, string $message = ''): void
Asserts that a variable is of type int.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsIterable(mixed $actual, string $message = ''): void
Asserts that a variable is of type iterable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotArray(mixed $actual, string $message = ''): void
Asserts that a variable is not of type array.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotBool(mixed $actual, string $message = ''): void
Asserts that a variable is not of type bool.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotCallable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type callable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotFloat(mixed $actual, string $message = ''): void
Asserts that a variable is not of type float.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotInt(mixed $actual, string $message = ''): void
Asserts that a variable is not of type int.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotIterable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type iterable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is not of type numeric.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotObject(mixed $actual, string $message = ''): void
Asserts that a variable is not of type object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotReadable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not readable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotScalar(mixed $actual, string $message = ''): void
Asserts that a variable is not of type scalar.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotString(mixed $actual, string $message = ''): void
Asserts that a variable is not of type string.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not writable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is of type numeric.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsObject(mixed $actual, string $message = ''): void
Asserts that a variable is of type object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir is readable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsScalar(mixed $actual, string $message = ''): void
Asserts that a variable is of type scalar.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsString(mixed $actual, string $message = ''): void
Asserts that a variable is of type string.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is writable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJson(string $actualJson, string $message = ''): void
Asserts that a string is a valid JSON string.
string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two JSON files are equal.
string $expectedFile string $actualFile string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two JSON files are not equal.
string $expectedFile string $actualFile string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
Asserts that the generated JSON encoded object and the content of the given file are equal.
string $expectedFile string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
Asserts that two given JSON encoded objects or arrays are equal.
string $expectedJson string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
Asserts that the generated JSON encoded object and the content of the given file are not equal.
string $expectedFile string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
Asserts that two given JSON encoded objects or arrays are not equal.
string $expectedJson string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertLayout(string $content, string $message = ''): void
Asserts that the search string was in the layout name.
string $content The content to check for.
string $message optional The failure message that will be appended to the generated message.
voidassertLessThan(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is smaller than another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertLessThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is smaller than or equal to another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
Asserts that a string matches a given regular expression.
string $pattern Regex pattern
string $string String to test
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertNan(mixed $actual, string $message = ''): void
Asserts that a variable is nan.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNoRedirect(string $message = ''): void
Asserts that the Location header is not set.
string $message optional The failure message that will be appended to the generated message.
voidassertNotContains(mixed $needle, iterable $haystack, string $message = ''): void
Asserts that a haystack does not contain a needle.
iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
iterable $haystack string $message optional voidassertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack does not contain only values of a given type.
string $type iterable $haystack ?bool $isNativeType optional string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
int $expectedCount Countable|iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is not empty.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (canonicalizing).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (ignoring case).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are not equal (with delta).
float $delta string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotFalse(mixed $condition, string $message = ''): void
Asserts that a condition is not false.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotInstanceOf(string $expected, mixed $actual, string $message = ''): void
Asserts that a variable is not of a given type.
string $expected string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not readable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not writable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotNull(mixed $actual, string $message = ''): void
Asserts that a variable is not null.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotRegExp(string $pattern, string $string, string $message = ''): void
Asserts that a string does not match a given regular expression.
string $pattern string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotSame(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables do not have the same type and value. Used on objects, it asserts that two variables do not reference the same object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
Assert that the size of two arrays (or Countable or Traversable objects) is not the same.
Countable|iterable $expected Countable|iterable $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotTrue(mixed $condition, string $message = ''): void
Asserts that a condition is not true.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotWithinRange(float $expected, float $result, float $margin, string $message = ''): void
Compatibility function to test if a value is not between an acceptable range.
float $expected float $result float $margin the rage of acceptation
string $message optional the text to display if the assertion is not correct
voidassertNull(mixed $actual, string $message = ''): void
Asserts that a variable is null.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertObjectEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void
object $expected object $actual string $method optional string $message optional voidExpectationFailedExceptionassertObjectHasAttribute(string $attributeName, object $object, string $message = ''): void
Asserts that an object has a specified attribute.
string $attributeName object $object string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertObjectNotHasAttribute(string $attributeName, object $object, string $message = ''): void
Asserts that an object does not have a specified attribute.
string $attributeName object $object string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertPathEquals(string $expected, string $result, string $message = ''): void
Compatibility function to test paths.
string $expected string $result string $message optional the text to display if the assertion is not correct
voidassertPostConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between test and tearDown().
voidassertPreConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between setUp() and test.
voidassertRedirect(array|string|null $url = null, string $message = ''): void
Asserts that the Location header is correct. Comparison is made against a full URL.
array|string|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.
voidassertRedirectContains(string $url, string $message = ''): void
Asserts that the Location header contains a substring
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.
voidassertRedirectEquals(array|string|null $url = null, string $message = ''): void
Asserts that the Location header is correct. Comparison is made against exactly the URL provided.
array|string|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.
voidassertRedirectNotContains(string $url, string $message = ''): void
Asserts that the Location header does not contain a substring
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.
voidassertRegExp(string $pattern, string $string, string $message = ''): void
Asserts that a string matches a given regular expression.
string $pattern string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertRegExpSql(string $pattern, string $actual, bool $optional = false): void
Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters < and >. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries
string $pattern The expected sql pattern
string $actual The sql to compare
bool $optional optional Whether quote characters (marked with <>) are optional
voidassertResponseCode(int $code, string $message = ''): void
Asserts a specific response status code.
int $code Status code to assert.
string $message optional Custom message for failure.
voidassertResponseContains(string $content, string $message = '', bool $ignoreCase = false): void
Asserts content exists in the response body.
string $content The content to check for.
string $message optional The failure message that will be appended to the generated message.
bool $ignoreCase optional A flag to check whether we should ignore case or not.
voidassertResponseEmpty(string $message = ''): void
Assert response content is empty.
string $message optional The failure message that will be appended to the generated message.
voidassertResponseEquals(mixed $content, string $message = ''): void
Asserts content in the response body equals.
mixed $content The content to check for.
string $message optional The failure message that will be appended to the generated message.
voidassertResponseError(string $message = ''): void
Asserts that the response status code is in the 4xx range.
string $message optional Custom message for failure.
voidassertResponseFailure(string $message = ''): void
Asserts that the response status code is in the 5xx range.
string $message optional Custom message for failure.
voidassertResponseNotContains(string $content, string $message = '', bool $ignoreCase = false): void
Asserts content does not exist in the response body.
string $content The content to check for.
string $message optional The failure message that will be appended to the generated message.
bool $ignoreCase optional A flag to check whether we should ignore case or not.
voidassertResponseNotEmpty(string $message = ''): void
Assert response content is not empty.
string $message optional The failure message that will be appended to the generated message.
voidassertResponseNotEquals(mixed $content, string $message = ''): void
Asserts content in the response body not equals.
mixed $content The content to check for.
string $message optional The failure message that will be appended to the generated message.
voidassertResponseNotRegExp(string $pattern, string $message = ''): void
Asserts that the response body does not match a given regular expression.
string $pattern The pattern to compare against.
string $message optional The failure message that will be appended to the generated message.
voidassertResponseOk(string $message = ''): void
Asserts that the response status code is in the 2xx range.
string $message optional Custom message for failure.
voidassertResponseRegExp(string $pattern, string $message = ''): void
Asserts that the response body matches a given regular expression.
string $pattern The pattern to compare against.
string $message optional The failure message that will be appended to the generated message.
voidassertResponseSuccess(string $message = ''): void
Asserts that the response status code is in the 2xx/3xx range.
string $message optional Custom message for failure.
voidassertSame(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
Assert that the size of two arrays (or Countable or Traversable objects) is the same.
Countable|iterable $expected Countable|iterable $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertSession(mixed $expected, string $path, string $message = ''): void
Asserts session contents
mixed $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.
voidassertSessionHasKey(string $path, string $message = ''): void
Asserts session key exists.
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.
voidassertSessionNotHasKey(string $path, string $message = ''): void
Asserts a session key does not exist.
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.
voidassertStringContainsString(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEndsNotWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends not with a given suffix.
string $suffix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEndsWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends with a given suffix.
string $suffix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file.
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringMatchesFormat(string $format, string $string, string $message = ''): void
Asserts that a string matches a given format string.
string $format string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
Asserts that a string matches a given format file.
string $formatFile string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file.
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
Asserts that a string does not match a given format string.
string $format string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
Asserts that a string does not match a given format string.
string $formatFile string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringStartsNotWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts not with a given prefix.
string $prefix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringStartsWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts with a given prefix.
string $prefix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertTemplate(string $content, string $message = ''): void
Asserts that the search string was in the template name.
string $content The content to check for.
string $message optional The failure message that will be appended to the generated message.
voidassertTextContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
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 the search should be case-sensitive.
voidassertTextEndsNotWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $suffix The suffix to not find.
string $string The string to search.
string $message optional The message to use for failure.
voidassertTextEndsWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $suffix The suffix to find.
string $string The string to search.
string $message optional The message to use for failure.
voidassertTextEquals(string $expected, string $result, string $message = ''): void
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $expected The expected value.
string $result The actual value.
string $message optional The message to use for failure.
voidassertTextNotContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
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 the search should be case-sensitive.
voidassertTextNotEquals(string $expected, string $result, string $message = ''): void
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $expected The expected value.
string $result The actual value.
string $message optional The message to use for failure.
voidassertTextStartsNotWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $prefix The prefix to not find.
string $string The string to search.
string $message optional The message to use for failure.
voidassertTextStartsWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $prefix The prefix to check for.
string $string The string to search in.
string $message optional The message to use for failure.
voidassertThat(mixed $value, Constraint $constraint, string $message = ''): void
Evaluates a PHPUnit\Framework\Constraint matcher object.
Constraint $constraint string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertTrue(mixed $condition, string $message = ''): void
Asserts that a condition is true.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertWithinRange(float $expected, float $result, float $margin, string $message = ''): void
Compatibility function to test if a value is between an acceptable range.
float $expected float $result float $margin the rage of acceptation
string $message optional the text to display if the assertion is not correct
voidassertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two XML files are equal.
string $expectedFile string $actualFile string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two XML files are not equal.
string $expectedFile string $actualFile string $message optional voidPHPUnit\Util\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
string $expectedFile DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
DOMDocument|string $expectedXml DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringNotEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
string $expectedFile DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringNotEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
DOMDocument|string $expectedXml DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionat(int $index): InvokedAtIndexMatcher
Returns a matcher that matches when the method is executed at the given index.
int $index InvokedAtIndexMatcheratLeast(int $requiredInvocations): InvokedAtLeastCountMatcher
Returns a matcher that matches when the method is executed at least N times.
int $requiredInvocations InvokedAtLeastCountMatcheratLeastOnce(): InvokedAtLeastOnceMatcher
Returns a matcher that matches when the method is executed at least once.
InvokedAtLeastOnceMatcheratMost(int $allowedInvocations): InvokedAtMostCountMatcher
Returns a matcher that matches when the method is executed at most N times.
int $allowedInvocations InvokedAtMostCountMatchercallback(callable $callback): Callback
callable $callback CallbackclassHasAttribute(string $attributeName): ClassHasAttribute
string $attributeName ClassHasAttributeclassHasStaticAttribute(string $attributeName): ClassHasStaticAttribute
string $attributeName ClassHasStaticAttributecleanup(): void
Clears the state used for requests.
voidcleanupContainer(): void
Clears any mocks that were defined and cleans up application class configuration.
voidclearPlugins(): void
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
voidconfigApplication(string $class, array|null $constructorArgs): void
Configure the application class to use in integration tests.
string $class The application class name.
array|null $constructorArgs The constructor arguments for your application class.
voidconfigRequest(array $data): void
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. Sub-keys like 'headers' will be reset, though.
array $data The request data to use.
voidcontainsEqual(mixed $value): TraversableContainsEqual
TraversableContainsEqualcontainsIdentical(mixed $value): TraversableContainsIdentical
TraversableContainsIdenticalcontainsOnly(string $type): TraversableContainsOnly
string $type TraversableContainsOnlycontainsOnlyInstancesOf(string $className): TraversableContainsOnly
string $className TraversableContainsOnlycontrollerSpy(Cake\Event\EventInterface $event, Cake\Controller\Controller|null $controller = null): void
Adds additional event spies to the controller/view event manager.
Cake\Event\EventInterface $event A dispatcher event.
Cake\Controller\Controller|null $controller optional Controller instance.
voidcookie(string $name, mixed $value): void
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.
string $name The cookie name to use.
mixed $value The value of the cookie.
voidcookieEncrypted(string $name, mixed $value, string|false $encrypt = 'aes', string|null $key = null): void
Sets a encrypted request cookie for future requests.
The difference from cookie() is this encrypts the cookie value like the CookieComponent.
string $name The cookie name to use.
mixed $value The value of the cookie.
string|false $encrypt optional Encryption mode to use.
string|null $key optional Encryption key used. Defaults to Security.salt.
voidcount(): int
intcountOf(int $count): Count
int $count CountcreateApp(): Cake\Core\HttpApplicationInterfaceCake\Core\ConsoleApplicationInterface
Create an application instance.
Uses the configuration set in configApplication().
Cake\Core\HttpApplicationInterfaceCake\Core\ConsoleApplicationInterfacecreateConfiguredMock(string $originalClassName, array $configuration): MockObject
Returns a configured mock object for the specified class.
string $originalClassName array $configuration MockObjectcreateMock(string $originalClassName): MockObject
Returns a mock object for the specified class.
string $originalClassName MockObjectcreatePartialMock(string $originalClassName, string[] $methods): MockObject
Returns a partial mock object for the specified class.
string $originalClassName string[] $methods MockObjectcreateResult(): TestResult
Creates a default TestResult object.
TestResultcreateStub(string $originalClassName): Stub
Makes configurable stub for the specified class.
string $originalClassName StubcreateTestProxy(string $originalClassName, array $constructorArguments = []): MockObject
Returns a test proxy for the specified class.
string $originalClassName array $constructorArguments optional MockObjectdataName(): int|string
int|stringdelete(array|string $url): void
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.
array|string $url The URL to request.
voiddeprecated(callable $callable): void
Helper method for check deprecation methods
callable $callable callable function that will receive asserts
voiddirectoryExists(): DirectoryExists
DirectoryExistsdisableErrorHandlerMiddleware(): void
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.
voiddoesNotPerformAssertions(): bool
booldoubledTypes(): string[]
string[]enableCsrfToken(string $cookieName = 'csrfToken'): void
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.
string $cookieName optional The name of the csrf token cookie.
voidenableRetainFlashMessages(): void
Calling this method will re-store flash messages into the test session after being removed by the FlashHelper
voidenableSecurityToken(): void
Calling this method will enable a SecurityComponent compatible token to be added to request data. This lets you easily test actions protected by SecurityComponent.
voidequalTo(mixed $value): IsEqual
IsEqualequalToCanonicalizing(mixed $value): IsEqualCanonicalizing
IsEqualCanonicalizingequalToIgnoringCase(mixed $value): IsEqualIgnoringCase
IsEqualIgnoringCaseequalToWithDelta(mixed $value, float $delta): IsEqualWithDelta
float $delta IsEqualWithDeltaexactly(int $count): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly $count times.
int $count InvokedCountMatcherexpectDeprecation(): void
voidexpectDeprecationMessage(string $message): void
string $message voidexpectDeprecationMessageMatches(string $regularExpression): void
string $regularExpression voidexpectError(): void
voidexpectErrorMessage(string $message): void
string $message voidexpectErrorMessageMatches(string $regularExpression): void
string $regularExpression voidexpectException(string $exception): void
string $exception voidexpectExceptionCode(int|string $code): void
int|string $code voidexpectExceptionMessage(string $message): void
string $message voidexpectExceptionMessageMatches(string $regularExpression): void
string $regularExpression voidexpectExceptionObject(Exception $exception): void
Sets up an expectation for an exception to be raised by the code under test. Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.
Exception $exception voidexpectNotToPerformAssertions(): void
voidexpectNotice(): void
voidexpectNoticeMessage(string $message): void
string $message voidexpectNoticeMessageMatches(string $regularExpression): void
string $regularExpression voidexpectOutputRegex(string $expectedRegex): void
string $expectedRegex voidexpectOutputString(string $expectedString): void
string $expectedString voidexpectWarning(): void
voidexpectWarningMessage(string $message): void
string $message voidexpectWarningMessageMatches(string $regularExpression): void
string $regularExpression voidextractExceptionMessage(Exception $exception): string
Extract verbose message for existing exception
Exception $exception Exception to extract
stringextractVerboseMessage(string $message): string
Inspect controller to extract possible causes of the failed assertion
string $message Original message to use as a base
stringfail(string $message = ''): void
Fails a test with the given message.
string $message optional voidAssertionFailedErrorfetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table
Convenience method to get a table instance.
string|null $alias optional The alias name you want to get. Should be in CamelCase format. If null then the value of $defaultTable property is used.
array<string, mixed> $options optional The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Cake\ORM\TableCake\Core\Exception\CakeExceptionfileExists(): FileExists
FileExistsget(array|string $url): void
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.
array|string $url The URL to request.
voidgetActualOutput(): string
stringgetActualOutputForAssertion(): string
stringgetCount(): int
Return the current assertion count.
intgetDataSetAsString(bool $includeData = true): string
bool $includeData optional stringgetExpectedException(): ?string
?stringgetExpectedExceptionCode(): null|int|string
null|int|stringgetExpectedExceptionMessage(): ?string
?stringgetExpectedExceptionMessageRegExp(): ?string
?stringgetFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface
Returns fixture strategy used by these tests.
Cake\TestSuite\Fixture\FixtureStrategyInterfacegetFixtures(): array<string>
Get the fixtures this test should use.
array<string>getGroups(): array
arraygetMockBuilder(string $className): MockBuilder
Returns a builder object to create mock objects using a fluent interface.
string $className MockBuildergetMockClass(string $originalClassName, null|array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = false, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = false): string
Mocks the specified class and returns the name of the mocked class.
string $originalClassName null|array $methods optional $methods
array $arguments optional string $mockClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional bool $cloneArguments optional stringgetMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default. To mock concrete methods, use the 7th parameter ($mockedMethods).
string $originalClassName array $arguments optional string $mockClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional array $mockedMethods optional bool $cloneArguments optional MockObjectgetMockForModel(string $alias, array<string> $methods = [], array<string, mixed> $options = []): Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject
Mock a model, maintain fixtures and table association
string $alias The model to get a mock for.
array<string> $methods optional The list of methods to mock
array<string, mixed> $options optional The config data for the mock's constructor.
Cake\ORM\TablePHPUnit\Framework\MockObject\MockObjectCake\ORM\Exception\MissingTableClassExceptiongetMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the $mockedMethods parameter.
string $traitName array $arguments optional string $mockClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional array $mockedMethods optional bool $cloneArguments optional MockObjectgetMockFromWsdl(string $wsdlFile, string $originalClassName = '', string $mockClassName = '', array $methods = [], bool $callOriginalConstructor = true, array $options = []): MockObject
Returns a mock object based on the given WSDL file.
string $wsdlFile string $originalClassName optional string $mockClassName optional array $methods optional bool $callOriginalConstructor optional array $options optional MockObjectgetName(bool $withDataSet = true): string
bool $withDataSet optional stringSebastianBergmann\RecursionContext\InvalidArgumentExceptiongetNumAssertions(): int
Returns the number of assertions performed by this test.
intgetObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true): object
Returns an object for the specified trait.
string $traitName array $arguments optional string $traitClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional objectgetProvidedData(): array
Gets the data set of a TestCase.
arraygetResult()
getSession(): Cake\TestSuite\TestSession
Cake\TestSuite\TestSessiongetSize(): int
Returns the size of the test.
intSebastianBergmann\RecursionContext\InvalidArgumentExceptiongetStatus(): int
intgetStatusMessage(): string
stringgetTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Cake\ORM\Locator\LocatorInterfacegetTestResultObject(): ?TestResult
?TestResultgreaterThan(mixed $value): GreaterThan
GreaterThangreaterThanOrEqual(mixed $value): LogicalOr
LogicalOrhasExpectationOnOutput(): bool
boolhasFailed(): bool
boolhasOutput(): bool
boolhasSize(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionhead(array|string $url): void
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.
array|string $url The URL to request.
voididenticalTo(mixed $value): IsIdentical
IsIdenticaliniSet(string $varName, string $newValue): void
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
string $varName string $newValue voidExceptionisEmpty(): IsEmpty
IsEmptyisFalse(): IsFalse
IsFalseisFinite(): IsFinite
IsFiniteisInIsolation(): bool
boolisInfinite(): IsInfinite
IsInfiniteisInstanceOf(string $className): IsInstanceOf
string $className IsInstanceOfisJson(): IsJson
IsJsonisLarge(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionisMedium(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionisNan(): IsNan
IsNanisNull(): IsNull
IsNullisReadable(): IsReadable
IsReadableisSmall(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionisTrue(): IsTrue
IsTrueisType(string $type): IsType
string $type IsTypeisWritable(): IsWritable
IsWritablelessThan(mixed $value): LessThan
LessThanlessThanOrEqual(mixed $value): LogicalOr
LogicalOrloadFixtures(): void
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.
voidRuntimeExceptionloadPlugins(array<string, mixed> $plugins = []): Cake\Http\BaseApplication
Load plugins into a simulated application.
Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.
array<string, mixed> $plugins optional List of Plugins to load.
Cake\Http\BaseApplicationloadRoutes(array|null $appArgs = null): void
Load routes for the application.
If no application class can be found an exception will be raised. Routes for plugins will not be loaded. Use loadPlugins() or use Cake\TestSuite\IntegrationTestCaseTrait to better simulate all routes and plugins being loaded.
array|null $appArgs optional Constructor parameters for the application class.
voidlogicalAnd(): LogicalAnd
LogicalAndExceptionlogicalNot(Constraint $constraint): LogicalNot
Constraint $constraint LogicalNotlogicalOr(): LogicalOr
LogicalOrlogicalXor(): LogicalXor
LogicalXormarkAsRisky(): void
voidmarkTestIncomplete(string $message = ''): void
Mark the test as incomplete.
string $message optional voidIncompleteTestErrormarkTestSkipped(string $message = ''): void
Mark the test as skipped.
string $message optional voidSkippedTestErrorSyntheticSkippedErrormatches(string $string): StringMatchesFormatDescription
string $string StringMatchesFormatDescriptionmatchesRegularExpression(string $pattern): RegularExpression
string $pattern RegularExpressionmockService(string $class, Closure $factory): $this
Add a mocked service to the container.
When the container is created the provided classname will be mapped to the factory function. The factory function will be used to create mocked services.
string $class The class or interface you want to define.
Closure $factory The factory function for mocked services.
$thismodifyContainer(Cake\Event\EventInterface $event, Cake\Core\ContainerInterface $container): Cake\Core\ContainerInterface|null
Wrap the application's container with one containing mocks.
If any mocked services are defined, the application's container will be replaced with one containing mocks. The original container will be set as a delegate to the mock container.
Cake\Event\EventInterface $event The event
Cake\Core\ContainerInterface $container The container to wrap.
Cake\Core\ContainerInterface|nullnever(): InvokedCountMatcher
Returns a matcher that matches when the method is never executed.
InvokedCountMatcherobjectEquals(object $object, string $method = 'equals'): ObjectEquals
object $object string $method optional ObjectEqualsobjectHasAttribute(mixed $attributeName): ObjectHasAttribute
ObjectHasAttributeonConsecutiveCalls(mixed ...$args): ConsecutiveCallsStub
ConsecutiveCallsStubonNotSuccessfulTest(Throwable $t): void
This method is called when a test method did not execute successfully.
Throwable $t voidThrowableonce(): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly once.
InvokedCountMatcheroptions(array|string $url): void
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.
array|string $url The URL to request.
voidpatch(array|string $url, array|string $data = []): void
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.
array|string $url The URL to request.
array|string $data optional The data for the request.
voidpost(array|string $url, array|string $data = []): void
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.
array|string $url The URL to request.
array|string $data optional The data for the request.
voidprophesize(?string $classOrInterface = null): ObjectProphecy
?string $classOrInterface optional ObjectProphecyProphecy\Exception\Doubler\ClassNotFoundExceptionProphecy\Exception\Doubler\DoubleExceptionProphecy\Exception\Doubler\InterfaceNotFoundExceptionprovides(): list<ExecutionOrderDependency>
Returns the normalized test name as class::method.
list<ExecutionOrderDependency>put(array|string $url, array|string $data = []): void
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.
array|string $url The URL to request.
array|string $data optional The data for the request.
voidrecordDoubledType(string $originalClassName): void
string $originalClassName voidregisterComparator(Comparator $comparator): void
Comparator $comparator voidregisterMockObject(MockObject $mockObject): void
MockObject $mockObject voidremoveMockService(string $class): $this
Remove a mocked service to the container.
string $class The class or interface you want to remove.
$thisremovePlugins(array<string> $names = []): void
Remove plugins from the global plugin collection.
Useful in test case teardown methods.
array<string> $names optional A list of plugins you want to remove.
voidrequires(): list<ExecutionOrderDependency>
Returns a list of normalized dependency names, class::method.
This list can differ from the raw dependencies as the resolver has no need for the [!][shallow]clone prefix that is filtered out during normalization.
list<ExecutionOrderDependency>resetCount(): void
Reset the assertion counter.
voidreturnArgument(int $argumentIndex): ReturnArgumentStub
int $argumentIndex ReturnArgumentStubreturnCallback(mixed $callback): ReturnCallbackStub
ReturnCallbackStubreturnSelf(): ReturnSelfStub
Returns the current object.
This method is useful when mocking a fluent interface.
ReturnSelfStubreturnValue(mixed $value): ReturnStub
ReturnStubreturnValueMap(array $valueMap): ReturnValueMapStub
array $valueMap ReturnValueMapStubrun(TestResult $result = null): TestResult
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.
TestResult $result optional TestResultSebastianBergmann\CodeCoverage\InvalidArgumentExceptionSebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionCodeCoverageExceptionUtilExceptionrunBare(): void
voidThrowablerunTest()
Override to run the test and assert its state.
SebastianBergmann\ObjectEnumerator\InvalidArgumentExceptionAssertionFailedErrorExceptionExpectationFailedExceptionThrowablesession(array $data): void
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.
array $data The session data to use.
voidsetAppNamespace(string $appNamespace = 'TestApp'): string|null
Set the app namespace
string $appNamespace optional The app namespace, defaults to "TestApp".
string|nullsetBackupGlobals(?bool $backupGlobals): void
?bool $backupGlobals voidsetBackupStaticAttributes(?bool $backupStaticAttributes): void
?bool $backupStaticAttributes voidsetBeStrictAboutChangesToGlobalState(?bool $beStrictAboutChangesToGlobalState): void
?bool $beStrictAboutChangesToGlobalState voidsetDependencies(list<ExecutionOrderDependency> $dependencies): void
list<ExecutionOrderDependency> $dependencies voidsetDependencyInput(array $dependencyInput): void
array $dependencyInput voidsetGroups(array $groups): void
array $groups voidsetInIsolation(bool $inIsolation): void
bool $inIsolation voidsetLocale(mixed ...$args): void
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
voidExceptionsetName(string $name): void
string $name voidsetOutputCallback(callable $callback): void
callable $callback voidsetPreserveGlobalState(bool $preserveGlobalState): void
bool $preserveGlobalState voidsetRegisterMockObjectsFromTestArgumentsRecursively(bool $flag): void
bool $flag voidsetResult(mixed $result): void
voidsetRunClassInSeparateProcess(bool $runClassInSeparateProcess): void
bool $runClassInSeparateProcess voidsetRunTestInSeparateProcess(bool $runTestInSeparateProcess): void
bool $runTestInSeparateProcess voidsetTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Cake\ORM\Locator\LocatorInterface $tableLocator LocatorInterface instance.
$thissetTestResultObject(TestResult $result): void
TestResult $result voidsetUnlockedFields(array<string> $unlockedFields = []): void
Set list of fields that are excluded from field validation.
array<string> $unlockedFields optional List of fields that are excluded from field validation.
voidsetUp(): void
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.
voidsetUpBeforeClass(): void
This method is called before the first test of this test class is run.
voidsetupFixtures(): void
Initialized and loads any use fixtures.
voidskipIf(bool $shouldSkip, string $message = ''): bool
Overrides SimpleTestCase::skipIf to provide a boolean return value
bool $shouldSkip Whether the test should be skipped.
string $message optional The message to display.
boolskipUnless(bool $condition, string $message = ''): bool
Compatibility function for skipping.
bool $condition Condition to trigger skipping
string $message optional Message for skip
boolsortId(): string
stringstringContains(string $string, bool $case = true): StringContains
string $string bool $case optional StringContainsstringEndsWith(string $suffix): StringEndsWith
string $suffix StringEndsWithstringStartsWith(mixed $prefix): StringStartsWith
StringStartsWithtearDown(): void
teardown any static object changes and restore them.
voidtearDownAfterClass(): void
This method is called after the last test of this test class is run.
voidteardownFixtures(): void
Unloads any use fixtures.
voidthrowException(Throwable $exception): ExceptionStub
Throwable $exception ExceptionStubtoString(): string
Returns a string representation of the test case.
stringSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionuseHttpServer(bool $enable): void
No-op method.
bool $enable Unused.
voidusesDataProvider(): bool
boolviewVariable(string $name): mixed
Fetches a view variable by name.
If the view variable does not exist, null will be returned.
string $name The view variable to get.
mixedwithErrorReporting(int $errorLevel, callable $callable): void
Helper method for tests that needs to use error_reporting()
int $errorLevel value of error_reporting() that needs to use
callable $callable callable function that will receive asserts
voidThe customized application constructor arguments.
array|nullThe customized application class name.
string|nullConfigure values to restore at end of test.
arrayThe controller used in the last request.
Cake\Controller\Controller|nullCookie data to use in the next request.
arraystring|nullThe name that will be used when retrieving the csrf token.
stringBoolean flag for whether the request should have a CSRF token added.
boolThe exception being thrown if the case.
Throwable|nullStored flash messages before render
arrayThe last rendered layout
stringThe data used to build the next request.
arrayThe session instance from the last request
Cake\Http\SessionThe response for the most recent request.
Psr\Http\Message\ResponseInterface|nullBoolean flag for whether the request should re-store flash messages
boolBoolean flag for whether the request should have a SecurityComponent token added.
boolSession data to use in the next request.
arrayTable locator instance
Cake\ORM\Locator\LocatorInterface|nullList of fields that are excluded from field validation.
array<string>Valid cipher names for encrypted cookies.
array<string>The last rendered view
stringBy default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
bool?boolstring[]string[]boolarray<string, array<int, string>>array<string, array<int, string>>This object's default table alias.
string|nullControl table create/drops on each test method.
If true, tables will still be dropped at the end of each test runner execution.
boolThe class responsible for managing the creation, loading and removing of fixtures
Cake\TestSuite\Fixture\FixtureManager|nullCake\TestSuite\Fixture\FixtureStrategyInterface|nullFixtures used by this test case.
array<string>boollist<ExecutionOrderDependency>bool
© 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/4.4/class-Cake.TestSuite.IntegrationTestCase.html