Class TestCase
Cake TestCase class
Property Summary
-
$_configure protected
arrayConfigure values to restore at end of test.
-
$_tableLocator protected
Cake\ORM\Locator\LocatorInterface|nullTable locator instance
-
$appPluginsToLoad protected
arrayPlugins to be loaded after app instance is created ContainerStubTrait::creatApp()
-
$defaultTable protected
string|nullThis object's default table alias.
-
$fixtureStrategy protected
Cake\TestSuite\Fixture\FixtureStrategyInterface|null -
$fixtures protected
array<string>Fixtures used by this test case.
Method Summary
-
__construct() public
-
_assertAttributes() protected
Check the attributes as part of an assertTags() check.
-
_getTableClassName() protected
Gets the class name for the table.
-
_normalizePath() protected
Normalize a path for comparison.
-
addFixture() protected
Adds a fixture to this test case.
-
addToAssertionCount() public
-
any() protected
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.
-
assertArrayIsEqualToArrayIgnoringListOfKeys() public static
Asserts that two arrays are equal while ignoring a list of keys.
-
assertArrayIsEqualToArrayOnlyConsideringListOfKeys() public static
Asserts that two arrays are equal while only considering a list of keys.
-
assertArrayIsIdenticalToArrayIgnoringListOfKeys() public static
Asserts that two arrays are equal while ignoring a list of keys.
-
assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys() public static
Asserts that two arrays are identical while only considering a list of keys.
-
assertArrayNotHasKey() public static
Asserts that an array does not have a specified key.
-
assertContains() public static
Asserts that a haystack contains a needle.
-
assertContainsEquals() public static
-
assertContainsNotOnlyArray() public static
Asserts that a haystack does not contain only values of type array.
-
assertContainsNotOnlyBool() public static
Asserts that a haystack does not contain only values of type bool.
-
assertContainsNotOnlyCallable() public static
Asserts that a haystack does not contain only values of type callable.
-
assertContainsNotOnlyClosedResource() public static
Asserts that a haystack does not contain only values of type closed resource.
-
assertContainsNotOnlyFloat() public static
Asserts that a haystack does not contain only values of type float.
-
assertContainsNotOnlyInstancesOf() public static
Asserts that a haystack does not contain only instances of a specified interface or class name.
-
assertContainsNotOnlyInt() public static
Asserts that a haystack does not contain only values of type int.
-
assertContainsNotOnlyIterable() public static
Asserts that a haystack does not contain only values of type iterable.
-
assertContainsNotOnlyNull() public static
Asserts that a haystack does not contain only values of type null.
-
assertContainsNotOnlyNumeric() public static
Asserts that a haystack does not contain only values of type numeric.
-
assertContainsNotOnlyObject() public static
Asserts that a haystack does not contain only values of type object.
-
assertContainsNotOnlyResource() public static
Asserts that a haystack does not contain only values of type resource.
-
assertContainsNotOnlyScalar() public static
Asserts that a haystack does not contain only values of type scalar.
-
assertContainsNotOnlyString() public static
Asserts that a haystack does not contain only values of type string.
-
assertContainsOnly() public static deprecated
Asserts that a haystack contains only values of a given type.
-
assertContainsOnlyArray() public static
Asserts that a haystack contains only values of type array.
-
assertContainsOnlyBool() public static
Asserts that a haystack contains only values of type bool.
-
assertContainsOnlyCallable() public static
Asserts that a haystack contains only values of type callable.
-
assertContainsOnlyClosedResource() public static
Asserts that a haystack contains only values of type closed resource.
-
assertContainsOnlyFloat() public static
Asserts that a haystack contains only values of type float.
-
assertContainsOnlyInstancesOf() public static
Asserts that a haystack contains only instances of a specified interface or class name.
-
assertContainsOnlyInt() public static
Asserts that a haystack contains only values of type int.
-
assertContainsOnlyIterable() public static
Asserts that a haystack contains only values of type iterable.
-
assertContainsOnlyNull() public static
Asserts that a haystack contains only values of type null.
-
assertContainsOnlyNumeric() public static
Asserts that a haystack contains only values of type numeric.
-
assertContainsOnlyObject() public static
Asserts that a haystack contains only values of type object.
-
assertContainsOnlyResource() public static
Asserts that a haystack contains only values of type resource.
-
assertContainsOnlyScalar() public static
Asserts that a haystack contains only values of type scalar.
-
assertContainsOnlyString() public static
Asserts that a haystack contains only values of type string.
-
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.
-
assertDoesNotMatchRegularExpression() public static
Asserts that a string does not match a given regular expression.
-
assertEmpty() public static
Asserts that a variable is empty.
-
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.
-
assertFileMatchesFormat() public static
Asserts that a string matches a given format string.
-
assertFileMatchesFormatFile() public static
Asserts that a string matches a given format string.
-
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).
-
assertFinite() public static
Asserts that a variable is finite.
-
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.
-
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.
-
assertIsList() public static
-
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.
-
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.
-
assertNotContains() public static
Asserts that a haystack does not contain a needle.
-
assertNotContainsEquals() public static
-
assertNotContainsOnly() public static deprecated
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.
-
assertNotNull() public static
Asserts that a variable is not null.
-
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
CountableorTraversableobjects) 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
-
assertObjectHasProperty() public static
Asserts that an object has a specified property.
-
assertObjectNotEquals() public static
-
assertObjectNotHasProperty() public static
Asserts that an object does not have a specified property.
-
assertPathEquals() protected static
Compatibility function to test paths.
-
assertPostConditions() protected
This method is called between test and tearDown().
-
assertPreConditions() protected
Performs assertions shared by all tests of a test case.
-
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 -
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
CountableorTraversableobjects) is the same. -
assertStringContainsString() public static
-
assertStringContainsStringIgnoringCase() public static
-
assertStringContainsStringIgnoringLineEndings() 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).
-
assertStringEqualsStringIgnoringLineEndings() public static
Asserts that two strings are equal except for line endings.
-
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).
-
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.
-
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.
-
atLeast() protected
Returns a matcher that matches when the method is executed at least N times.
-
atLeastOnce() protected
Returns a matcher that matches when the method is executed at least once.
-
atMost() protected
Returns a matcher that matches when the method is executed at most N times.
-
callback() public static
-
captureError() public
Capture errors from $callable so that you can do assertions on the error.
-
clearPlugins() public
Clear all plugins from the global plugin collection.
-
containsEqual() public static
-
containsIdentical() public static
-
containsOnly() public static deprecated
-
containsOnlyArray() public static
-
containsOnlyBool() public static
-
containsOnlyCallable() public static
-
containsOnlyClosedResource() public static
-
containsOnlyFloat() public static
-
containsOnlyInstancesOf() public static
-
containsOnlyInt() public static
-
containsOnlyIterable() public static
-
containsOnlyNull() public static
-
containsOnlyNumeric() public static
-
containsOnlyObject() public static
-
containsOnlyResource() public static
-
containsOnlyScalar() public static
-
containsOnlyString() public static
-
count() public
-
countOf() public static
-
createConfiguredMock() protected
Creates (and configures) a mock object for the specified interface or class.
-
createConfiguredStub() protected static
Creates (and configures) a test stub for the specified interface or class.
-
createMock() protected
Creates a mock object for the specified interface or class.
-
createMockForIntersectionOfInterfaces() protected
-
createPartialMock() protected
Creates a partial mock object for the specified interface or class.
-
createStub() protected static
Creates a test stub for the specified interface or class.
-
createStubForIntersectionOfInterfaces() protected static
-
dataName() public
-
dataSetAsString() public
-
dataSetAsStringWithData() public
-
dependencyInput() public
-
deprecated() public
Helper method for check deprecation methods
-
directoryExists() public static
-
doesNotPerformAssertions() public
-
equalTo() public static
-
equalToCanonicalizing() public static
-
equalToIgnoringCase() public static
-
equalToWithDelta() public static
-
exactly() protected
Returns a matcher that matches when the method is executed exactly $count times.
-
expectDeprecationMessageMatches() public
-
expectErrorHandlerMessageMatches() protected
-
expectErrorLog() protected
-
expectErrorMessageMatches() public
-
expectException() protected
-
expectExceptionCode() protected
-
expectExceptionMessage() protected
-
expectExceptionMessageMatches() protected
-
expectExceptionObject() protected
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() protected
-
expectNoticeMessageMatches() public
-
expectOutputRegex() protected
-
expectOutputString() protected
-
expectUserDeprecationMessage() protected
-
expectUserDeprecationMessageMatches() protected
-
expectWarningMessageMatches() public
-
expectsOutput() public
-
fail() public static
Fails a test with the given message.
-
fetchTable() public
Convenience method to get a table instance.
-
fileExists() public static
-
getActualOutputForAssertion() protected
-
getCount() public static
Return the current assertion count.
-
getFixtureStrategy() protected
Returns fixture strategy used by these tests.
-
getFixtures() public
Get the fixtures this test should use.
-
getMockBuilder() protected
Returns a builder object to create mock objects using a fluent interface.
-
getMockForModel() public
Mock a model, maintain fixtures and table association
-
getTableLocator() public
Gets the table locator.
-
greaterThan() public static
-
greaterThanOrEqual() public static
-
groups() public
-
hasDependencyInput() public
-
hasUnexpectedOutput() public
-
identicalTo() public static
-
isArray() public static
-
isBool() public static
-
isCallable() public static
-
isClosedResource() public static
-
isEmpty() public static
-
isFalse() public static
-
isFinite() public static
-
isFloat() public static
-
isInfinite() public static
-
isInstanceOf() public static
-
isInt() public static
-
isIterable() public static
-
isJson() public static
-
isList() public static
-
isNan() public static
-
isNull() public static
-
isNumeric() public static
-
isObject() public static
-
isReadable() public static
-
isResource() public static
-
isScalar() public static
-
isString() public static
-
isTrue() public static
-
isType() public static deprecated
-
isWritable() public static
-
lessThan() public static
-
lessThanOrEqual() public static
-
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
-
markTestIncomplete() public static
Mark the test as incomplete.
-
markTestSkipped() public static
Mark the test as skipped.
-
matches() public static
-
matchesRegularExpression() public static
-
name() public
-
nameWithDataSet() public
-
never() protected
Returns a matcher that matches when the method is never executed.
-
numberOfAssertionsPerformed() public
-
objectEquals() public static
-
onNotSuccessfulTest() protected
This method is called when a test method did not execute successfully.
-
once() protected
Returns a matcher that matches when the method is executed exactly once.
-
output() public
-
provideAdditionalInformation() protected
-
providedData() public
-
provides() public
-
registerComparator() protected
-
registerFailureType() protected
-
registerMockObject() public
-
removePlugins() public
Remove plugins from the global plugin collection.
-
requires() public
-
resetCount() public static
Reset the assertion counter.
-
result() public
-
run() public
-
runBare() public
-
setAppNamespace() public static
Set the app namespace
-
setBackupGlobals() public
-
setBackupGlobalsExcludeList() public
-
setBackupStaticProperties() public
-
setBackupStaticPropertiesExcludeList() public
-
setData() public
-
setDependencies() public
-
setDependencyInput() public
-
setGroups() public
-
setInIsolation() public
-
setPreserveGlobalState() public
-
setResult() public
-
setRunClassInSeparateProcess() public
-
setRunTestInSeparateProcess() public
-
setTableLocator() public
Sets the table locator.
-
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.
-
size() public
-
skipIf() public
Overrides SimpleTestCase::skipIf to provide a boolean return value
-
skipUnless() protected
Compatibility function for skipping.
-
sortId() public
-
status() public
-
stringContains() public static
-
stringEndsWith() public static
-
stringEqualsStringIgnoringLineEndings() 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() protected
-
toString() public
Returns a string representation of the test case.
-
transformException() protected
-
usesDataProvider() public
-
valueObjectForEvents() public
-
wasPrepared() public
-
withConsecutive() public static
-
withErrorReporting() public
Helper method for tests that needs to use error_reporting()
Method Detail
_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_getTableClassName() ¶ protected
_getTableClassName(string $alias, array<string, mixed> $options): class-string<Cake\ORM\Table>
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
class-string<Cake\ORM\Table>Throws
Cake\ORM\Exception\MissingTableClassException_normalizePath() ¶ protected
_normalizePath(string $path): string
Normalize a path for comparison.
Parameters
-
string$path Path separated by "/" slash.
Returns
stringNormalized path separated by DIRECTORY_SEPARATOR.
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
$thisaddToAssertionCount() ¶ public
addToAssertionCount(int $count): void
Parameters
-
int$count
Returns
voidany() ¶ protected
any(): AnyInvokedCountMatcher
Returns a matcher that matches when the method is executed zero or more times.
Returns
AnyInvokedCountMatcherarrayHasKey() ¶ public static
arrayHasKey(mixed $key): ArrayHasKey
Parameters
-
mixed$key
Returns
ArrayHasKeyassertArrayHasKey() ¶ public static
assertArrayHasKey(mixed $key, array<mixed>|ArrayAccess<array-key, mixed> $array, string $message = ''): void
Asserts that an array has a specified key.
Parameters
-
mixed$key -
array<mixed>|ArrayAccess<array-key, mixed>$array -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertArrayIsEqualToArrayIgnoringListOfKeys() ¶ public static
assertArrayIsEqualToArrayIgnoringListOfKeys(array<mixed> $expected, array<mixed> $actual, non-empty-list<array-key> $keysToBeIgnored, string $message = ''): void
Asserts that two arrays are equal while ignoring a list of keys.
Parameters
-
array<mixed>$expected -
array<mixed>$actual -
non-empty-list<array-key>$keysToBeIgnored -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertArrayIsEqualToArrayOnlyConsideringListOfKeys() ¶ public static
assertArrayIsEqualToArrayOnlyConsideringListOfKeys(array<mixed> $expected, array<mixed> $actual, non-empty-list<array-key> $keysToBeConsidered, string $message = ''): void
Asserts that two arrays are equal while only considering a list of keys.
Parameters
-
array<mixed>$expected -
array<mixed>$actual -
non-empty-list<array-key>$keysToBeConsidered -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertArrayIsIdenticalToArrayIgnoringListOfKeys() ¶ public static
assertArrayIsIdenticalToArrayIgnoringListOfKeys(array<mixed> $expected, array<mixed> $actual, non-empty-list<array-key> $keysToBeIgnored, string $message = ''): void
Asserts that two arrays are equal while ignoring a list of keys.
Parameters
-
array<mixed>$expected -
array<mixed>$actual -
non-empty-list<array-key>$keysToBeIgnored -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertArrayIsIdenticalToArrayOnlyConsideringListOfKeys() ¶ public static
assertArrayIsIdenticalToArrayOnlyConsideringListOfKeys(array<mixed> $expected, array<mixed> $actual, non-empty-list<array-key> $keysToBeConsidered, string $message = ''): void
Asserts that two arrays are identical while only considering a list of keys.
Parameters
-
array<mixed>$expected -
array<mixed>$actual -
non-empty-list<array-key>$keysToBeConsidered -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertArrayNotHasKey() ¶ public static
assertArrayNotHasKey(mixed $key, array<mixed>|ArrayAccess<array-key, mixed> $array, string $message = ''): void
Asserts that an array does not have a specified key.
Parameters
-
mixed$key -
array<mixed>|ArrayAccess<array-key, mixed>$array -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertContains() ¶ public static
assertContains(mixed $needle, iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains a needle.
Parameters
-
mixed$needle -
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertContainsEquals() ¶ public static
assertContainsEquals(mixed $needle, iterable<mixed> $haystack, string $message = ''): void
Parameters
-
mixed$needle -
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyArray() ¶ public static
assertContainsNotOnlyArray(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type array.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyBool() ¶ public static
assertContainsNotOnlyBool(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type bool.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyCallable() ¶ public static
assertContainsNotOnlyCallable(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type callable.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyClosedResource() ¶ public static
assertContainsNotOnlyClosedResource(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type closed resource.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyFloat() ¶ public static
assertContainsNotOnlyFloat(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type float.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyInstancesOf() ¶ public static
assertContainsNotOnlyInstancesOf(class-string $className, iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only instances of a specified interface or class name.
Parameters
-
class-string$className -
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertContainsNotOnlyInt() ¶ public static
assertContainsNotOnlyInt(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type int.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyIterable() ¶ public static
assertContainsNotOnlyIterable(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type iterable.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyNull() ¶ public static
assertContainsNotOnlyNull(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type null.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyNumeric() ¶ public static
assertContainsNotOnlyNumeric(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type numeric.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyObject() ¶ public static
assertContainsNotOnlyObject(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type object.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyResource() ¶ public static
assertContainsNotOnlyResource(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type resource.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyScalar() ¶ public static
assertContainsNotOnlyScalar(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type scalar.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsNotOnlyString() ¶ public static
assertContainsNotOnlyString(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain only values of type string.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnly() ¶ public static
assertContainsOnly(array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string $type, iterable<mixed> $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack contains only values of a given type.
Parameters
-
array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string$type -
iterable<mixed>$haystack -
?bool$isNativeType optional -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertContainsOnlyArray() ¶ public static
assertContainsOnlyArray(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type array.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyBool() ¶ public static
assertContainsOnlyBool(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type bool.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyCallable() ¶ public static
assertContainsOnlyCallable(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type callable.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyClosedResource() ¶ public static
assertContainsOnlyClosedResource(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type closed resource.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyFloat() ¶ public static
assertContainsOnlyFloat(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type float.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyInstancesOf() ¶ public static
assertContainsOnlyInstancesOf(class-string<T> $className, iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only instances of a specified interface or class name.
Templates
T
Parameters
-
class-string<T>$className -
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertContainsOnlyInt() ¶ public static
assertContainsOnlyInt(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type int.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyIterable() ¶ public static
assertContainsOnlyIterable(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type iterable.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyNull() ¶ public static
assertContainsOnlyNull(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type null.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyNumeric() ¶ public static
assertContainsOnlyNumeric(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type numeric.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyObject() ¶ public static
assertContainsOnlyObject(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type object.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyResource() ¶ public static
assertContainsOnlyResource(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type resource.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyScalar() ¶ public static
assertContainsOnlyScalar(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type scalar.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertContainsOnlyString() ¶ public static
assertContainsOnlyString(iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack contains only values of type string.
Parameters
-
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertCount() ¶ public static
assertCount(int $expectedCount, Countable|iterable<mixed> $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
Parameters
-
int$expectedCount -
Countable|iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionGeneratorNotSupportedExceptionassertDirectoryDoesNotExist() ¶ public static
assertDirectoryDoesNotExist(string $directory, string $message = ''): void
Asserts that a directory does not exist.
Parameters
-
string$directory -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertDirectoryExists() ¶ public static
assertDirectoryExists(string $directory, string $message = ''): void
Asserts that a directory exists.
Parameters
-
string$directory -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertDirectoryIsNotReadable() ¶ public static
assertDirectoryIsNotReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
Parameters
-
string$directory -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertDirectoryIsNotWritable() ¶ public static
assertDirectoryIsNotWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
Parameters
-
string$directory -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertDirectoryIsReadable() ¶ public static
assertDirectoryIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is readable.
Parameters
-
string$directory -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertDirectoryIsWritable() ¶ public static
assertDirectoryIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is writable.
Parameters
-
string$directory -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertDoesNotMatchRegularExpression() ¶ public static
assertDoesNotMatchRegularExpression(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
voidThrows
ExpectationFailedExceptionassertEmpty() ¶ public static
assertEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is empty.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionGeneratorNotSupportedExceptionassertEquals() ¶ public static
assertEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal.
Parameters
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertEqualsCanonicalizing() ¶ public static
assertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (canonicalizing).
Parameters
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertEqualsIgnoringCase() ¶ public static
assertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (ignoring case).
Parameters
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertEqualsSql() ¶ 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
voidassertEqualsWithDelta() ¶ public static
assertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are equal (with delta).
Parameters
-
mixed$expected -
mixed$actual -
float$delta -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertEventFired() ¶ 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
voidassertEventFiredWith() ¶ 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
voidassertFalse() ¶ public static
assertFalse(mixed $condition, string $message = ''): void
Asserts that a condition is false.
Parameters
-
mixed$condition -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileDoesNotExist() ¶ public static
assertFileDoesNotExist(string $filename, string $message = ''): void
Asserts that a file does not exist.
Parameters
-
string$filename -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileEquals() ¶ 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
voidThrows
ExpectationFailedExceptionassertFileEqualsCanonicalizing() ¶ 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
voidThrows
ExpectationFailedExceptionassertFileEqualsIgnoringCase() ¶ 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
voidThrows
ExpectationFailedExceptionassertFileExists() ¶ public static
assertFileExists(string $filename, string $message = ''): void
Asserts that a file exists.
Parameters
-
string$filename -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileIsNotReadable() ¶ public static
assertFileIsNotReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
Parameters
-
string$file -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileIsNotWritable() ¶ public static
assertFileIsNotWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
Parameters
-
string$file -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileIsReadable() ¶ public static
assertFileIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is readable.
Parameters
-
string$file -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileIsWritable() ¶ public static
assertFileIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is writable.
Parameters
-
string$file -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileMatchesFormat() ¶ public static
assertFileMatchesFormat(string $format, string $actualFile, string $message = ''): void
Asserts that a string matches a given format string.
Parameters
-
string$format -
string$actualFile -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileMatchesFormatFile() ¶ public static
assertFileMatchesFormatFile(string $formatFile, string $actualFile, string $message = ''): void
Asserts that a string matches a given format string.
Parameters
-
string$formatFile -
string$actualFile -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertFileNotEquals() ¶ 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
voidThrows
ExpectationFailedExceptionassertFileNotEqualsCanonicalizing() ¶ 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
voidThrows
ExpectationFailedExceptionassertFileNotEqualsIgnoringCase() ¶ 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
voidThrows
ExpectationFailedExceptionassertFinite() ¶ public static
assertFinite(mixed $actual, string $message = ''): void
Asserts that a variable is finite.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertGreaterThan() ¶ public static
assertGreaterThan(mixed $minimum, mixed $actual, string $message = ''): void
Asserts that a value is greater than another value.
Parameters
-
mixed$minimum -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertGreaterThanOrEqual() ¶ public static
assertGreaterThanOrEqual(mixed $minimum, mixed $actual, string $message = ''): void
Asserts that a value is greater than or equal to another value.
Parameters
-
mixed$minimum -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertHtml() ¶ 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
boolassertInfinite() ¶ public static
assertInfinite(mixed $actual, string $message = ''): void
Asserts that a variable is infinite.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertInstanceOf() ¶ public static
assertInstanceOf(class-string<ExpectedType> $expected, mixed $actual, string $message = ''): void
Asserts that a variable is of a given type.
Templates
ExpectedType
of object Parameters
-
class-string<ExpectedType>$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionUnknownClassOrInterfaceExceptionassertIsArray() ¶ public static
assertIsArray(mixed $actual, string $message = ''): void
Asserts that a variable is of type array.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsBool() ¶ public static
assertIsBool(mixed $actual, string $message = ''): void
Asserts that a variable is of type bool.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsCallable() ¶ public static
assertIsCallable(mixed $actual, string $message = ''): void
Asserts that a variable is of type callable.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsClosedResource() ¶ public static
assertIsClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource and is closed.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsFloat() ¶ public static
assertIsFloat(mixed $actual, string $message = ''): void
Asserts that a variable is of type float.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsInt() ¶ public static
assertIsInt(mixed $actual, string $message = ''): void
Asserts that a variable is of type int.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsIterable() ¶ public static
assertIsIterable(mixed $actual, string $message = ''): void
Asserts that a variable is of type iterable.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsList() ¶ public static
assertIsList(mixed $array, string $message = ''): void
Parameters
-
mixed$array -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertIsNotArray() ¶ public static
assertIsNotArray(mixed $actual, string $message = ''): void
Asserts that a variable is not of type array.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotBool() ¶ public static
assertIsNotBool(mixed $actual, string $message = ''): void
Asserts that a variable is not of type bool.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotCallable() ¶ public static
assertIsNotCallable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type callable.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotClosedResource() ¶ public static
assertIsNotClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotFloat() ¶ public static
assertIsNotFloat(mixed $actual, string $message = ''): void
Asserts that a variable is not of type float.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotInt() ¶ public static
assertIsNotInt(mixed $actual, string $message = ''): void
Asserts that a variable is not of type int.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotIterable() ¶ public static
assertIsNotIterable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type iterable.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotNumeric() ¶ public static
assertIsNotNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is not of type numeric.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotObject() ¶ public static
assertIsNotObject(mixed $actual, string $message = ''): void
Asserts that a variable is not of type object.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotReadable() ¶ 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
voidThrows
ExpectationFailedExceptionassertIsNotResource() ¶ public static
assertIsNotResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotScalar() ¶ public static
assertIsNotScalar(mixed $actual, string $message = ''): void
Asserts that a variable is not of type scalar.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotString() ¶ public static
assertIsNotString(mixed $actual, string $message = ''): void
Asserts that a variable is not of type string.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsNotWritable() ¶ 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
voidThrows
ExpectationFailedExceptionassertIsNumeric() ¶ public static
assertIsNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is of type numeric.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsObject() ¶ public static
assertIsObject(mixed $actual, string $message = ''): void
Asserts that a variable is of type object.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsReadable() ¶ public static
assertIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir is readable.
Parameters
-
string$filename -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertIsResource() ¶ public static
assertIsResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsScalar() ¶ public static
assertIsScalar(mixed $actual, string $message = ''): void
Asserts that a variable is of type scalar.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsString() ¶ public static
assertIsString(mixed $actual, string $message = ''): void
Asserts that a variable is of type string.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertIsWritable() ¶ public static
assertIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is writable.
Parameters
-
string$filename -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertJson() ¶ public static
assertJson(string $actual, string $message = ''): void
Asserts that a string is a valid JSON string.
Parameters
-
string$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertJsonFileEqualsJsonFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertJsonFileNotEqualsJsonFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertJsonStringEqualsJsonFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertJsonStringEqualsJsonString() ¶ 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
voidThrows
ExpectationFailedExceptionassertJsonStringNotEqualsJsonFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertJsonStringNotEqualsJsonString() ¶ 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
voidThrows
ExpectationFailedExceptionassertLessThan() ¶ public static
assertLessThan(mixed $maximum, mixed $actual, string $message = ''): void
Asserts that a value is smaller than another value.
Parameters
-
mixed$maximum -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertLessThanOrEqual() ¶ public static
assertLessThanOrEqual(mixed $maximum, mixed $actual, string $message = ''): void
Asserts that a value is smaller than or equal to another value.
Parameters
-
mixed$maximum -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertMatchesRegularExpression() ¶ public static
assertMatchesRegularExpression(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
voidThrows
ExpectationFailedExceptionassertNan() ¶ public static
assertNan(mixed $actual, string $message = ''): void
Asserts that a variable is nan.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotContains() ¶ public static
assertNotContains(mixed $needle, iterable<mixed> $haystack, string $message = ''): void
Asserts that a haystack does not contain a needle.
Parameters
-
mixed$needle -
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertNotContainsEquals() ¶ public static
assertNotContainsEquals(mixed $needle, iterable<mixed> $haystack, string $message = ''): void
Parameters
-
mixed$needle -
iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotContainsOnly() ¶ public static
assertNotContainsOnly(array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string $type, iterable<mixed> $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack does not contain only values of a given type.
Parameters
-
array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string$type -
iterable<mixed>$haystack -
?bool$isNativeType optional -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertNotCount() ¶ public static
assertNotCount(int $expectedCount, Countable|iterable<mixed> $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
Parameters
-
int$expectedCount -
Countable|iterable<mixed>$haystack -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionGeneratorNotSupportedExceptionassertNotEmpty() ¶ public static
assertNotEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is not empty.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionGeneratorNotSupportedExceptionassertNotEquals() ¶ public static
assertNotEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal.
Parameters
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotEqualsCanonicalizing() ¶ public static
assertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (canonicalizing).
Parameters
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotEqualsIgnoringCase() ¶ public static
assertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (ignoring case).
Parameters
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotEqualsWithDelta() ¶ public static
assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are not equal (with delta).
Parameters
-
mixed$expected -
mixed$actual -
float$delta -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotFalse() ¶ public static
assertNotFalse(mixed $condition, string $message = ''): void
Asserts that a condition is not false.
Parameters
-
mixed$condition -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotInstanceOf() ¶ public static
assertNotInstanceOf(class-string<ExpectedType> $expected, mixed $actual, string $message = ''): void
Asserts that a variable is not of a given type.
Templates
ExpectedType
of object Parameters
-
class-string<ExpectedType>$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionassertNotNull() ¶ public static
assertNotNull(mixed $actual, string $message = ''): void
Asserts that a variable is not null.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotSame() ¶ 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
-
mixed$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotSameSize() ¶ public static
assertNotSameSize(Countable|iterable<mixed> $expected, Countable|iterable<mixed> $actual, string $message = ''): void
Assert that the size of two arrays (or Countable or Traversable objects)
is not the same.
Parameters
-
Countable|iterable<mixed>$expected -
Countable|iterable<mixed>$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionGeneratorNotSupportedExceptionassertNotTrue() ¶ public static
assertNotTrue(mixed $condition, string $message = ''): void
Asserts that a condition is not true.
Parameters
-
mixed$condition -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertNotWithinRange() ¶ 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
voidassertNull() ¶ public static
assertNull(mixed $actual, string $message = ''): void
Asserts that a variable is null.
Parameters
-
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertObjectEquals() ¶ 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
voidThrows
ExpectationFailedExceptionassertObjectHasProperty() ¶ 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
voidThrows
ExpectationFailedExceptionassertObjectNotEquals() ¶ public static
assertObjectNotEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void
Parameters
-
object$expected -
object$actual -
string$method optional -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertObjectNotHasProperty() ¶ 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
voidThrows
ExpectationFailedExceptionassertPathEquals() ¶ 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
voidassertPostConditions() ¶ protected
assertPostConditions(): void
This method is called between test and tearDown().
Gets the count of expectations on the mocks produced through Mockery.
Returns
voidassertPreConditions() ¶ protected
assertPreConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between setUp() and test.
Returns
voidassertRegExpSql() ¶ 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
voidassertSame() ¶ public static
assertSame(ExpectedType $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.
Templates
ExpectedType
Parameters
-
ExpectedType$expected -
mixed$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertSameSize() ¶ public static
assertSameSize(Countable|iterable<mixed> $expected, Countable|iterable<mixed> $actual, string $message = ''): void
Assert that the size of two arrays (or Countable or Traversable objects)
is the same.
Parameters
-
Countable|iterable<mixed>$expected -
Countable|iterable<mixed>$actual -
string$message optional
Returns
voidThrows
ExceptionExpectationFailedExceptionGeneratorNotSupportedExceptionassertStringContainsString() ¶ public static
assertStringContainsString(string $needle, string $haystack, string $message = ''): void
Parameters
-
string$needle -
string$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertStringContainsStringIgnoringCase() ¶ public static
assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
Parameters
-
string$needle -
string$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertStringContainsStringIgnoringLineEndings() ¶ public static
assertStringContainsStringIgnoringLineEndings(string $needle, string $haystack, string $message = ''): void
Parameters
-
string$needle -
string$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertStringEndsNotWith() ¶ public static
assertStringEndsNotWith(non-empty-string $suffix, string $string, string $message = ''): void
Asserts that a string ends not with a given suffix.
Parameters
-
non-empty-string$suffix -
string$string -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionInvalidArgumentExceptionassertStringEndsWith() ¶ public static
assertStringEndsWith(non-empty-string $suffix, string $string, string $message = ''): void
Asserts that a string ends with a given suffix.
Parameters
-
non-empty-string$suffix -
string$string -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionInvalidArgumentExceptionassertStringEqualsFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringEqualsFileCanonicalizing() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringEqualsFileIgnoringCase() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringEqualsStringIgnoringLineEndings() ¶ public static
assertStringEqualsStringIgnoringLineEndings(string $expected, string $actual, string $message = ''): void
Asserts that two strings are equal except for line endings.
Parameters
-
string$expected -
string$actual -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertStringMatchesFormat() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringMatchesFormatFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringNotContainsString() ¶ public static
assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
Parameters
-
string$needle -
string$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertStringNotContainsStringIgnoringCase() ¶ public static
assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
Parameters
-
string$needle -
string$haystack -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertStringNotEqualsFile() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringNotEqualsFileCanonicalizing() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringNotEqualsFileIgnoringCase() ¶ 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
voidThrows
ExpectationFailedExceptionassertStringStartsNotWith() ¶ public static
assertStringStartsNotWith(non-empty-string $prefix, string $string, string $message = ''): void
Asserts that a string starts not with a given prefix.
Parameters
-
non-empty-string$prefix -
string$string -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionInvalidArgumentExceptionassertStringStartsWith() ¶ public static
assertStringStartsWith(non-empty-string $prefix, string $string, string $message = ''): void
Asserts that a string starts with a given prefix.
Parameters
-
non-empty-string$prefix -
string$string -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionInvalidArgumentExceptionassertTextContains() ¶ 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
voidassertTextEndsNotWith() ¶ 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
voidassertTextEndsWith() ¶ 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
voidassertTextEquals() ¶ 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
voidassertTextNotContains() ¶ 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
voidassertTextNotEquals() ¶ 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
voidassertTextStartsNotWith() ¶ 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
voidassertTextStartsWith() ¶ 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
voidassertThat() ¶ public static
assertThat(mixed $value, Constraint $constraint, string $message = ''): void
Evaluates a PHPUnit\Framework\Constraint matcher object.
Parameters
-
mixed$value -
Constraint$constraint -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertTrue() ¶ public static
assertTrue(mixed $condition, string $message = ''): void
Asserts that a condition is true.
Parameters
-
mixed$condition -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionassertWithinRange() ¶ 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
voidassertXmlFileEqualsXmlFile() ¶ 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
voidThrows
ExceptionExpectationFailedExceptionXmlExceptionassertXmlFileNotEqualsXmlFile() ¶ 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
voidThrows
PHPUnit\Util\ExceptionExpectationFailedExceptionassertXmlStringEqualsXmlFile() ¶ public static
assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
Parameters
-
string$expectedFile -
string$actualXml -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionXmlExceptionassertXmlStringEqualsXmlString() ¶ public static
assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
Parameters
-
string$expectedXml -
string$actualXml -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionXmlExceptionassertXmlStringNotEqualsXmlFile() ¶ public static
assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
Parameters
-
string$expectedFile -
string$actualXml -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionXmlExceptionassertXmlStringNotEqualsXmlString() ¶ public static
assertXmlStringNotEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
Parameters
-
string$expectedXml -
string$actualXml -
string$message optional
Returns
voidThrows
ExpectationFailedExceptionXmlExceptionatLeast() ¶ protected
atLeast(int $requiredInvocations): InvokedAtLeastCountMatcher
Returns a matcher that matches when the method is executed at least N times.
Parameters
-
int$requiredInvocations
Returns
InvokedAtLeastCountMatcheratLeastOnce() ¶ protected
atLeastOnce(): InvokedAtLeastOnceMatcher
Returns a matcher that matches when the method is executed at least once.
Returns
InvokedAtLeastOnceMatcheratMost() ¶ protected
atMost(int $allowedInvocations): InvokedAtMostCountMatcher
Returns a matcher that matches when the method is executed at most N times.
Parameters
-
int$allowedInvocations
Returns
InvokedAtMostCountMatchercallback() ¶ public static
callback(callable(CallbackInput $callback): bool $callback): Callback<CallbackInput>
Templates
CallbackInput
of mixed Parameters
-
callable(CallbackInput $callback): bool$callback
Returns
Callback<CallbackInput>captureError() ¶ public
captureError(int $errorLevel, Closure $callable): Cake\Error\PhpError
Capture errors from $callable so that you can do assertions on the error.
If no error is captured an assertion will fail.
Parameters
-
int$errorLevel The value of error_reporting() to use.
-
Closure$callable A closure to capture errors from.
Returns
Cake\Error\PhpErrorThe captured error.
clearPlugins() ¶ public
clearPlugins(): void
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
Returns
voidcontainsEqual() ¶ public static
containsEqual(mixed $value): TraversableContainsEqual
Parameters
-
mixed$value
Returns
TraversableContainsEqualcontainsIdentical() ¶ public static
containsIdentical(mixed $value): TraversableContainsIdentical
Parameters
-
mixed$value
Returns
TraversableContainsIdenticalcontainsOnly() ¶ public static
containsOnly(array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string $type): TraversableContainsOnly
Parameters
-
array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string$type
Returns
TraversableContainsOnlyThrows
ExceptioncontainsOnlyArray() ¶ public static
containsOnlyArray(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyBool() ¶ public static
containsOnlyBool(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyCallable() ¶ public static
containsOnlyCallable(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyClosedResource() ¶ public static
containsOnlyClosedResource(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyFloat() ¶ public static
containsOnlyFloat(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyInstancesOf() ¶ public static
containsOnlyInstancesOf(class-string $className): TraversableContainsOnly
Parameters
-
class-string$className
Returns
TraversableContainsOnlyThrows
ExceptioncontainsOnlyInt() ¶ public static
containsOnlyInt(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyIterable() ¶ public static
containsOnlyIterable(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyNull() ¶ public static
containsOnlyNull(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyNumeric() ¶ public static
containsOnlyNumeric(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyObject() ¶ public static
containsOnlyObject(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyResource() ¶ public static
containsOnlyResource(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyScalar() ¶ public static
containsOnlyScalar(): TraversableContainsOnly
Returns
TraversableContainsOnlycontainsOnlyString() ¶ public static
containsOnlyString(): TraversableContainsOnly
Returns
TraversableContainsOnlycreateConfiguredMock() ¶ protected
createConfiguredMock(class-string<RealInstanceType> $type, array<non-empty-string, mixed> $configuration): MockObject&RealInstanceType
Creates (and configures) a mock object for the specified interface or class.
Templates
RealInstanceType
of object Parameters
-
class-string<RealInstanceType>$type -
array<non-empty-string, mixed>$configuration
Returns
MockObject&RealInstanceTypeThrows
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateConfiguredStub() ¶ protected static
createConfiguredStub(class-string<RealInstanceType> $type, array<non-empty-string, mixed> $configuration): RealInstanceType&Stub
Creates (and configures) a test stub for the specified interface or class.
Templates
RealInstanceType
of object Parameters
-
class-string<RealInstanceType>$type -
array<non-empty-string, mixed>$configuration
Returns
RealInstanceType&StubThrows
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateMock() ¶ protected
createMock(class-string<RealInstanceType> $type): MockObject&RealInstanceType
Creates a mock object for the specified interface or class.
Templates
RealInstanceType
of object Parameters
-
class-string<RealInstanceType>$type
Returns
MockObject&RealInstanceTypeThrows
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateMockForIntersectionOfInterfaces() ¶ protected
createMockForIntersectionOfInterfaces(list<class-string> $interfaces): MockObject
Parameters
-
list<class-string>$interfaces
Returns
MockObjectThrows
MockObjectExceptioncreatePartialMock() ¶ protected
createPartialMock(class-string<RealInstanceType> $type, list<non-empty-string> $methods): MockObject&RealInstanceType
Creates a partial mock object for the specified interface or class.
Templates
RealInstanceType
of object Parameters
-
class-string<RealInstanceType>$type -
list<non-empty-string>$methods
Returns
MockObject&RealInstanceTypeThrows
InvalidArgumentExceptionMockObjectExceptioncreateStub() ¶ protected static
createStub(class-string<RealInstanceType> $type): RealInstanceType&Stub
Creates a test stub for the specified interface or class.
Templates
RealInstanceType
of object Parameters
-
class-string<RealInstanceType>$type
Returns
RealInstanceType&StubThrows
InvalidArgumentExceptionMockObjectExceptionNoPreviousThrowableExceptioncreateStubForIntersectionOfInterfaces() ¶ protected static
createStubForIntersectionOfInterfaces(list<class-string> $interfaces): Stub
Parameters
-
list<class-string>$interfaces
Returns
StubThrows
MockObjectExceptiondependencyInput() ¶ public
dependencyInput(): array<non-empty-string, array<mixed>>
Returns
array<non-empty-string, array<mixed>>deprecated() ¶ public
deprecated(Closure $callable, int $type = E_USER_DEPRECATED, string|null $phpVersion = null): void
Helper method for check deprecation methods
Parameters
-
Closure$callable callable function that will receive asserts.
-
int$type optional Error level to expect, E_DEPRECATED or E_USER_DEPRECATED.
-
string|null$phpVersion optional If set, only applies to this version forward, e.g.
8.4.
Returns
voidequalToCanonicalizing() ¶ public static
equalToCanonicalizing(mixed $value): IsEqualCanonicalizing
Parameters
-
mixed$value
Returns
IsEqualCanonicalizingequalToIgnoringCase() ¶ public static
equalToIgnoringCase(mixed $value): IsEqualIgnoringCase
Parameters
-
mixed$value
Returns
IsEqualIgnoringCaseequalToWithDelta() ¶ public static
equalToWithDelta(mixed $value, float $delta): IsEqualWithDelta
Parameters
-
mixed$value -
float$delta
Returns
IsEqualWithDeltaexactly() ¶ protected
exactly(int $count): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly $count times.
Parameters
-
int$count
Returns
InvokedCountMatcherexpectDeprecationMessageMatches() ¶ public
expectDeprecationMessageMatches(string $regex, Closure $callable): void
Parameters
-
string$regex A regex to match against the deprecation message
-
Closure$callable Callable which should trigger the warning
Returns
voidThrows
ExceptionexpectErrorHandlerMessageMatches() ¶ protected
expectErrorHandlerMessageMatches(string $regex, Closure $callable, int $errorLevel): void
Parameters
-
string$regex A regex to match against the warning message
-
Closure$callable Callable which should trigger the warning
-
int$errorLevel The error level to listen to
Returns
voidThrows
ExceptionexpectErrorMessageMatches() ¶ public
expectErrorMessageMatches(string $regex, Closure $callable): void
Parameters
-
string$regex A regex to match against the error message
-
Closure$callable Callable which should trigger the warning
Returns
voidThrows
ExceptionexpectException() ¶ protected
expectException(class-string<Throwable> $exception): void
Parameters
-
class-string<Throwable>$exception
Returns
voidexpectExceptionCode() ¶ protected
expectExceptionCode(int|string $code): void
Parameters
-
int|string$code
Returns
voidexpectExceptionMessage() ¶ protected
expectExceptionMessage(string $message): void
Parameters
-
string$message
Returns
voidexpectExceptionMessageMatches() ¶ protected
expectExceptionMessageMatches(string $regularExpression): void
Parameters
-
string$regularExpression
Returns
voidexpectExceptionObject() ¶ protected
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
voidexpectNoticeMessageMatches() ¶ public
expectNoticeMessageMatches(string $regex, Closure $callable): void
Parameters
-
string$regex A regex to match against the warning message
-
Closure$callable Callable which should trigger the warning
Returns
voidThrows
ExceptionexpectOutputRegex() ¶ protected
expectOutputRegex(string $expectedRegex): void
Parameters
-
string$expectedRegex
Returns
voidexpectOutputString() ¶ protected
expectOutputString(string $expectedString): void
Parameters
-
string$expectedString
Returns
voidexpectUserDeprecationMessage() ¶ protected
expectUserDeprecationMessage(non-empty-string $expectedUserDeprecationMessage): void
Parameters
-
non-empty-string$expectedUserDeprecationMessage
Returns
voidexpectUserDeprecationMessageMatches() ¶ protected
expectUserDeprecationMessageMatches(non-empty-string $expectedUserDeprecationMessageRegularExpression): void
Parameters
-
non-empty-string$expectedUserDeprecationMessageRegularExpression
Returns
voidexpectWarningMessageMatches() ¶ public
expectWarningMessageMatches(string $regex, Closure $callable): void
Parameters
-
string$regex A regex to match against the warning message
-
Closure$callable Callable which should trigger the warning
Returns
voidThrows
Exceptionfail() ¶ public static
fail(string $message = ''): never
Fails a test with the given message.
Parameters
-
string$message optional
Returns
neverThrows
AssertionFailedErrorfetchTable() ¶ public
fetchTable(class-string<T>|string|null $alias = null, array<string, mixed> $options = []): $alias is class-string<T> ? T : \Cake\ORM\Table
Convenience method to get a table instance.
Templates
T
of \Cake\ORM\Table Parameters
-
class-string<T>|string|null$alias optional The alias name you want to get. Should be in CamelCase format. If
nullthen 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
$alias is class-string<T> ? T : \Cake\ORM\TableThrows
Cake\Core\Exception\CakeExceptionIf `$alias` argument and `$defaultTable` property both are `null`.
See Also
getFixtureStrategy() ¶ protected
getFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface
Returns fixture strategy used by these tests.
Returns
Cake\TestSuite\Fixture\FixtureStrategyInterfacegetFixtures() ¶ public
getFixtures(): array<string>
Get the fixtures this test should use.
Returns
array<string>getMockBuilder() ¶ protected
getMockBuilder(class-string<RealInstanceType> $className): MockBuilder<RealInstanceType>
Returns a builder object to create mock objects using a fluent interface.
Templates
RealInstanceType
of object Parameters
-
class-string<RealInstanceType>$className
Returns
MockBuilder<RealInstanceType>getMockForModel() ¶ public
getMockForModel(string $alias, array<string> $methods = [], array<string, mixed> $options = []): Cake\ORM\Table|PHPUnit\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\Table|PHPUnit\Framework\MockObject\MockObjectThrows
Cake\ORM\Exception\MissingTableClassExceptiongetTableLocator() ¶ public
getTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Returns
Cake\ORM\Locator\LocatorInterfacegreaterThan() ¶ public static
greaterThan(mixed $value): GreaterThan
Parameters
-
mixed$value
Returns
GreaterThangreaterThanOrEqual() ¶ public static
greaterThanOrEqual(mixed $value): LogicalOr
Parameters
-
mixed$value
Returns
LogicalOridenticalTo() ¶ public static
identicalTo(mixed $value): IsIdentical
Parameters
-
mixed$value
Returns
IsIdenticalisInstanceOf() ¶ public static
isInstanceOf(string $className): IsInstanceOf
Parameters
-
string$className
Returns
IsInstanceOfThrows
UnknownClassOrInterfaceExceptionisType() ¶ public static
isType(array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string $type): IsType
Parameters
-
array|bool|boolean|callable|double|float|int|integer|iterable|null|numeric|object|real|resource (closed)|resource|scalar|string$type
Returns
IsTypeThrows
UnknownNativeTypeExceptionlessThan() ¶ public static
lessThan(mixed $value): LessThan
Parameters
-
mixed$value
Returns
LessThanlessThanOrEqual() ¶ public static
lessThanOrEqual(mixed $value): LogicalOr
Parameters
-
mixed$value
Returns
LogicalOrloadPlugins() ¶ public
loadPlugins(array $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$plugins optional List of Plugins to load.
Returns
Cake\Http\BaseApplicationloadRoutes() ¶ 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
voidlogicalAnd() ¶ public static
logicalAnd(mixed ...$constraints): LogicalAnd
Parameters
-
mixed...$constraints
Returns
LogicalAndThrows
ExceptionlogicalNot() ¶ public static
logicalNot(Constraint $constraint): LogicalNot
Parameters
-
Constraint$constraint
Returns
LogicalNotlogicalOr() ¶ public static
logicalOr(mixed ...$constraints): LogicalOr
Parameters
-
mixed...$constraints
Returns
LogicalOrlogicalXor() ¶ public static
logicalXor(mixed ...$constraints): LogicalXor
Parameters
-
mixed...$constraints
Returns
LogicalXormarkTestIncomplete() ¶ public static
markTestIncomplete(string $message = ''): never
Mark the test as incomplete.
Parameters
-
string$message optional
Returns
neverThrows
IncompleteTestErrormarkTestSkipped() ¶ public static
markTestSkipped(string $message = ''): never
Mark the test as skipped.
Parameters
-
string$message optional
Returns
neverThrows
SkippedWithMessageExceptionmatches() ¶ public static
matches(string $string): StringMatchesFormatDescription
Parameters
-
string$string
Returns
StringMatchesFormatDescriptionmatchesRegularExpression() ¶ public static
matchesRegularExpression(string $pattern): RegularExpression
Parameters
-
string$pattern
Returns
RegularExpressionnever() ¶ protected
never(): InvokedCountMatcher
Returns a matcher that matches when the method is never executed.
Returns
InvokedCountMatchernumberOfAssertionsPerformed() ¶ public
numberOfAssertionsPerformed(): 0|positive-int
Returns
0|positive-intobjectEquals() ¶ public static
objectEquals(object $object, string $method = 'equals'): ObjectEquals
Parameters
-
object$object -
string$method optional
Returns
ObjectEqualsonNotSuccessfulTest() ¶ protected
onNotSuccessfulTest(Throwable $t): never
This method is called when a test method did not execute successfully.
Parameters
-
Throwable$t
Returns
neverThrows
Throwableonce() ¶ protected
once(): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly once.
Returns
InvokedCountMatcherprovideAdditionalInformation() ¶ protected
provideAdditionalInformation(non-empty-string $additionalInformation): void
Parameters
-
non-empty-string$additionalInformation
Returns
voidprovides() ¶ public
provides(): list<ExecutionOrderDependency>
Returns
list<ExecutionOrderDependency>registerComparator() ¶ protected
registerComparator(Comparator $comparator): void
Parameters
-
Comparator$comparator
Returns
voidregisterFailureType() ¶ protected
registerFailureType(class-string $classOrInterface): void
Parameters
-
class-string$classOrInterface
Returns
voidregisterMockObject() ¶ public
registerMockObject(MockObject $mockObject): void
Parameters
-
MockObject$mockObject
Returns
voidremovePlugins() ¶ 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
voidrequires() ¶ public
requires(): list<ExecutionOrderDependency>
Returns
list<ExecutionOrderDependency>run() ¶ public
run(): void
Returns
voidThrows
PHPUnit\Runner\ExceptionPHPUnit\Util\ExceptionSebastianBergmann\CodeCoverage\InvalidArgumentExceptionSebastianBergmann\Template\InvalidArgumentExceptionExceptionNoPreviousThrowableExceptionProcessIsolationExceptionUnintentionallyCoveredCodeExceptionsetAppNamespace() ¶ public static
setAppNamespace(string $appNamespace = 'TestApp'): string|null
Set the app namespace
Parameters
-
string$appNamespace optional The app namespace, defaults to "TestApp".
Returns
string|nullThe previous app namespace or null if not set.
setBackupGlobals() ¶ public
setBackupGlobals(bool $backupGlobals): void
Parameters
-
bool$backupGlobals
Returns
voidsetBackupGlobalsExcludeList() ¶ public
setBackupGlobalsExcludeList(list<string> $backupGlobalsExcludeList): void
Parameters
-
list<string>$backupGlobalsExcludeList
Returns
voidsetBackupStaticProperties() ¶ public
setBackupStaticProperties(bool $backupStaticProperties): void
Parameters
-
bool$backupStaticProperties
Returns
voidsetBackupStaticPropertiesExcludeList() ¶ public
setBackupStaticPropertiesExcludeList(array<string, list<class-string>> $backupStaticPropertiesExcludeList): void
Parameters
-
array<string, list<class-string>>$backupStaticPropertiesExcludeList
Returns
voidsetData() ¶ public
setData(int|string $dataName, array<mixed> $data): void
Parameters
-
int|string$dataName -
array<mixed>$data
Returns
voidsetDependencies() ¶ public
setDependencies(list<ExecutionOrderDependency> $dependencies): void
Parameters
-
list<ExecutionOrderDependency>$dependencies
Returns
voidsetDependencyInput() ¶ public
setDependencyInput(array<non-empty-string, array<mixed>> $dependencyInput): void
Parameters
-
array<non-empty-string, array<mixed>>$dependencyInput
Returns
voidsetGroups() ¶ public
setGroups(list<string> $groups): void
Parameters
-
list<string>$groups
Returns
voidsetInIsolation() ¶ public
setInIsolation(bool $inIsolation): void
Parameters
-
bool$inIsolation
Returns
voidsetPreserveGlobalState() ¶ public
setPreserveGlobalState(bool $preserveGlobalState): void
Parameters
-
bool$preserveGlobalState
Returns
voidsetRunClassInSeparateProcess() ¶ public
setRunClassInSeparateProcess(bool $runClassInSeparateProcess): void
Parameters
-
bool$runClassInSeparateProcess
Returns
voidsetRunTestInSeparateProcess() ¶ public
setRunTestInSeparateProcess(bool $runTestInSeparateProcess): void
Parameters
-
bool$runTestInSeparateProcess
Returns
voidsetTableLocator() ¶ public
setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface$tableLocator LocatorInterface instance.
Returns
$thissetUp() ¶ 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
voidsetUpBeforeClass() ¶ public static
setUpBeforeClass(): void
This method is called before the first test of this test class is run.
Returns
voidsetupFixtures() ¶ protected
setupFixtures(): void
Initialized and loads any use fixtures.
Returns
voidskipIf() ¶ 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
boolskipUnless() ¶ 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
boolstringContains() ¶ public static
stringContains(string $string, bool $case = true): StringContains
Parameters
-
string$string -
bool$case optional
Returns
StringContainsstringEndsWith() ¶ public static
stringEndsWith(non-empty-string $suffix): StringEndsWith
Parameters
-
non-empty-string$suffix
Returns
StringEndsWithThrows
InvalidArgumentExceptionstringEqualsStringIgnoringLineEndings() ¶ public static
stringEqualsStringIgnoringLineEndings(string $string): StringEqualsStringIgnoringLineEndings
Parameters
-
string$string
Returns
StringEqualsStringIgnoringLineEndingsstringStartsWith() ¶ public static
stringStartsWith(non-empty-string $prefix): StringStartsWith
Parameters
-
non-empty-string$prefix
Returns
StringStartsWithThrows
InvalidArgumentExceptiontearDown() ¶ protected
tearDown(): void
teardown any static object changes and restore them.
Returns
voidtearDownAfterClass() ¶ public static
tearDownAfterClass(): void
This method is called after the last test of this test class is run.
Returns
voidthrowException() ¶ protected
throwException(Throwable $exception): ExceptionStub
Parameters
-
Throwable$exception
Returns
ExceptionStubtoString() ¶ public
toString(): string
Returns a string representation of the test case.
Returns
stringThrows
ExceptiontransformException() ¶ protected
transformException(Throwable $t): Throwable
Parameters
-
Throwable$t
Returns
ThrowablevalueObjectForEvents() ¶ public
valueObjectForEvents(): Event\Code\TestMethod
Returns
Event\Code\TestMethodwithConsecutive() ¶ public static
withConsecutive(array $firstCallArguments, array ...$consecutiveCallsArguments): iterable
Parameters
-
array$firstCallArguments The call arguments
-
array...$consecutiveCallsArguments Additional arguments
Returns
iterablewithErrorReporting() ¶ 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
voidProperty Detail
$appPluginsToLoad ¶ protected
Plugins to be loaded after app instance is created ContainerStubTrait::creatApp()
Type
array