Class
IntegrationTestCase
A test case class intended to make integration tests of your controllers easier.
This test class provides a number of helper methods and features that make dispatching requests and checking their responses simpler. It favours full integration tests over mock objects as you can test more of your code easily and avoid some of the maintenance pitfalls that mock objects create.
Namespace: Cake\TestSuite
Deprecated: 3.7.0 Will be removed in 5.0.0. Use {@link \Cake\TestSuite\IntegrationTestTrait} instead.
Property Summary
-
$_appArgs protected
array|null
The customized application constructor arguments.
-
$_appClass protected
string|null
The customized application class name.
-
$_configure protected
array
Configure values to restore at end of test.
-
$_controller protected
Cake\Controller\Controller|null
The controller used in the last request.
-
$_cookie protected
array
Cookie data to use in the next request.
-
$_cookieEncryptionKey protected
string|null
-
$_csrfKeyName protected
string
The name that will be used when retrieving the csrf token.
-
$_csrfToken protected
bool
Boolean flag for whether the request should have a CSRF token added.
-
$_exception protected
Throwable|null
The exception being thrown if the case.
-
$_flashMessages protected
array
Stored flash messages before render
-
$_layoutName protected
string
The last rendered layout
-
$_request protected
array
The data used to build the next request.
-
$_requestSession protected
Cake\Http\Session
The session instance from the last request
-
$_response protected
Psr\Http\Message\ResponseInterface|null
The response for the most recent request.
-
$_retainFlashMessages protected
bool
Boolean flag for whether the request should re-store flash messages
-
$_securityToken protected
bool
Boolean flag for whether the request should have a SecurityComponent token added.
-
$_session protected
array
Session data to use in the next request.
-
$_tableLocator protected
Cake\ORM\Locator\LocatorInterface|null
Table locator instance
-
$_unlockedFields protected
array<string>
List of fields that are excluded from field validation.
-
$_validCiphers protected
array<string>
Valid cipher names for encrypted cookies.
-
$_viewName protected
string
The last rendered view
-
$autoFixtures public deprecated
bool
By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
-
$backupGlobals protected
?bool
-
$backupGlobalsBlacklist protected deprecated
string[]
-
$backupGlobalsExcludeList protected
string[]
-
$backupStaticAttributes protected
?bool
-
$backupStaticAttributesBlacklist protected deprecated
array<string, array<int, string>>
-
$backupStaticAttributesExcludeList protected
array<string, array<int, string>>
-
$defaultTable protected
string|null
This object's default table alias.
-
$dropTables public deprecated
bool
Control table create/drops on each test method.
-
$fixtureManager public static
Cake\TestSuite\Fixture\FixtureManager|null
The class responsible for managing the creation, loading and removing of fixtures
-
$fixtureStrategy protected
Cake\TestSuite\Fixture\FixtureStrategyInterface|null
-
$fixtures protected
array<string>
Fixtures used by this test case.
-
$preserveGlobalState protected
bool
-
$providedTests protected
list<ExecutionOrderDependency>
-
$runTestInSeparateProcess protected
?bool
Method Summary
-
__construct() public
-
_addTokens() protected
Add the CSRF and Security Component tokens if necessary.
-
_assertAttributes() protected
Check the attributes as part of an assertTags() check.
-
_buildRequest() protected
Creates a request object with the configured options and parameters.
-
_castToString() protected
Recursively casts all data to string as that is how data would be POSTed in the real world
-
_checkCipher() protected
Helper method for validating encryption cipher names.
-
_decode() protected
Decodes and decrypts a single value.
-
_decrypt() protected
Decrypts $value using public $type method in Security class
-
_encrypt() protected
Encrypts $value using public $type method in Security class
-
_explode() protected
Explode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().
-
_getBodyAsString() protected
Get the response body as string
-
_getCookieEncryptionKey() protected
Returns the encryption key to be used.
-
_getTableClassName() protected
Gets the class name for the table.
-
_handleError() protected
Attempts to render an error response for a given exception.
-
_implode() protected
Implode method to keep keys are multidimensional arrays
-
_makeDispatcher() protected
Get the correct dispatcher instance.
-
_normalizePath() protected
Normalize a path for comparison.
-
_sendRequest() protected
Creates and send the request into a Dispatcher instance.
-
_url() protected
Creates a valid request url and parameter array more like Request::_url()
-
addFixture() protected
Adds a fixture to this test case.
-
addToAssertionCount() public
-
addWarning() public
-
any() public static
Returns a matcher that matches when the method is executed zero or more times.
-
anything() public static
-
arrayHasKey() public static
-
assertArrayHasKey() public static
Asserts that an array has a specified key.
-
assertArrayNotHasKey() public static
Asserts that an array does not have a specified key.
-
assertClassHasAttribute() public static deprecated
Asserts that a class has a specified attribute.
-
assertClassHasStaticAttribute() public static deprecated
Asserts that a class has a specified static attribute.
-
assertClassNotHasAttribute() public static deprecated
Asserts that a class does not have a specified attribute.
-
assertClassNotHasStaticAttribute() public static deprecated
Asserts that a class does not have a specified static attribute.
-
assertContains() public static
Asserts that a haystack contains a needle.
-
assertContainsEquals() public static
-
assertContainsOnly() public static
Asserts that a haystack contains only values of a given type.
-
assertContainsOnlyInstancesOf() public static
Asserts that a haystack contains only instances of a given class name.
-
assertContentType() public
Asserts content type
-
assertCookie() public
Asserts cookie values
-
assertCookieEncrypted() public
Asserts cookie values which are encrypted by the CookieComponent.
-
assertCookieNotSet() public
Asserts a cookie has not been set in the response
-
assertCount() public static
Asserts the number of elements of an array, Countable or Traversable.
-
assertDirectoryDoesNotExist() public static
Asserts that a directory does not exist.
-
assertDirectoryExists() public static
Asserts that a directory exists.
-
assertDirectoryIsNotReadable() public static
Asserts that a directory exists and is not readable.
-
assertDirectoryIsNotWritable() public static
Asserts that a directory exists and is not writable.
-
assertDirectoryIsReadable() public static
Asserts that a directory exists and is readable.
-
assertDirectoryIsWritable() public static
Asserts that a directory exists and is writable.
-
assertDirectoryNotExists() public static deprecated
Asserts that a directory does not exist.
-
assertDirectoryNotIsReadable() public static deprecated
Asserts that a directory exists and is not readable.
-
assertDirectoryNotIsWritable() public static deprecated
Asserts that a directory exists and is not writable.
-
assertDoesNotMatchRegularExpression() public static
Asserts that a string does not match a given regular expression.
-
assertEmpty() public static
Asserts that a variable is empty.
-
assertEqualXMLStructure() public static deprecated
Asserts that a hierarchy of DOMElements matches.
-
assertEquals() public static
Asserts that two variables are equal.
-
assertEqualsCanonicalizing() public static
Asserts that two variables are equal (canonicalizing).
-
assertEqualsIgnoringCase() public static
Asserts that two variables are equal (ignoring case).
-
assertEqualsSql() public
Assert that a string matches SQL with db-specific characters like quotes removed.
-
assertEqualsWithDelta() public static
Asserts that two variables are equal (with delta).
-
assertEventFired() public
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
-
assertEventFiredWith() public
Asserts an event was fired with data
-
assertFalse() public static
Asserts that a condition is false.
-
assertFileDoesNotExist() public static
Asserts that a file does not exist.
-
assertFileEquals() public static
Asserts that the contents of one file is equal to the contents of another file.
-
assertFileEqualsCanonicalizing() public static
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
-
assertFileEqualsIgnoringCase() public static
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
-
assertFileExists() public static
Asserts that a file exists.
-
assertFileIsNotReadable() public static
Asserts that a file exists and is not readable.
-
assertFileIsNotWritable() public static
Asserts that a file exists and is not writable.
-
assertFileIsReadable() public static
Asserts that a file exists and is readable.
-
assertFileIsWritable() public static
Asserts that a file exists and is writable.
-
assertFileNotEquals() public static
Asserts that the contents of one file is not equal to the contents of another file.
-
assertFileNotEqualsCanonicalizing() public static
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
-
assertFileNotEqualsIgnoringCase() public static
Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
-
assertFileNotExists() public static deprecated
Asserts that a file does not exist.
-
assertFileNotIsReadable() public static deprecated
Asserts that a file exists and is not readable.
-
assertFileNotIsWritable() public static deprecated
Asserts that a file exists and is not writable.
-
assertFileResponse() public
Asserts that a file with the given name was sent in the response
-
assertFinite() public static
Asserts that a variable is finite.
-
assertFlashElement() public
Asserts a flash element was set
-
assertFlashElementAt() public
Asserts a flash element was set at a certain index
-
assertFlashMessage() public
Asserts a flash message was set
-
assertFlashMessageAt() public
Asserts a flash message was set at a certain index
-
assertGreaterThan() public static
Asserts that a value is greater than another value.
-
assertGreaterThanOrEqual() public static
Asserts that a value is greater than or equal to another value.
-
assertHeader() public
Asserts response headers
-
assertHeaderContains() public
Asserts response header contains a string
-
assertHeaderNotContains() public
Asserts response header does not contain a string
-
assertHtml() public
Asserts HTML tags.
-
assertInfinite() public static
Asserts that a variable is infinite.
-
assertInstanceOf() public static
Asserts that a variable is of a given type.
-
assertIsArray() public static
Asserts that a variable is of type array.
-
assertIsBool() public static
Asserts that a variable is of type bool.
-
assertIsCallable() public static
Asserts that a variable is of type callable.
-
assertIsClosedResource() public static
Asserts that a variable is of type resource and is closed.
-
assertIsFloat() public static
Asserts that a variable is of type float.
-
assertIsInt() public static
Asserts that a variable is of type int.
-
assertIsIterable() public static
Asserts that a variable is of type iterable.
-
assertIsNotArray() public static
Asserts that a variable is not of type array.
-
assertIsNotBool() public static
Asserts that a variable is not of type bool.
-
assertIsNotCallable() public static
Asserts that a variable is not of type callable.
-
assertIsNotClosedResource() public static
Asserts that a variable is not of type resource.
-
assertIsNotFloat() public static
Asserts that a variable is not of type float.
-
assertIsNotInt() public static
Asserts that a variable is not of type int.
-
assertIsNotIterable() public static
Asserts that a variable is not of type iterable.
-
assertIsNotNumeric() public static
Asserts that a variable is not of type numeric.
-
assertIsNotObject() public static
Asserts that a variable is not of type object.
-
assertIsNotReadable() public static
Asserts that a file/dir exists and is not readable.
-
assertIsNotResource() public static
Asserts that a variable is not of type resource.
-
assertIsNotScalar() public static
Asserts that a variable is not of type scalar.
-
assertIsNotString() public static
Asserts that a variable is not of type string.
-
assertIsNotWritable() public static
Asserts that a file/dir exists and is not writable.
-
assertIsNumeric() public static
Asserts that a variable is of type numeric.
-
assertIsObject() public static
Asserts that a variable is of type object.
-
assertIsReadable() public static
Asserts that a file/dir is readable.
-
assertIsResource() public static
Asserts that a variable is of type resource.
-
assertIsScalar() public static
Asserts that a variable is of type scalar.
-
assertIsString() public static
Asserts that a variable is of type string.
-
assertIsWritable() public static
Asserts that a file/dir exists and is writable.
-
assertJson() public static
Asserts that a string is a valid JSON string.
-
assertJsonFileEqualsJsonFile() public static
Asserts that two JSON files are equal.
-
assertJsonFileNotEqualsJsonFile() public static
Asserts that two JSON files are not equal.
-
assertJsonStringEqualsJsonFile() public static
Asserts that the generated JSON encoded object and the content of the given file are equal.
-
assertJsonStringEqualsJsonString() public static
Asserts that two given JSON encoded objects or arrays are equal.
-
assertJsonStringNotEqualsJsonFile() public static
Asserts that the generated JSON encoded object and the content of the given file are not equal.
-
assertJsonStringNotEqualsJsonString() public static
Asserts that two given JSON encoded objects or arrays are not equal.
-
assertLayout() public
Asserts that the search string was in the layout name.
-
assertLessThan() public static
Asserts that a value is smaller than another value.
-
assertLessThanOrEqual() public static
Asserts that a value is smaller than or equal to another value.
-
assertMatchesRegularExpression() public static
Asserts that a string matches a given regular expression.
-
assertNan() public static
Asserts that a variable is nan.
-
assertNoRedirect() public
Asserts that the Location header is not set.
-
assertNotContains() public static
Asserts that a haystack does not contain a needle.
-
assertNotContainsEquals() public static
-
assertNotContainsOnly() public static
Asserts that a haystack does not contain only values of a given type.
-
assertNotCount() public static
Asserts the number of elements of an array, Countable or Traversable.
-
assertNotEmpty() public static
Asserts that a variable is not empty.
-
assertNotEquals() public static
Asserts that two variables are not equal.
-
assertNotEqualsCanonicalizing() public static
Asserts that two variables are not equal (canonicalizing).
-
assertNotEqualsIgnoringCase() public static
Asserts that two variables are not equal (ignoring case).
-
assertNotEqualsWithDelta() public static
Asserts that two variables are not equal (with delta).
-
assertNotFalse() public static
Asserts that a condition is not false.
-
assertNotInstanceOf() public static
Asserts that a variable is not of a given type.
-
assertNotIsReadable() public static deprecated
Asserts that a file/dir exists and is not readable.
-
assertNotIsWritable() public static deprecated
Asserts that a file/dir exists and is not writable.
-
assertNotNull() public static
Asserts that a variable is not null.
-
assertNotRegExp() public static deprecated
Asserts that a string does not match a given regular expression.
-
assertNotSame() public static
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.
-
assertNotSameSize() public static
Assert that the size of two arrays (or
Countable
orTraversable
objects) is not the same. -
assertNotTrue() public static
Asserts that a condition is not true.
-
assertNotWithinRange() protected static
Compatibility function to test if a value is not between an acceptable range.
-
assertNull() public static
Asserts that a variable is null.
-
assertObjectEquals() public static
-
assertObjectHasAttribute() public static deprecated
Asserts that an object has a specified attribute.
-
assertObjectHasProperty() public static
Asserts that an object has a specified property.
-
assertObjectNotHasAttribute() public static deprecated
Asserts that an object does not have a specified attribute.
-
assertObjectNotHasProperty() public static
Asserts that an object does not have a specified property.
-
assertPathEquals() protected static
Compatibility function to test paths.
-
assertPostConditions() protected
Performs assertions shared by all tests of a test case.
-
assertPreConditions() protected
Performs assertions shared by all tests of a test case.
-
assertRedirect() public
Asserts that the Location header is correct. Comparison is made against a full URL.
-
assertRedirectContains() public
Asserts that the Location header contains a substring
-
assertRedirectEquals() public
Asserts that the Location header is correct. Comparison is made against exactly the URL provided.
-
assertRedirectNotContains() public
Asserts that the Location header does not contain a substring
-
assertRegExp() public static deprecated
Asserts that a string matches a given regular expression.
-
assertRegExpSql() public
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 -
assertResponseCode() public
Asserts a specific response status code.
-
assertResponseContains() public
Asserts content exists in the response body.
-
assertResponseEmpty() public
Assert response content is empty.
-
assertResponseEquals() public
Asserts content in the response body equals.
-
assertResponseError() public
Asserts that the response status code is in the 4xx range.
-
assertResponseFailure() public
Asserts that the response status code is in the 5xx range.
-
assertResponseNotContains() public
Asserts content does not exist in the response body.
-
assertResponseNotEmpty() public
Assert response content is not empty.
-
assertResponseNotEquals() public
Asserts content in the response body not equals.
-
assertResponseNotRegExp() public
Asserts that the response body does not match a given regular expression.
-
assertResponseOk() public
Asserts that the response status code is in the 2xx range.
-
assertResponseRegExp() public
Asserts that the response body matches a given regular expression.
-
assertResponseSuccess() public
Asserts that the response status code is in the 2xx/3xx range.
-
assertSame() public static
Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.
-
assertSameSize() public static
Assert that the size of two arrays (or
Countable
orTraversable
objects) is the same. -
assertSession() public
Asserts session contents
-
assertSessionHasKey() public
Asserts session key exists.
-
assertSessionNotHasKey() public
Asserts a session key does not exist.
-
assertStringContainsString() public static
-
assertStringContainsStringIgnoringCase() public static
-
assertStringEndsNotWith() public static
Asserts that a string ends not with a given suffix.
-
assertStringEndsWith() public static
Asserts that a string ends with a given suffix.
-
assertStringEqualsFile() public static
Asserts that the contents of a string is equal to the contents of a file.
-
assertStringEqualsFileCanonicalizing() public static
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
-
assertStringEqualsFileIgnoringCase() public static
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
-
assertStringMatchesFormat() public static
Asserts that a string matches a given format string.
-
assertStringMatchesFormatFile() public static
Asserts that a string matches a given format file.
-
assertStringNotContainsString() public static
-
assertStringNotContainsStringIgnoringCase() public static
-
assertStringNotEqualsFile() public static
Asserts that the contents of a string is not equal to the contents of a file.
-
assertStringNotEqualsFileCanonicalizing() public static
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
-
assertStringNotEqualsFileIgnoringCase() public static
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
-
assertStringNotMatchesFormat() public static
Asserts that a string does not match a given format string.
-
assertStringNotMatchesFormatFile() public static
Asserts that a string does not match a given format string.
-
assertStringStartsNotWith() public static
Asserts that a string starts not with a given prefix.
-
assertStringStartsWith() public static
Asserts that a string starts with a given prefix.
-
assertTemplate() public
Asserts that the search string was in the template name.
-
assertTextContains() public
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextEndsNotWith() public
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextEndsWith() public
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextEquals() public
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextNotContains() public
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextNotEquals() public
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextStartsNotWith() public
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertTextStartsWith() public
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
-
assertThat() public static
Evaluates a PHPUnit\Framework\Constraint matcher object.
-
assertTrue() public static
Asserts that a condition is true.
-
assertWithinRange() protected static
Compatibility function to test if a value is between an acceptable range.
-
assertXmlFileEqualsXmlFile() public static
Asserts that two XML files are equal.
-
assertXmlFileNotEqualsXmlFile() public static
Asserts that two XML files are not equal.
-
assertXmlStringEqualsXmlFile() public static
Asserts that two XML documents are equal.
-
assertXmlStringEqualsXmlString() public static
Asserts that two XML documents are equal.
-
assertXmlStringNotEqualsXmlFile() public static
Asserts that two XML documents are not equal.
-
assertXmlStringNotEqualsXmlString() public static
Asserts that two XML documents are not equal.
-
at() public static deprecated
Returns a matcher that matches when the method is executed at the given index.
-
atLeast() public static
Returns a matcher that matches when the method is executed at least N times.
-
atLeastOnce() public static
Returns a matcher that matches when the method is executed at least once.
-
atMost() public static
Returns a matcher that matches when the method is executed at most N times.
-
callback() public static
-
classHasAttribute() public static deprecated
-
classHasStaticAttribute() public static deprecated
-
cleanup() public
Clears the state used for requests.
-
cleanupContainer() public
Clears any mocks that were defined and cleans up application class configuration.
-
clearPlugins() public
Clear all plugins from the global plugin collection.
-
configApplication() public
Configure the application class to use in integration tests.
-
configRequest() public
Configures the data for the next request.
-
containsEqual() public static
-
containsIdentical() public static
-
containsOnly() public static
-
containsOnlyInstancesOf() public static
-
controllerSpy() public
Adds additional event spies to the controller/view event manager.
-
cookie() public
Sets a request cookie for future requests.
-
cookieEncrypted() public
Sets a encrypted request cookie for future requests.
-
count() public
-
countOf() public static
-
createApp() protected
Create an application instance.
-
createConfiguredMock() protected
Returns a configured mock object for the specified class.
-
createMock() protected
Returns a mock object for the specified class.
-
createPartialMock() protected
Returns a partial mock object for the specified class.
-
createResult() protected
Creates a default TestResult object.
-
createStub() protected
Makes configurable stub for the specified class.
-
createTestProxy() protected
Returns a test proxy for the specified class.
-
dataName() public
-
delete() public
Performs a DELETE request using the current request data.
-
deprecated() public
Helper method for check deprecation methods
-
directoryExists() public static
-
disableErrorHandlerMiddleware() public
Disable the error handler middleware.
-
doesNotPerformAssertions() public
-
doubledTypes() public
-
enableCsrfToken() public
Calling this method will add a CSRF token to the request.
-
enableRetainFlashMessages() public
Calling this method will re-store flash messages into the test session after being removed by the FlashHelper
-
enableSecurityToken() public
Calling this method will enable a SecurityComponent compatible token to be added to request data. This lets you easily test actions protected by SecurityComponent.
-
equalTo() public static
-
equalToCanonicalizing() public static
-
equalToIgnoringCase() public static
-
equalToWithDelta() public static
-
exactly() public static
Returns a matcher that matches when the method is executed exactly $count times.
-
expectDeprecation() public deprecated
-
expectDeprecationMessage() public deprecated
-
expectDeprecationMessageMatches() public deprecated
-
expectError() public deprecated
-
expectErrorMessage() public deprecated
-
expectErrorMessageMatches() public deprecated
-
expectException() public
-
expectExceptionCode() public
-
expectExceptionMessage() public
-
expectExceptionMessageMatches() public
-
expectExceptionObject() public
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.
-
expectNotToPerformAssertions() public
-
expectNotice() public deprecated
-
expectNoticeMessage() public deprecated
-
expectNoticeMessageMatches() public deprecated
-
expectOutputRegex() public
-
expectOutputString() public
-
expectWarning() public deprecated
-
expectWarningMessage() public deprecated
-
expectWarningMessageMatches() public deprecated
-
extractExceptionMessage() protected
Extract verbose message for existing exception
-
extractVerboseMessage() protected
Inspect controller to extract possible causes of the failed assertion
-
fail() public static
Fails a test with the given message.
-
fetchTable() public
Convenience method to get a table instance.
-
fileExists() public static
-
get() public
Performs a GET request using the current request data.
-
getActualOutput() public
-
getActualOutputForAssertion() public
-
getCount() public static
Return the current assertion count.
-
getDataSetAsString() public
-
getExpectedException() public
-
getExpectedExceptionCode() public
-
getExpectedExceptionMessage() public
-
getExpectedExceptionMessageRegExp() public
-
getFixtureStrategy() protected
Returns fixture strategy used by these tests.
-
getFixtures() public
Get the fixtures this test should use.
-
getGroups() public
-
getMockBuilder() public
Returns a builder object to create mock objects using a fluent interface.
-
getMockClass() protected deprecated
Mocks the specified class and returns the name of the mocked class.
-
getMockForAbstractClass() protected
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).
-
getMockForModel() public
Mock a model, maintain fixtures and table association
-
getMockForTrait() protected
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. -
getMockFromWsdl() protected
Returns a mock object based on the given WSDL file.
-
getName() public
-
getNumAssertions() public
Returns the number of assertions performed by this test.
-
getObjectForTrait() protected
Returns an object for the specified trait.
-
getProvidedData() public
Gets the data set of a TestCase.
-
getResult() public
-
getSession() protected
-
getSize() public
Returns the size of the test.
-
getStatus() public
-
getStatusMessage() public
-
getTableLocator() public
Gets the table locator.
-
getTestResultObject() public
-
greaterThan() public static
-
greaterThanOrEqual() public static
-
hasExpectationOnOutput() public
-
hasFailed() public
-
hasOutput() public
-
hasSize() public
-
head() public
Performs a HEAD request using the current request data.
-
identicalTo() public static
-
iniSet() protected
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.
-
isEmpty() public static
-
isFalse() public static
-
isFinite() public static
-
isInIsolation() public
-
isInfinite() public static
-
isInstanceOf() public static
-
isJson() public static
-
isLarge() public
-
isMedium() public
-
isNan() public static
-
isNull() public static
-
isReadable() public static
-
isSmall() public
-
isTrue() public static
-
isType() public static
-
isWritable() public static
-
lessThan() public static
-
lessThanOrEqual() public static
-
loadFixtures() public deprecated
Chooses which fixtures to load for a given test
-
loadPlugins() public
Load plugins into a simulated application.
-
loadRoutes() public
Load routes for the application.
-
logicalAnd() public static
-
logicalNot() public static
-
logicalOr() public static
-
logicalXor() public static
-
markAsRisky() public
-
markTestIncomplete() public static
Mark the test as incomplete.
-
markTestSkipped() public static
Mark the test as skipped.
-
matches() public static
-
matchesRegularExpression() public static
-
mockService() public
Add a mocked service to the container.
-
modifyContainer() public
Wrap the application's container with one containing mocks.
-
never() public static
Returns a matcher that matches when the method is never executed.
-
objectEquals() public static
-
objectHasAttribute() public static deprecated
-
onConsecutiveCalls() public static
-
onNotSuccessfulTest() protected
This method is called when a test method did not execute successfully.
-
once() public static
Returns a matcher that matches when the method is executed exactly once.
-
options() public
Performs an OPTIONS request using the current request data.
-
patch() public
Performs a PATCH request using the current request data.
-
post() public
Performs a POST request using the current request data.
-
prophesize() protected deprecated
-
provides() public
Returns the normalized test name as class::method.
-
put() public
Performs a PUT request using the current request data.
-
recordDoubledType() protected
-
registerComparator() public
-
registerMockObject() public
-
removeMockService() public
Remove a mocked service to the container.
-
removePlugins() public
Remove plugins from the global plugin collection.
-
requires() public
Returns a list of normalized dependency names, class::method.
-
resetCount() public static
Reset the assertion counter.
-
returnArgument() public static
-
returnCallback() public static
-
returnSelf() public static
Returns the current object.
-
returnValue() public static
-
returnValueMap() public static
-
run() public
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.
-
runBare() public
-
runTest() protected
Override to run the test and assert its state.
-
session() public
Sets session data.
-
setAppNamespace() public static
Set the app namespace
-
setBackupGlobals() public
-
setBackupStaticAttributes() public
-
setBeStrictAboutChangesToGlobalState() public
-
setDependencies() public
-
setDependencyInput() public
-
setGroups() public
-
setInIsolation() public
-
setLocale() protected
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
-
setName() public
-
setOutputCallback() public
-
setPreserveGlobalState() public
-
setRegisterMockObjectsFromTestArgumentsRecursively() public
-
setResult() public
-
setRunClassInSeparateProcess() public
-
setRunTestInSeparateProcess() public
-
setTableLocator() public
Sets the table locator.
-
setTestResultObject() public
-
setUnlockedFields() public
Set list of fields that are excluded from field validation.
-
setUp() protected
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.
-
setUpBeforeClass() public static
This method is called before the first test of this test class is run.
-
setupFixtures() protected
Initialized and loads any use fixtures.
-
skipIf() public
Overrides SimpleTestCase::skipIf to provide a boolean return value
-
skipUnless() protected
Compatibility function for skipping.
-
sortId() public
-
stringContains() public static
-
stringEndsWith() public static
-
stringStartsWith() public static
-
tearDown() protected
teardown any static object changes and restore them.
-
tearDownAfterClass() public static
This method is called after the last test of this test class is run.
-
teardownFixtures() protected
Unloads any use fixtures.
-
throwException() public static
-
toString() public
Returns a string representation of the test case.
-
useHttpServer() public
No-op method.
-
usesDataProvider() public
-
viewVariable() public
Fetches a view variable by name.
-
withErrorReporting() public
Helper method for tests that needs to use error_reporting()
Method Detail
__construct() ΒΆ public
__construct(?string $name = null, array $data = [], int|string $dataName = '')
Parameters
-
?string
$name optional -
array
$data optional -
int|string
$dataName optional
_addTokens() ΒΆ protected
_addTokens(string $url, array $data): array
Add the CSRF and Security Component tokens if necessary.
Parameters
-
string
$url The URL the form is being submitted on.
-
array
$data The request body data.
Returns
array
_assertAttributes() ΒΆ protected
_assertAttributes(array<string, mixed> $assertions, string $string, bool $fullDebug = false, array|string $regex = ''): string|false
Check the attributes as part of an assertTags() check.
Parameters
-
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
Returns
string|false
_buildRequest() ΒΆ protected
_buildRequest(string $url, string $method, array|string $data = []): array
Creates a request object with the configured options and parameters.
Parameters
-
string
$url The URL
-
string
$method The HTTP method
-
array|string
$data optional The request data.
Returns
array
_castToString() ΒΆ protected
_castToString(array $data): array
Recursively casts all data to string as that is how data would be POSTed in the real world
Parameters
-
array
$data POST data
Returns
array
_checkCipher() ΒΆ protected
_checkCipher(string $encrypt): void
Helper method for validating encryption cipher names.
Parameters
-
string
$encrypt The cipher name.
Returns
void
Throws
RuntimeException
When an invalid cipher is provided.
_decode() ΒΆ protected
_decode(string $value, string|false $encrypt, string|null $key): array|string
Decodes and decrypts a single value.
Parameters
-
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.
Returns
array|string
_decrypt() ΒΆ protected
_decrypt(array<string>|string $values, string|false $mode, string|null $key = null): array|string
Decrypts $value using public $type method in Security class
Parameters
-
array<string>|string
$values Values to decrypt
-
string|false
$mode Encryption mode
-
string|null
$key optional Used as the security salt if specified.
Returns
array|string
_encrypt() ΒΆ protected
_encrypt(array|string $value, string|false $encrypt, string|null $key = null): string
Encrypts $value using public $type method in Security class
Parameters
-
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.
Returns
string
_explode() ΒΆ protected
_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().
Parameters
-
string
$string A string containing JSON encoded data, or a bare string.
Returns
array|string
_getBodyAsString() ΒΆ protected
_getBodyAsString(): string
Get the response body as string
Returns
string
_getCookieEncryptionKey() ΒΆ protected
_getCookieEncryptionKey(): string
Returns the encryption key to be used.
Returns
string
_getTableClassName() ΒΆ protected
_getTableClassName(string $alias, array<string, mixed> $options): string
Gets the class name for the table.
Parameters
-
string
$alias The model to get a mock for.
-
array<string, mixed>
$options The config data for the mock's constructor.
Returns
string
Throws
Cake\ORM\Exception\MissingTableClassException
_handleError() ΒΆ protected
_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.
Parameters
-
Throwable
$exception Exception to handle.
Returns
void
_implode() ΒΆ protected
_implode(array $array): string
Implode method to keep keys are multidimensional arrays
Parameters
-
array
$array Map of key and values
Returns
string
_makeDispatcher() ΒΆ protected
_makeDispatcher(): Cake\TestSuite\MiddlewareDispatcher
Get the correct dispatcher instance.
Returns
Cake\TestSuite\MiddlewareDispatcher
_normalizePath() ΒΆ protected
_normalizePath(string $path): string
Normalize a path for comparison.
Parameters
-
string
$path Path separated by "/" slash.
Returns
string
_sendRequest() ΒΆ protected
_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.
Parameters
-
array|string
$url The URL
-
string
$method The HTTP method
-
array|string
$data optional The request data.
Returns
void
Throws
PHPUnit\ExceptionThrowable
_url() ΒΆ protected
_url(string $url): array
Creates a valid request url and parameter array more like Request::_url()
Parameters
-
string
$url The URL
Returns
array
addFixture() ΒΆ protected
addFixture(string $fixture): $this
Adds a fixture to this test case.
Examples:
- core.Tags
- app.MyRecords
- plugin.MyPluginName.MyModelName
Use this method inside your test cases' {@link getFixtures()} method to build up the fixture list.
Parameters
-
string
$fixture Fixture
Returns
$this
addToAssertionCount() ΒΆ public
addToAssertionCount(int $count): void
Parameters
-
int
$count
Returns
void
any() ΒΆ public static
any(): AnyInvokedCountMatcher
Returns a matcher that matches when the method is executed zero or more times.
Returns
AnyInvokedCountMatcher
arrayHasKey() ΒΆ public static
arrayHasKey(int|string $key): ArrayHasKey
Parameters
-
int|string
$key
Returns
ArrayHasKey
assertArrayHasKey() ΒΆ public static
assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
Asserts that an array has a specified key.
Parameters
-
int|string
$key -
array|ArrayAccess
$array -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertArrayNotHasKey() ΒΆ public static
assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
Asserts that an array does not have a specified key.
Parameters
-
int|string
$key -
array|ArrayAccess
$array -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertClassHasAttribute() ΒΆ public static
assertClassHasAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class has a specified attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertClassHasStaticAttribute() ΒΆ public static
assertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class has a specified static attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertClassNotHasAttribute() ΒΆ public static
assertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class does not have a specified attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertClassNotHasStaticAttribute() ΒΆ public static
assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class does not have a specified static attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertContains() ΒΆ public static
assertContains(mixed $needle, iterable $haystack, string $message = ''): void
Asserts that a haystack contains a needle.
Parameters
-
$needle
-
iterable
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertContainsEquals() ΒΆ public static
assertContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
Parameters
-
$needle
-
iterable
$haystack -
string
$message optional
Returns
void
assertContainsOnly() ΒΆ public static
assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack contains only values of a given type.
Parameters
-
string
$type -
iterable
$haystack -
?bool
$isNativeType optional -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertContainsOnlyInstancesOf() ΒΆ public static
assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void
Asserts that a haystack contains only instances of a given class name.
Parameters
-
string
$className -
iterable
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertContentType() ΒΆ public
assertContentType(string $type, string $message = ''): void
Asserts content type
Parameters
-
string
$type The content-type to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertCookie() ΒΆ public
assertCookie(mixed $expected, string $name, string $message = ''): void
Asserts cookie values
Parameters
-
mixed
$expected The expected contents.
-
string
$name The cookie name.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertCookieEncrypted() ΒΆ public
assertCookieEncrypted(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.
Parameters
-
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.
Returns
void
See Also
assertCookieNotSet() ΒΆ public
assertCookieNotSet(string $cookie, string $message = ''): void
Asserts a cookie has not been set in the response
Parameters
-
string
$cookie The cookie name to check
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertCount() ΒΆ public static
assertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
Parameters
-
int
$expectedCount -
Countable|iterable
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertDirectoryDoesNotExist() ΒΆ public static
assertDirectoryDoesNotExist(string $directory, string $message = ''): void
Asserts that a directory does not exist.
Parameters
-
string
$directory Directory
-
string
$message optional Message
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
assertDirectoryExists() ΒΆ public static
assertDirectoryExists(string $directory, string $message = ''): void
Asserts that a directory exists.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryIsNotReadable() ΒΆ public static
assertDirectoryIsNotReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryIsNotWritable() ΒΆ public static
assertDirectoryIsNotWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryIsReadable() ΒΆ public static
assertDirectoryIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is readable.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryIsWritable() ΒΆ public static
assertDirectoryIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is writable.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryNotExists() ΒΆ public static
assertDirectoryNotExists(string $directory, string $message = ''): void
Asserts that a directory does not exist.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryNotIsReadable() ΒΆ public static
assertDirectoryNotIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDirectoryNotIsWritable() ΒΆ public static
assertDirectoryNotIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
Parameters
-
string
$directory -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertDoesNotMatchRegularExpression() ΒΆ public static
assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void
Asserts that a string does not match a given regular expression.
Parameters
-
string
$pattern Regex pattern
-
string
$string String to test
-
string
$message optional Message
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEmpty() ΒΆ public static
assertEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is empty.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertEqualXMLStructure() ΒΆ public static
assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void
Asserts that a hierarchy of DOMElements matches.
Parameters
-
DOMElement
$expectedElement -
DOMElement
$actualElement -
bool
$checkAttributes optional -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
AssertionFailedError
ExpectationFailedException
assertEquals() ΒΆ public static
assertEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertEqualsCanonicalizing() ΒΆ public static
assertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (canonicalizing).
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertEqualsIgnoringCase() ΒΆ public static
assertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (ignoring case).
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertEqualsSql() ΒΆ public
assertEqualsSql(string $expected, string $actual, string $message = ''): void
Assert that a string matches SQL with db-specific characters like quotes removed.
Parameters
-
string
$expected The expected sql
-
string
$actual The sql to compare
-
string
$message optional The message to display on failure
Returns
void
assertEqualsWithDelta() ΒΆ public static
assertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are equal (with delta).
Parameters
-
$expected
-
$actual
-
float
$delta -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertEventFired() ΒΆ public
assertEventFired(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
Parameters
-
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
Returns
void
assertEventFiredWith() ΒΆ public
assertEventFiredWith(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
Parameters
-
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
Returns
void
assertFalse() ΒΆ public static
assertFalse(mixed $condition, string $message = ''): void
Asserts that a condition is false.
Parameters
-
$condition
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileDoesNotExist() ΒΆ public static
assertFileDoesNotExist(string $filename, string $message = ''): void
Asserts that a file does not exist.
Parameters
-
string
$filename Filename
-
string
$message optional Message
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileEquals() ΒΆ public static
assertFileEquals(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file.
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileEqualsCanonicalizing() ΒΆ public static
assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileEqualsIgnoringCase() ΒΆ public static
assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileExists() ΒΆ public static
assertFileExists(string $filename, string $message = ''): void
Asserts that a file exists.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileIsNotReadable() ΒΆ public static
assertFileIsNotReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
Parameters
-
string
$file -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileIsNotWritable() ΒΆ public static
assertFileIsNotWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
Parameters
-
string
$file -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileIsReadable() ΒΆ public static
assertFileIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is readable.
Parameters
-
string
$file -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileIsWritable() ΒΆ public static
assertFileIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is writable.
Parameters
-
string
$file -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileNotEquals() ΒΆ public static
assertFileNotEquals(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file.
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileNotEqualsCanonicalizing() ΒΆ public static
assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileNotEqualsIgnoringCase() ΒΆ public static
assertFileNotEqualsIgnoringCase(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).
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileNotExists() ΒΆ public static
assertFileNotExists(string $filename, string $message = ''): void
Asserts that a file does not exist.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileNotIsReadable() ΒΆ public static
assertFileNotIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
Parameters
-
string
$file -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileNotIsWritable() ΒΆ public static
assertFileNotIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
Parameters
-
string
$file -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFileResponse() ΒΆ public
assertFileResponse(string $expected, string $message = ''): void
Asserts that a file with the given name was sent in the response
Parameters
-
string
$expected The absolute file path that should be sent in the response.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertFinite() ΒΆ public static
assertFinite(mixed $actual, string $message = ''): void
Asserts that a variable is finite.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertFlashElement() ΒΆ public
assertFlashElement(string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash element was set
Parameters
-
string
$expected Expected element name
-
string
$key optional Flash key
-
string
$message optional Assertion failure message
Returns
void
assertFlashElementAt() ΒΆ public
assertFlashElementAt(int $at, string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash element was set at a certain index
Parameters
-
int
$at Flash index
-
string
$expected Expected element name
-
string
$key optional Flash key
-
string
$message optional Assertion failure message
Returns
void
assertFlashMessage() ΒΆ public
assertFlashMessage(string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash message was set
Parameters
-
string
$expected Expected message
-
string
$key optional Flash key
-
string
$message optional Assertion failure message
Returns
void
assertFlashMessageAt() ΒΆ public
assertFlashMessageAt(int $at, string $expected, string $key = 'flash', string $message = ''): void
Asserts a flash message was set at a certain index
Parameters
-
int
$at Flash index
-
string
$expected Expected message
-
string
$key optional Flash key
-
string
$message optional Assertion failure message
Returns
void
assertGreaterThan() ΒΆ public static
assertGreaterThan(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is greater than another value.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertGreaterThanOrEqual() ΒΆ public static
assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is greater than or equal to another value.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertHeader() ΒΆ public
assertHeader(string $header, string $content, string $message = ''): void
Asserts response headers
Parameters
-
string
$header The header to check
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertHeaderContains() ΒΆ public
assertHeaderContains(string $header, string $content, string $message = ''): void
Asserts response header contains a string
Parameters
-
string
$header The header to check
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertHeaderNotContains() ΒΆ public
assertHeaderNotContains(string $header, string $content, string $message = ''): void
Asserts response header does not contain a string
Parameters
-
string
$header The header to check
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertHtml() ΒΆ public
assertHtml(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.
Parameters
-
array
$expected An array, see above
-
string
$string An HTML/XHTML/XML string
-
bool
$fullDebug optional Whether more verbose output should be used.
Returns
bool
assertInfinite() ΒΆ public static
assertInfinite(mixed $actual, string $message = ''): void
Asserts that a variable is infinite.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertInstanceOf() ΒΆ public static
assertInstanceOf(string $expected, mixed $actual, string $message = ''): void
Asserts that a variable is of a given type.
Parameters
-
string
$expected -
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertIsArray() ΒΆ public static
assertIsArray(mixed $actual, string $message = ''): void
Asserts that a variable is of type array.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsBool() ΒΆ public static
assertIsBool(mixed $actual, string $message = ''): void
Asserts that a variable is of type bool.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsCallable() ΒΆ public static
assertIsCallable(mixed $actual, string $message = ''): void
Asserts that a variable is of type callable.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsClosedResource() ΒΆ public static
assertIsClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource and is closed.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsFloat() ΒΆ public static
assertIsFloat(mixed $actual, string $message = ''): void
Asserts that a variable is of type float.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsInt() ΒΆ public static
assertIsInt(mixed $actual, string $message = ''): void
Asserts that a variable is of type int.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsIterable() ΒΆ public static
assertIsIterable(mixed $actual, string $message = ''): void
Asserts that a variable is of type iterable.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotArray() ΒΆ public static
assertIsNotArray(mixed $actual, string $message = ''): void
Asserts that a variable is not of type array.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotBool() ΒΆ public static
assertIsNotBool(mixed $actual, string $message = ''): void
Asserts that a variable is not of type bool.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotCallable() ΒΆ public static
assertIsNotCallable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type callable.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotClosedResource() ΒΆ public static
assertIsNotClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotFloat() ΒΆ public static
assertIsNotFloat(mixed $actual, string $message = ''): void
Asserts that a variable is not of type float.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotInt() ΒΆ public static
assertIsNotInt(mixed $actual, string $message = ''): void
Asserts that a variable is not of type int.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotIterable() ΒΆ public static
assertIsNotIterable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type iterable.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotNumeric() ΒΆ public static
assertIsNotNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is not of type numeric.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotObject() ΒΆ public static
assertIsNotObject(mixed $actual, string $message = ''): void
Asserts that a variable is not of type object.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotReadable() ΒΆ public static
assertIsNotReadable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not readable.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotResource() ΒΆ public static
assertIsNotResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotScalar() ΒΆ public static
assertIsNotScalar(mixed $actual, string $message = ''): void
Asserts that a variable is not of type scalar.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotString() ΒΆ public static
assertIsNotString(mixed $actual, string $message = ''): void
Asserts that a variable is not of type string.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNotWritable() ΒΆ public static
assertIsNotWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not writable.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsNumeric() ΒΆ public static
assertIsNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is of type numeric.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsObject() ΒΆ public static
assertIsObject(mixed $actual, string $message = ''): void
Asserts that a variable is of type object.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsReadable() ΒΆ public static
assertIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir is readable.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsResource() ΒΆ public static
assertIsResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsScalar() ΒΆ public static
assertIsScalar(mixed $actual, string $message = ''): void
Asserts that a variable is of type scalar.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsString() ΒΆ public static
assertIsString(mixed $actual, string $message = ''): void
Asserts that a variable is of type string.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertIsWritable() ΒΆ public static
assertIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is writable.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJson() ΒΆ public static
assertJson(string $actualJson, string $message = ''): void
Asserts that a string is a valid JSON string.
Parameters
-
string
$actualJson -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJsonFileEqualsJsonFile() ΒΆ public static
assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two JSON files are equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJsonFileNotEqualsJsonFile() ΒΆ public static
assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two JSON files are not equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJsonStringEqualsJsonFile() ΒΆ public static
assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
Asserts that the generated JSON encoded object and the content of the given file are equal.
Parameters
-
string
$expectedFile -
string
$actualJson -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJsonStringEqualsJsonString() ΒΆ public static
assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
Asserts that two given JSON encoded objects or arrays are equal.
Parameters
-
string
$expectedJson -
string
$actualJson -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJsonStringNotEqualsJsonFile() ΒΆ public static
assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
Asserts that the generated JSON encoded object and the content of the given file are not equal.
Parameters
-
string
$expectedFile -
string
$actualJson -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertJsonStringNotEqualsJsonString() ΒΆ public static
assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
Asserts that two given JSON encoded objects or arrays are not equal.
Parameters
-
string
$expectedJson -
string
$actualJson -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertLayout() ΒΆ public
assertLayout(string $content, string $message = ''): void
Asserts that the search string was in the layout name.
Parameters
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertLessThan() ΒΆ public static
assertLessThan(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is smaller than another value.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertLessThanOrEqual() ΒΆ public static
assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is smaller than or equal to another value.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertMatchesRegularExpression() ΒΆ public static
assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
Asserts that a string matches a given regular expression.
Parameters
-
string
$pattern Regex pattern
-
string
$string String to test
-
string
$message optional Message
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNan() ΒΆ public static
assertNan(mixed $actual, string $message = ''): void
Asserts that a variable is nan.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNoRedirect() ΒΆ public
assertNoRedirect(string $message = ''): void
Asserts that the Location header is not set.
Parameters
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertNotContains() ΒΆ public static
assertNotContains(mixed $needle, iterable $haystack, string $message = ''): void
Asserts that a haystack does not contain a needle.
Parameters
-
$needle
-
iterable
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertNotContainsEquals() ΒΆ public static
assertNotContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
Parameters
-
$needle
-
iterable
$haystack -
string
$message optional
Returns
void
assertNotContainsOnly() ΒΆ public static
assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack does not contain only values of a given type.
Parameters
-
string
$type -
iterable
$haystack -
?bool
$isNativeType optional -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotCount() ΒΆ public static
assertNotCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
Parameters
-
int
$expectedCount -
Countable|iterable
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertNotEmpty() ΒΆ public static
assertNotEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is not empty.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotEquals() ΒΆ public static
assertNotEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotEqualsCanonicalizing() ΒΆ public static
assertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (canonicalizing).
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotEqualsIgnoringCase() ΒΆ public static
assertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (ignoring case).
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotEqualsWithDelta() ΒΆ public static
assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are not equal (with delta).
Parameters
-
$expected
-
$actual
-
float
$delta -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotFalse() ΒΆ public static
assertNotFalse(mixed $condition, string $message = ''): void
Asserts that a condition is not false.
Parameters
-
$condition
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotInstanceOf() ΒΆ public static
assertNotInstanceOf(string $expected, mixed $actual, string $message = ''): void
Asserts that a variable is not of a given type.
Parameters
-
string
$expected -
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertNotIsReadable() ΒΆ public static
assertNotIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not readable.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotIsWritable() ΒΆ public static
assertNotIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not writable.
Parameters
-
string
$filename -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotNull() ΒΆ public static
assertNotNull(mixed $actual, string $message = ''): void
Asserts that a variable is not null.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotRegExp() ΒΆ public static
assertNotRegExp(string $pattern, string $string, string $message = ''): void
Asserts that a string does not match a given regular expression.
Parameters
-
string
$pattern -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotSame() ΒΆ public static
assertNotSame(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.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotSameSize() ΒΆ public static
assertNotSameSize(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.
Parameters
-
Countable|iterable
$expected -
Countable|iterable
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertNotTrue() ΒΆ public static
assertNotTrue(mixed $condition, string $message = ''): void
Asserts that a condition is not true.
Parameters
-
$condition
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertNotWithinRange() ΒΆ protected static
assertNotWithinRange(float $expected, float $result, float $margin, string $message = ''): void
Compatibility function to test if a value is not between an acceptable range.
Parameters
-
float
$expected -
float
$result -
float
$margin the rage of acceptation
-
string
$message optional the text to display if the assertion is not correct
Returns
void
assertNull() ΒΆ public static
assertNull(mixed $actual, string $message = ''): void
Asserts that a variable is null.
Parameters
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertObjectEquals() ΒΆ public static
assertObjectEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void
Parameters
-
object
$expected -
object
$actual -
string
$method optional -
string
$message optional
Returns
void
Throws
ExpectationFailedException
assertObjectHasAttribute() ΒΆ public static
assertObjectHasAttribute(string $attributeName, object $object, string $message = ''): void
Asserts that an object has a specified attribute.
Parameters
-
string
$attributeName -
object
$object -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertObjectHasProperty() ΒΆ public static
assertObjectHasProperty(string $propertyName, object $object, string $message = ''): void
Asserts that an object has a specified property.
Parameters
-
string
$propertyName -
object
$object -
string
$message optional
Returns
void
Throws
ExpectationFailedException
assertObjectNotHasAttribute() ΒΆ public static
assertObjectNotHasAttribute(string $attributeName, object $object, string $message = ''): void
Asserts that an object does not have a specified attribute.
Parameters
-
string
$attributeName -
object
$object -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertObjectNotHasProperty() ΒΆ public static
assertObjectNotHasProperty(string $propertyName, object $object, string $message = ''): void
Asserts that an object does not have a specified property.
Parameters
-
string
$propertyName -
object
$object -
string
$message optional
Returns
void
Throws
ExpectationFailedException
assertPathEquals() ΒΆ protected static
assertPathEquals(string $expected, string $result, string $message = ''): void
Compatibility function to test paths.
Parameters
-
string
$expected -
string
$result -
string
$message optional the text to display if the assertion is not correct
Returns
void
assertPostConditions() ΒΆ protected
assertPostConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between test and tearDown().
Returns
void
assertPreConditions() ΒΆ protected
assertPreConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between setUp() and test.
Returns
void
assertRedirect() ΒΆ public
assertRedirect(array|string|null $url = null, string $message = ''): void
Asserts that the Location header is correct. Comparison is made against a full URL.
Parameters
-
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.
Returns
void
assertRedirectContains() ΒΆ public
assertRedirectContains(string $url, string $message = ''): void
Asserts that the Location header contains a substring
Parameters
-
string
$url The URL you expected the client to go to.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertRedirectEquals() ΒΆ public
assertRedirectEquals(array|string|null $url = null, string $message = ''): void
Asserts that the Location header is correct. Comparison is made against exactly the URL provided.
Parameters
-
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.
Returns
void
assertRedirectNotContains() ΒΆ public
assertRedirectNotContains(string $url, string $message = ''): void
Asserts that the Location header does not contain a substring
Parameters
-
string
$url The URL you expected the client to go to.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertRegExp() ΒΆ public static
assertRegExp(string $pattern, string $string, string $message = ''): void
Asserts that a string matches a given regular expression.
Parameters
-
string
$pattern -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertRegExpSql() ΒΆ public
assertRegExpSql(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
Parameters
-
string
$pattern The expected sql pattern
-
string
$actual The sql to compare
-
bool
$optional optional Whether quote characters (marked with <>) are optional
Returns
void
assertResponseCode() ΒΆ public
assertResponseCode(int $code, string $message = ''): void
Asserts a specific response status code.
Parameters
-
int
$code Status code to assert.
-
string
$message optional Custom message for failure.
Returns
void
assertResponseContains() ΒΆ public
assertResponseContains(string $content, string $message = '', bool $ignoreCase = false): void
Asserts content exists in the response body.
Parameters
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
-
bool
$ignoreCase optional A flag to check whether we should ignore case or not.
Returns
void
assertResponseEmpty() ΒΆ public
assertResponseEmpty(string $message = ''): void
Assert response content is empty.
Parameters
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertResponseEquals() ΒΆ public
assertResponseEquals(mixed $content, string $message = ''): void
Asserts content in the response body equals.
Parameters
-
mixed
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertResponseError() ΒΆ public
assertResponseError(string $message = ''): void
Asserts that the response status code is in the 4xx range.
Parameters
-
string
$message optional Custom message for failure.
Returns
void
assertResponseFailure() ΒΆ public
assertResponseFailure(string $message = ''): void
Asserts that the response status code is in the 5xx range.
Parameters
-
string
$message optional Custom message for failure.
Returns
void
assertResponseNotContains() ΒΆ public
assertResponseNotContains(string $content, string $message = '', bool $ignoreCase = false): void
Asserts content does not exist in the response body.
Parameters
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
-
bool
$ignoreCase optional A flag to check whether we should ignore case or not.
Returns
void
assertResponseNotEmpty() ΒΆ public
assertResponseNotEmpty(string $message = ''): void
Assert response content is not empty.
Parameters
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertResponseNotEquals() ΒΆ public
assertResponseNotEquals(mixed $content, string $message = ''): void
Asserts content in the response body not equals.
Parameters
-
mixed
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertResponseNotRegExp() ΒΆ public
assertResponseNotRegExp(string $pattern, string $message = ''): void
Asserts that the response body does not match a given regular expression.
Parameters
-
string
$pattern The pattern to compare against.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertResponseOk() ΒΆ public
assertResponseOk(string $message = ''): void
Asserts that the response status code is in the 2xx range.
Parameters
-
string
$message optional Custom message for failure.
Returns
void
assertResponseRegExp() ΒΆ public
assertResponseRegExp(string $pattern, string $message = ''): void
Asserts that the response body matches a given regular expression.
Parameters
-
string
$pattern The pattern to compare against.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertResponseSuccess() ΒΆ public
assertResponseSuccess(string $message = ''): void
Asserts that the response status code is in the 2xx/3xx range.
Parameters
-
string
$message optional Custom message for failure.
Returns
void
assertSame() ΒΆ public static
assertSame(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.
Parameters
-
$expected
-
$actual
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertSameSize() ΒΆ public static
assertSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
Assert that the size of two arrays (or Countable
or Traversable
objects)
is the same.
Parameters
-
Countable|iterable
$expected -
Countable|iterable
$actual -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertSession() ΒΆ public
assertSession(mixed $expected, string $path, string $message = ''): void
Asserts session contents
Parameters
-
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.
Returns
void
assertSessionHasKey() ΒΆ public
assertSessionHasKey(string $path, string $message = ''): void
Asserts session key exists.
Parameters
-
string
$path The session data path. Uses Hash::get() compatible notation.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertSessionNotHasKey() ΒΆ public
assertSessionNotHasKey(string $path, string $message = ''): void
Asserts a session key does not exist.
Parameters
-
string
$path The session data path. Uses Hash::get() compatible notation.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertStringContainsString() ΒΆ public static
assertStringContainsString(string $needle, string $haystack, string $message = ''): void
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringContainsStringIgnoringCase() ΒΆ public static
assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringEndsNotWith() ΒΆ public static
assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends not with a given suffix.
Parameters
-
string
$suffix -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringEndsWith() ΒΆ public static
assertStringEndsWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends with a given suffix.
Parameters
-
string
$suffix -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringEqualsFile() ΒΆ public static
assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file.
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringEqualsFileCanonicalizing() ΒΆ public static
assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringEqualsFileIgnoringCase() ΒΆ public static
assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringMatchesFormat() ΒΆ public static
assertStringMatchesFormat(string $format, string $string, string $message = ''): void
Asserts that a string matches a given format string.
Parameters
-
string
$format -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringMatchesFormatFile() ΒΆ public static
assertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
Asserts that a string matches a given format file.
Parameters
-
string
$formatFile -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotContainsString() ΒΆ public static
assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotContainsStringIgnoringCase() ΒΆ public static
assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotEqualsFile() ΒΆ public static
assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file.
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotEqualsFileCanonicalizing() ΒΆ public static
assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotEqualsFileIgnoringCase() ΒΆ public static
assertStringNotEqualsFileIgnoringCase(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).
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotMatchesFormat() ΒΆ public static
assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
Asserts that a string does not match a given format string.
Parameters
-
string
$format -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringNotMatchesFormatFile() ΒΆ public static
assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
Asserts that a string does not match a given format string.
Parameters
-
string
$formatFile -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringStartsNotWith() ΒΆ public static
assertStringStartsNotWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts not with a given prefix.
Parameters
-
string
$prefix -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertStringStartsWith() ΒΆ public static
assertStringStartsWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts with a given prefix.
Parameters
-
string
$prefix -
string
$string -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertTemplate() ΒΆ public
assertTemplate(string $content, string $message = ''): void
Asserts that the search string was in the template name.
Parameters
-
string
$content The content to check for.
-
string
$message optional The failure message that will be appended to the generated message.
Returns
void
assertTextContains() ΒΆ public
assertTextContains(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.
Parameters
-
string
$needle The string to search for.
-
string
$haystack The string to search through.
-
string
$message optional The message to display on failure.
-
bool
$ignoreCase optional Whether the search should be case-sensitive.
Returns
void
assertTextEndsNotWith() ΒΆ public
assertTextEndsNotWith(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.
Parameters
-
string
$suffix The suffix to not find.
-
string
$string The string to search.
-
string
$message optional The message to use for failure.
Returns
void
assertTextEndsWith() ΒΆ public
assertTextEndsWith(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.
Parameters
-
string
$suffix The suffix to find.
-
string
$string The string to search.
-
string
$message optional The message to use for failure.
Returns
void
assertTextEquals() ΒΆ public
assertTextEquals(string $expected, string $result, string $message = ''): void
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$expected The expected value.
-
string
$result The actual value.
-
string
$message optional The message to use for failure.
Returns
void
assertTextNotContains() ΒΆ public
assertTextNotContains(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.
Parameters
-
string
$needle The string to search for.
-
string
$haystack The string to search through.
-
string
$message optional The message to display on failure.
-
bool
$ignoreCase optional Whether the search should be case-sensitive.
Returns
void
assertTextNotEquals() ΒΆ public
assertTextNotEquals(string $expected, string $result, string $message = ''): void
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$expected The expected value.
-
string
$result The actual value.
-
string
$message optional The message to use for failure.
Returns
void
assertTextStartsNotWith() ΒΆ public
assertTextStartsNotWith(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.
Parameters
-
string
$prefix The prefix to not find.
-
string
$string The string to search.
-
string
$message optional The message to use for failure.
Returns
void
assertTextStartsWith() ΒΆ public
assertTextStartsWith(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.
Parameters
-
string
$prefix The prefix to check for.
-
string
$string The string to search in.
-
string
$message optional The message to use for failure.
Returns
void
assertThat() ΒΆ public static
assertThat(mixed $value, Constraint $constraint, string $message = ''): void
Evaluates a PHPUnit\Framework\Constraint matcher object.
Parameters
-
$value
-
Constraint
$constraint -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertTrue() ΒΆ public static
assertTrue(mixed $condition, string $message = ''): void
Asserts that a condition is true.
Parameters
-
$condition
-
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertWithinRange() ΒΆ protected static
assertWithinRange(float $expected, float $result, float $margin, string $message = ''): void
Compatibility function to test if a value is between an acceptable range.
Parameters
-
float
$expected -
float
$result -
float
$margin the rage of acceptation
-
string
$message optional the text to display if the assertion is not correct
Returns
void
assertXmlFileEqualsXmlFile() ΒΆ public static
assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two XML files are equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
Exception
ExpectationFailedException
assertXmlFileNotEqualsXmlFile() ΒΆ public static
assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two XML files are not equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Returns
void
Throws
PHPUnit\Util\Exception
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
assertXmlStringEqualsXmlFile() ΒΆ public static
assertXmlStringEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
Parameters
-
string
$expectedFile -
DOMDocument|string
$actualXml -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
Xml\Exception
assertXmlStringEqualsXmlString() ΒΆ public static
assertXmlStringEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
Parameters
-
DOMDocument|string
$expectedXml -
DOMDocument|string
$actualXml -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
Xml\Exception
assertXmlStringNotEqualsXmlFile() ΒΆ public static
assertXmlStringNotEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
Parameters
-
string
$expectedFile -
DOMDocument|string
$actualXml -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
Xml\Exception
assertXmlStringNotEqualsXmlString() ΒΆ public static
assertXmlStringNotEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
Parameters
-
DOMDocument|string
$expectedXml -
DOMDocument|string
$actualXml -
string
$message optional
Returns
void
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
ExpectationFailedException
Xml\Exception
at() ΒΆ public static
at(int $index): InvokedAtIndexMatcher
Returns a matcher that matches when the method is executed at the given index.
Parameters
-
int
$index
Returns
InvokedAtIndexMatcher
atLeast() ΒΆ public static
atLeast(int $requiredInvocations): InvokedAtLeastCountMatcher
Returns a matcher that matches when the method is executed at least N times.
Parameters
-
int
$requiredInvocations
Returns
InvokedAtLeastCountMatcher
atLeastOnce() ΒΆ public static
atLeastOnce(): InvokedAtLeastOnceMatcher
Returns a matcher that matches when the method is executed at least once.
Returns
InvokedAtLeastOnceMatcher
atMost() ΒΆ public static
atMost(int $allowedInvocations): InvokedAtMostCountMatcher
Returns a matcher that matches when the method is executed at most N times.
Parameters
-
int
$allowedInvocations
Returns
InvokedAtMostCountMatcher
callback() ΒΆ public static
callback(callable $callback): Callback
Parameters
-
callable
$callback
Returns
Callback
classHasAttribute() ΒΆ public static
classHasAttribute(string $attributeName): ClassHasAttribute
Parameters
-
string
$attributeName
Returns
ClassHasAttribute
classHasStaticAttribute() ΒΆ public static
classHasStaticAttribute(string $attributeName): ClassHasStaticAttribute
Parameters
-
string
$attributeName
Returns
ClassHasStaticAttribute
cleanupContainer() ΒΆ public
cleanupContainer(): void
Clears any mocks that were defined and cleans up application class configuration.
Returns
void
clearPlugins() ΒΆ public
clearPlugins(): void
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
Returns
void
configApplication() ΒΆ public
configApplication(string $class, array|null $constructorArgs): void
Configure the application class to use in integration tests.
Parameters
-
string
$class The application class name.
-
array|null
$constructorArgs The constructor arguments for your application class.
Returns
void
configRequest() ΒΆ public
configRequest(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.
Parameters
-
array
$data The request data to use.
Returns
void
containsEqual() ΒΆ public static
containsEqual(mixed $value): TraversableContainsEqual
Parameters
-
$value
Returns
TraversableContainsEqual
containsIdentical() ΒΆ public static
containsIdentical(mixed $value): TraversableContainsIdentical
Parameters
-
$value
Returns
TraversableContainsIdentical
containsOnly() ΒΆ public static
containsOnly(string $type): TraversableContainsOnly
Parameters
-
string
$type
Returns
TraversableContainsOnly
containsOnlyInstancesOf() ΒΆ public static
containsOnlyInstancesOf(string $className): TraversableContainsOnly
Parameters
-
string
$className
Returns
TraversableContainsOnly
controllerSpy() ΒΆ public
controllerSpy(Cake\Event\EventInterface $event, Cake\Controller\Controller|null $controller = null): void
Adds additional event spies to the controller/view event manager.
Parameters
-
Cake\Event\EventInterface
$event A dispatcher event.
-
Cake\Controller\Controller|null
$controller optional Controller instance.
Returns
void
cookie() ΒΆ public
cookie(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.
Parameters
-
string
$name The cookie name to use.
-
mixed
$value The value of the cookie.
Returns
void
cookieEncrypted() ΒΆ public
cookieEncrypted(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.
Parameters
-
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.
Returns
void
See Also
createApp() ΒΆ protected
createApp(): Cake\Core\HttpApplicationInterfaceCake\Core\ConsoleApplicationInterface
Create an application instance.
Uses the configuration set in configApplication()
.
Returns
Cake\Core\HttpApplicationInterfaceCake\Core\ConsoleApplicationInterface
createConfiguredMock() ΒΆ protected
createConfiguredMock(string $originalClassName, array $configuration): MockObject
Returns a configured mock object for the specified class.
Parameters
-
string
$originalClassName -
array
$configuration
Returns
MockObject
createMock() ΒΆ protected
createMock(string $originalClassName): MockObject
Returns a mock object for the specified class.
Parameters
-
string
$originalClassName
Returns
MockObject
createPartialMock() ΒΆ protected
createPartialMock(string $originalClassName, string[] $methods): MockObject
Returns a partial mock object for the specified class.
Parameters
-
string
$originalClassName -
string[]
$methods
Returns
MockObject
createResult() ΒΆ protected
createResult(): TestResult
Creates a default TestResult object.
Returns
TestResult
createStub() ΒΆ protected
createStub(string $originalClassName): Stub
Makes configurable stub for the specified class.
Parameters
-
string
$originalClassName
Returns
Stub
createTestProxy() ΒΆ protected
createTestProxy(string $originalClassName, array $constructorArguments = []): MockObject
Returns a test proxy for the specified class.
Parameters
-
string
$originalClassName -
array
$constructorArguments optional
Returns
MockObject
delete() ΒΆ public
delete(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.
Parameters
-
array|string
$url The URL to request.
Returns
void
deprecated() ΒΆ public
deprecated(callable $callable): void
Helper method for check deprecation methods
Parameters
-
callable
$callable callable function that will receive asserts
Returns
void
disableErrorHandlerMiddleware() ΒΆ public
disableErrorHandlerMiddleware(): 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.
Returns
void
enableCsrfToken() ΒΆ public
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.
Parameters
-
string
$cookieName optional The name of the csrf token cookie.
Returns
void
enableRetainFlashMessages() ΒΆ public
enableRetainFlashMessages(): void
Calling this method will re-store flash messages into the test session after being removed by the FlashHelper
Returns
void
enableSecurityToken() ΒΆ public
enableSecurityToken(): 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.
Returns
void
equalToCanonicalizing() ΒΆ public static
equalToCanonicalizing(mixed $value): IsEqualCanonicalizing
Parameters
-
$value
Returns
IsEqualCanonicalizing
equalToIgnoringCase() ΒΆ public static
equalToIgnoringCase(mixed $value): IsEqualIgnoringCase
Parameters
-
$value
Returns
IsEqualIgnoringCase
equalToWithDelta() ΒΆ public static
equalToWithDelta(mixed $value, float $delta): IsEqualWithDelta
Parameters
-
$value
-
float
$delta
Returns
IsEqualWithDelta
exactly() ΒΆ public static
exactly(int $count): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly $count times.
Parameters
-
int
$count
Returns
InvokedCountMatcher
expectDeprecationMessage() ΒΆ public
expectDeprecationMessage(string $message): void
Parameters
-
string
$message
Returns
void
expectDeprecationMessageMatches() ΒΆ public
expectDeprecationMessageMatches(string $regularExpression): void
Parameters
-
string
$regularExpression
Returns
void
expectErrorMessage() ΒΆ public
expectErrorMessage(string $message): void
Parameters
-
string
$message
Returns
void
expectErrorMessageMatches() ΒΆ public
expectErrorMessageMatches(string $regularExpression): void
Parameters
-
string
$regularExpression
Returns
void
expectException() ΒΆ public
expectException(string $exception): void
Parameters
-
string
$exception
Returns
void
expectExceptionCode() ΒΆ public
expectExceptionCode(int|string $code): void
Parameters
-
int|string
$code
Returns
void
expectExceptionMessage() ΒΆ public
expectExceptionMessage(string $message): void
Parameters
-
string
$message
Returns
void
expectExceptionMessageMatches() ΒΆ public
expectExceptionMessageMatches(string $regularExpression): void
Parameters
-
string
$regularExpression
Returns
void
expectExceptionObject() ΒΆ public
expectExceptionObject(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.
Parameters
-
Exception
$exception
Returns
void
expectNoticeMessage() ΒΆ public
expectNoticeMessage(string $message): void
Parameters
-
string
$message
Returns
void
expectNoticeMessageMatches() ΒΆ public
expectNoticeMessageMatches(string $regularExpression): void
Parameters
-
string
$regularExpression
Returns
void
expectOutputRegex() ΒΆ public
expectOutputRegex(string $expectedRegex): void
Parameters
-
string
$expectedRegex
Returns
void
expectOutputString() ΒΆ public
expectOutputString(string $expectedString): void
Parameters
-
string
$expectedString
Returns
void
expectWarningMessage() ΒΆ public
expectWarningMessage(string $message): void
Parameters
-
string
$message
Returns
void
expectWarningMessageMatches() ΒΆ public
expectWarningMessageMatches(string $regularExpression): void
Parameters
-
string
$regularExpression
Returns
void
extractExceptionMessage() ΒΆ protected
extractExceptionMessage(Exception $exception): string
Extract verbose message for existing exception
Parameters
-
Exception
$exception Exception to extract
Returns
string
extractVerboseMessage() ΒΆ protected
extractVerboseMessage(string $message): string
Inspect controller to extract possible causes of the failed assertion
Parameters
-
string
$message Original message to use as a base
Returns
string
fail() ΒΆ public static
fail(string $message = ''): void
Fails a test with the given message.
Parameters
-
string
$message optional
Returns
void
Throws
AssertionFailedError
fetchTable() ΒΆ public
fetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table
Convenience method to get a table instance.
Parameters
-
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.
Returns
Cake\ORM\Table
Throws
Cake\Core\Exception\CakeException
If `$alias` argument and `$defaultTable` property both are `null`.
See Also
get() ΒΆ public
get(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.
Parameters
-
array|string
$url The URL to request.
Returns
void
getDataSetAsString() ΒΆ public
getDataSetAsString(bool $includeData = true): string
Parameters
-
bool
$includeData optional
Returns
string
getExpectedExceptionCode() ΒΆ public
getExpectedExceptionCode(): null|int|string
Returns
null|int|string
getExpectedExceptionMessageRegExp() ΒΆ public
getExpectedExceptionMessageRegExp(): ?string
Returns
?string
getFixtureStrategy() ΒΆ protected
getFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface
Returns fixture strategy used by these tests.
Returns
Cake\TestSuite\Fixture\FixtureStrategyInterface
getFixtures() ΒΆ public
getFixtures(): array<string>
Get the fixtures this test should use.
Returns
array<string>
getMockBuilder() ΒΆ public
getMockBuilder(string $className): MockBuilder
Returns a builder object to create mock objects using a fluent interface.
Parameters
-
string
$className
Returns
MockBuilder
getMockClass() ΒΆ protected
getMockClass(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.
Parameters
-
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
Returns
string
getMockForAbstractClass() ΒΆ protected
getMockForAbstractClass(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).
Parameters
-
string
$originalClassName -
array
$arguments optional -
string
$mockClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional -
array
$mockedMethods optional -
bool
$cloneArguments optional
Returns
MockObject
getMockForModel() ΒΆ public
getMockForModel(string $alias, array<string> $methods = [], array<string, mixed> $options = []): Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject
Mock a model, maintain fixtures and table association
Parameters
-
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.
Returns
Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject
Throws
Cake\ORM\Exception\MissingTableClassException
getMockForTrait() ΒΆ protected
getMockForTrait(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.
Parameters
-
string
$traitName -
array
$arguments optional -
string
$mockClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional -
array
$mockedMethods optional -
bool
$cloneArguments optional
Returns
MockObject
getMockFromWsdl() ΒΆ protected
getMockFromWsdl(string $wsdlFile, string $originalClassName = '', string $mockClassName = '', array $methods = [], bool $callOriginalConstructor = true, array $options = []): MockObject
Returns a mock object based on the given WSDL file.
Parameters
-
string
$wsdlFile -
string
$originalClassName optional -
string
$mockClassName optional -
array
$methods optional -
bool
$callOriginalConstructor optional -
array
$options optional
Returns
MockObject
getName() ΒΆ public
getName(bool $withDataSet = true): string
Parameters
-
bool
$withDataSet optional
Returns
string
Throws
InvalidArgumentException
getNumAssertions() ΒΆ public
getNumAssertions(): int
Returns the number of assertions performed by this test.
Returns
int
getObjectForTrait() ΒΆ protected
getObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true): object
Returns an object for the specified trait.
Parameters
-
string
$traitName -
array
$arguments optional -
string
$traitClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional
Returns
object
getSession() ΒΆ protected
getSession(): Cake\TestSuite\TestSession
Returns
Cake\TestSuite\TestSession
getSize() ΒΆ public
getSize(): int
Returns the size of the test.
Returns
int
Throws
InvalidArgumentException
getTableLocator() ΒΆ public
getTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Returns
Cake\ORM\Locator\LocatorInterface
greaterThan() ΒΆ public static
greaterThan(mixed $value): GreaterThan
Parameters
-
$value
Returns
GreaterThan
greaterThanOrEqual() ΒΆ public static
greaterThanOrEqual(mixed $value): LogicalOr
Parameters
-
$value
Returns
LogicalOr
head() ΒΆ public
head(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.
Parameters
-
array|string
$url The URL to request.
Returns
void
identicalTo() ΒΆ public static
identicalTo(mixed $value): IsIdentical
Parameters
-
$value
Returns
IsIdentical
iniSet() ΒΆ protected
iniSet(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.
Parameters
-
string
$varName -
string
$newValue
Returns
void
Throws
Exception
isInstanceOf() ΒΆ public static
isInstanceOf(string $className): IsInstanceOf
Parameters
-
string
$className
Returns
IsInstanceOf
lessThanOrEqual() ΒΆ public static
lessThanOrEqual(mixed $value): LogicalOr
Parameters
-
$value
Returns
LogicalOr
loadFixtures() ΒΆ public
loadFixtures(): 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.
Returns
void
Throws
RuntimeException
when no fixture manager is available.
See Also
loadPlugins() ΒΆ public
loadPlugins(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.
Parameters
-
array<string, mixed>
$plugins optional List of Plugins to load.
Returns
Cake\Http\BaseApplication
loadRoutes() ΒΆ public
loadRoutes(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.
Parameters
-
array|null
$appArgs optional Constructor parameters for the application class.
Returns
void
logicalNot() ΒΆ public static
logicalNot(Constraint $constraint): LogicalNot
Parameters
-
Constraint
$constraint
Returns
LogicalNot
markTestIncomplete() ΒΆ public static
markTestIncomplete(string $message = ''): void
Mark the test as incomplete.
Parameters
-
string
$message optional
Returns
void
Throws
IncompleteTestError
markTestSkipped() ΒΆ public static
markTestSkipped(string $message = ''): void
Mark the test as skipped.
Parameters
-
string
$message optional
Returns
void
Throws
SkippedTestError
SyntheticSkippedError
matches() ΒΆ public static
matches(string $string): StringMatchesFormatDescription
Parameters
-
string
$string
Returns
StringMatchesFormatDescription
matchesRegularExpression() ΒΆ public static
matchesRegularExpression(string $pattern): RegularExpression
Parameters
-
string
$pattern
Returns
RegularExpression
mockService() ΒΆ public
mockService(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.
Parameters
-
string
$class The class or interface you want to define.
-
Closure
$factory The factory function for mocked services.
Returns
$this
modifyContainer() ΒΆ public
modifyContainer(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.
Parameters
-
Cake\Event\EventInterface
$event The event
-
Cake\Core\ContainerInterface
$container The container to wrap.
Returns
Cake\Core\ContainerInterface|null
never() ΒΆ public static
never(): InvokedCountMatcher
Returns a matcher that matches when the method is never executed.
Returns
InvokedCountMatcher
objectEquals() ΒΆ public static
objectEquals(object $object, string $method = 'equals'): ObjectEquals
Parameters
-
object
$object -
string
$method optional
Returns
ObjectEquals
objectHasAttribute() ΒΆ public static
objectHasAttribute(mixed $attributeName): ObjectHasAttribute
Parameters
-
$attributeName
Returns
ObjectHasAttribute
onConsecutiveCalls() ΒΆ public static
onConsecutiveCalls(mixed ...$args): ConsecutiveCallsStub
Parameters
-
...$args
Returns
ConsecutiveCallsStub
onNotSuccessfulTest() ΒΆ protected
onNotSuccessfulTest(Throwable $t): void
This method is called when a test method did not execute successfully.
Parameters
-
Throwable
$t
Returns
void
Throws
Throwable
once() ΒΆ public static
once(): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly once.
Returns
InvokedCountMatcher
options() ΒΆ public
options(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.
Parameters
-
array|string
$url The URL to request.
Returns
void
patch() ΒΆ public
patch(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.
Parameters
-
array|string
$url The URL to request.
-
array|string
$data optional The data for the request.
Returns
void
post() ΒΆ public
post(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.
Parameters
-
array|string
$url The URL to request.
-
array|string
$data optional The data for the request.
Returns
void
prophesize() ΒΆ protected
prophesize(?string $classOrInterface = null): ObjectProphecy
Parameters
-
?string
$classOrInterface optional
Returns
ObjectProphecy
Throws
ClassNotFoundException
DoubleException
InterfaceNotFoundException
provides() ΒΆ public
provides(): list<ExecutionOrderDependency>
Returns the normalized test name as class::method.
Returns
list<ExecutionOrderDependency>
put() ΒΆ public
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.
Parameters
-
array|string
$url The URL to request.
-
array|string
$data optional The data for the request.
Returns
void
recordDoubledType() ΒΆ protected
recordDoubledType(string $originalClassName): void
Parameters
-
string
$originalClassName
Returns
void
registerComparator() ΒΆ public
registerComparator(Comparator $comparator): void
Parameters
-
Comparator
$comparator
Returns
void
registerMockObject() ΒΆ public
registerMockObject(MockObject $mockObject): void
Parameters
-
MockObject
$mockObject
Returns
void
removeMockService() ΒΆ public
removeMockService(string $class): $this
Remove a mocked service to the container.
Parameters
-
string
$class The class or interface you want to remove.
Returns
$this
removePlugins() ΒΆ public
removePlugins(array<string> $names = []): void
Remove plugins from the global plugin collection.
Useful in test case teardown methods.
Parameters
-
array<string>
$names optional A list of plugins you want to remove.
Returns
void
requires() ΒΆ public
requires(): 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.
Returns
list<ExecutionOrderDependency>
returnArgument() ΒΆ public static
returnArgument(int $argumentIndex): ReturnArgumentStub
Parameters
-
int
$argumentIndex
Returns
ReturnArgumentStub
returnCallback() ΒΆ public static
returnCallback(mixed $callback): ReturnCallbackStub
Parameters
-
$callback
Returns
ReturnCallbackStub
returnSelf() ΒΆ public static
returnSelf(): ReturnSelfStub
Returns the current object.
This method is useful when mocking a fluent interface.
Returns
ReturnSelfStub
returnValue() ΒΆ public static
returnValue(mixed $value): ReturnStub
Parameters
-
$value
Returns
ReturnStub
returnValueMap() ΒΆ public static
returnValueMap(array $valueMap): ReturnValueMapStub
Parameters
-
array
$valueMap
Returns
ReturnValueMapStub
run() ΒΆ public
run(?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.
Parameters
-
?TestResult
$result optional
Returns
TestResult
Throws
SebastianBergmann\CodeCoverage\InvalidArgumentException
CodeCoverageException
InvalidArgumentException
UnintentionallyCoveredCodeException
UtilException
runTest() ΒΆ protected
runTest()
Override to run the test and assert its state.
Throws
SebastianBergmann\ObjectEnumerator\InvalidArgumentException
AssertionFailedError
Exception
ExpectationFailedException
Throwable
session() ΒΆ public
session(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.
Parameters
-
array
$data The session data to use.
Returns
void
setAppNamespace() ΒΆ public static
setAppNamespace(string $appNamespace = 'TestApp'): string|null
Set the app namespace
Parameters
-
string
$appNamespace optional The app namespace, defaults to "TestApp".
Returns
string|null
setBackupGlobals() ΒΆ public
setBackupGlobals(?bool $backupGlobals): void
Parameters
-
?bool
$backupGlobals
Returns
void
setBackupStaticAttributes() ΒΆ public
setBackupStaticAttributes(?bool $backupStaticAttributes): void
Parameters
-
?bool
$backupStaticAttributes
Returns
void
setBeStrictAboutChangesToGlobalState() ΒΆ public
setBeStrictAboutChangesToGlobalState(?bool $beStrictAboutChangesToGlobalState): void
Parameters
-
?bool
$beStrictAboutChangesToGlobalState
Returns
void
setDependencies() ΒΆ public
setDependencies(list<ExecutionOrderDependency> $dependencies): void
Parameters
-
list<ExecutionOrderDependency>
$dependencies
Returns
void
setDependencyInput() ΒΆ public
setDependencyInput(array $dependencyInput): void
Parameters
-
array
$dependencyInput
Returns
void
setInIsolation() ΒΆ public
setInIsolation(bool $inIsolation): void
Parameters
-
bool
$inIsolation
Returns
void
setLocale() ΒΆ protected
setLocale(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.
Parameters
-
...$args
Returns
void
Throws
Exception
setOutputCallback() ΒΆ public
setOutputCallback(callable $callback): void
Parameters
-
callable
$callback
Returns
void
setPreserveGlobalState() ΒΆ public
setPreserveGlobalState(bool $preserveGlobalState): void
Parameters
-
bool
$preserveGlobalState
Returns
void
setRegisterMockObjectsFromTestArgumentsRecursively() ΒΆ public
setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag): void
Parameters
-
bool
$flag
Returns
void
setRunClassInSeparateProcess() ΒΆ public
setRunClassInSeparateProcess(bool $runClassInSeparateProcess): void
Parameters
-
bool
$runClassInSeparateProcess
Returns
void
setRunTestInSeparateProcess() ΒΆ public
setRunTestInSeparateProcess(bool $runTestInSeparateProcess): void
Parameters
-
bool
$runTestInSeparateProcess
Returns
void
setTableLocator() ΒΆ public
setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface
$tableLocator LocatorInterface instance.
Returns
$this
setTestResultObject() ΒΆ public
setTestResultObject(TestResult $result): void
Parameters
-
TestResult
$result
Returns
void
setUnlockedFields() ΒΆ public
setUnlockedFields(array<string> $unlockedFields = []): void
Set list of fields that are excluded from field validation.
Parameters
-
array<string>
$unlockedFields optional List of fields that are excluded from field validation.
Returns
void
setUp() ΒΆ protected
setUp(): 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.
Returns
void
setUpBeforeClass() ΒΆ public static
setUpBeforeClass(): void
This method is called before the first test of this test class is run.
Returns
void
setupFixtures() ΒΆ protected
setupFixtures(): void
Initialized and loads any use fixtures.
Returns
void
skipIf() ΒΆ public
skipIf(bool $shouldSkip, string $message = ''): bool
Overrides SimpleTestCase::skipIf to provide a boolean return value
Parameters
-
bool
$shouldSkip Whether the test should be skipped.
-
string
$message optional The message to display.
Returns
bool
skipUnless() ΒΆ protected
skipUnless(bool $condition, string $message = ''): bool
Compatibility function for skipping.
Parameters
-
bool
$condition Condition to trigger skipping
-
string
$message optional Message for skip
Returns
bool
stringContains() ΒΆ public static
stringContains(string $string, bool $case = true): StringContains
Parameters
-
string
$string -
bool
$case optional
Returns
StringContains
stringEndsWith() ΒΆ public static
stringEndsWith(string $suffix): StringEndsWith
Parameters
-
string
$suffix
Returns
StringEndsWith
stringStartsWith() ΒΆ public static
stringStartsWith(mixed $prefix): StringStartsWith
Parameters
-
$prefix
Returns
StringStartsWith
tearDown() ΒΆ protected
tearDown(): void
teardown any static object changes and restore them.
Returns
void
tearDownAfterClass() ΒΆ public static
tearDownAfterClass(): void
This method is called after the last test of this test class is run.
Returns
void
throwException() ΒΆ public static
throwException(Throwable $exception): ExceptionStub
Parameters
-
Throwable
$exception
Returns
ExceptionStub
toString() ΒΆ public
toString(): string
Returns a string representation of the test case.
Returns
string
Throws
Exception
InvalidArgumentException
useHttpServer() ΒΆ public
useHttpServer(bool $enable): void
No-op method.
Parameters
-
bool
$enable Unused.
Returns
void
viewVariable() ΒΆ public
viewVariable(string $name): mixed
Fetches a view variable by name.
If the view variable does not exist, null will be returned.
Parameters
-
string
$name The view variable to get.
Returns
mixed
withErrorReporting() ΒΆ public
withErrorReporting(int $errorLevel, callable $callable): void
Helper method for tests that needs to use error_reporting()
Parameters
-
int
$errorLevel value of error_reporting() that needs to use
-
callable
$callable callable function that will receive asserts
Returns
void
Property Detail
$_controller ΒΆ protected
The controller used in the last request.
Type
Cake\Controller\Controller|null
$_csrfToken ΒΆ protected
Boolean flag for whether the request should have a CSRF token added.
Type
bool
$_response ΒΆ protected
The response for the most recent request.
Type
Psr\Http\Message\ResponseInterface|null
$_retainFlashMessages ΒΆ protected
Boolean flag for whether the request should re-store flash messages
Type
bool
$_securityToken ΒΆ protected
Boolean flag for whether the request should have a SecurityComponent token added.
Type
bool
$_unlockedFields ΒΆ protected
List of fields that are excluded from field validation.
Type
array<string>
$autoFixtures ΒΆ public deprecated
By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
Type
bool
$dropTables ΒΆ public deprecated
Control table create/drops on each test method.
If true, tables will still be dropped at the end of each test runner execution.
Type
bool
$fixtureManager ΒΆ public static
The class responsible for managing the creation, loading and removing of fixtures
Type
Cake\TestSuite\Fixture\FixtureManager|null