Class TestCase
Cake TestCase class
Properties summary
- $_configure protected
array
Configure values to restore at end of test.
- $_tableLocator protected
\Cake\ORM\Locator\LocatorInterface|null
Table locator instance
- $autoFixtures public
bool
By default, all fixtures attached to this class will be truncated and reloaded after each test.
- $backupGlobals protected
?bool
- $backupGlobalsBlacklist protected
string[]
- $backupStaticAttributes protected
bool
- $backupStaticAttributesBlacklist protected
array<string,array<int,string>>
- $dropTables public
bool
Control table create/drops on each test method.
- $fixtureManager public
\Cake\TestSuite\Fixture\FixtureManager|null
The class responsible for managing the creation, loading and removing of fixtures
- $fixtures protected
string[]
Fixtures used by this test case.
- $preserveGlobalState protected
bool
- $runTestInSeparateProcess protected
bool
Method Summary
- __construct() public
- addToAssertionCount() public
- addWarning() public
- assertAttributeContains() public static
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains a needle.
- assertAttributeContainsOnly() public static
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains only values of a given type.
- assertAttributeCount() public static
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
- assertAttributeEmpty() public static
Asserts that a static attribute of a class or an attribute of an object is empty.
- assertAttributeEquals() public static
Asserts that a variable is equal to an attribute of an object.
- assertAttributeGreaterThanOrEqual() public static
Asserts that an attribute is greater than or equal to another value.
- assertAttributeLessThanOrEqual() public static
Asserts that an attribute is smaller than or equal to another value.
- assertAttributeNotContains() public static
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain a needle.
- assertAttributeNotContainsOnly() public static
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain only values of a given type.
- assertAttributeNotCount() public static
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
- assertAttributeNotEmpty() public static
Asserts that a static attribute of a class or an attribute of an object is not empty.
- assertAttributeNotEquals() public static
Asserts that a variable is not equal to an attribute of an object.
- assertAttributeNotSame() public static
Asserts that a variable and an attribute of an object do not have the same type and value.
- assertAttributeSame() public static
Asserts that a variable and an attribute of an object have the same type and value.
- assertClassHasStaticAttribute() public static
Asserts that a class has a specified static attribute.
- assertClassNotHasAttribute() public static
Asserts that a class does not have a specified attribute.
- assertClassNotHasStaticAttribute() public static
Asserts that a class does not have a specified static attribute.
- assertContainsOnlyInstancesOf() public static
Asserts that a haystack contains only instances of a given class name.
- assertEqualsSql() public
Assert that a string matches SQL with db-specific characters like quotes removed.
- assertEventFired() public
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
- 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).
- 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).
- assertGreaterThanOrEqual() public static
Asserts that a value is greater than or equal to another value.
- 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.
- assertLessThanOrEqual() public static
Asserts that a value is smaller than or equal to another value.
- assertNotContainsOnly() public static
Asserts that a haystack does not contain only values of a given type.
- assertNotCount() public static
Asserts the number of elements of an array, Countable or Traversable.
- assertNotEqualsCanonicalizing() public static
Asserts that two variables are not equal (canonicalizing).
- assertNotEqualsIgnoringCase() public static
Asserts that two variables are not equal (ignoring case).
- assertNotSameSize() public static
Assert that the size of two arrays (or
Countable
orTraversable
objects) is not the same. - assertNotWithinRange() protected static
Compatibility function to test if a value is not between an acceptable range.
- assertObjectNotHasAttribute() public static
Asserts that an object does not have a specified attribute.
- 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 - assertSameSize() public static
Assert that the size of two arrays (or
Countable
orTraversable
objects) is the same. - 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).
- assertStringNotEqualsFile() public static
Asserts that the contents of a string is not equal to the contents of a file.
- assertStringNotEqualsFileCanonicalizing() public static
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
- assertStringNotEqualsFileIgnoringCase() public static
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
- assertStringNotMatchesFormat() public static
Asserts that a string does not match a given format string.
- assertStringNotMatchesFormatFile() public static
Asserts that a string does not match a given format string.
- assertTextContains() public
Assert that a string contains another string, ignoring differences in newlines.
- assertTextEndsNotWith() public
Asserts that a string ends not with a given prefix, ignoring differences in newlines.
- assertTextEndsWith() public
Asserts that a string ends with a given prefix, ignoring differences in newlines.
- assertTextNotContains() public
Assert that a text doesn't contain another text, ignoring differences in newlines.
- assertTextStartsNotWith() public
Asserts that a string starts not with a given prefix, ignoring differences in newlines.
- assertTextStartsWith() public
Asserts that a string starts with a given prefix, ignoring differences in newlines.
- assertWithinRange() protected static
Compatibility function to test if a value is between an acceptable range.
- atLeast() public static
Returns a matcher that matches when the method is executed at least N times.
- atLeastOnce() public static
Returns a matcher that matches when the method is executed at least once.
- count() public
- dataDescription() public
- dataName() public
- doesNotPerformAssertions() public
- doubledTypes() public
- exactly() public static
Returns a matcher that matches when the method is executed exactly $count times.
- expectDeprecation() public
- expectDeprecationMessage() public
- expectError() public
- expectErrorMessage() public
- expectErrorMessageMatches() public
- expectException() public
- expectExceptionCode() public
- expectExceptionMessage() public
- expectExceptionObject() public
Sets up an expectation for an exception to be raised by the code under test.
- expectNotice() public
- expectNoticeMessage() public
- expectNoticeMessageMatches() public
- expectOutputRegex() public
- expectOutputString() public
- expectWarning() public
- expectWarningMessage() public
- getActualOutput() public
- getAnnotations() public
- getDataSetAsString() public
- getDependencies() public
- getDependencyInput() public
- getExpectedException() public
- getExpectedExceptionCode() public
- getGroups() public
- getMockForAbstractClass() protected
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default.
- getMockForTrait() protected
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the
$mockedMethods
parameter. - getName() public
- getResult() public
- getStatus() public
- getStatusMessage() public
- getTestResultObject() public
- hasDependencies() public
- hasExpectationOnOutput() public
- hasFailed() public
- hasOutput() public
- hasSize() public
- iniSet() protected
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
- isInIsolation() public
- isLarge() public
- isMedium() public
- isSmall() public
- markAsRisky() public
- onNotSuccessfulTest() protected
This method is called when a test method did not execute successfully.
- prophesize() protected
- registerComparator() public
- registerMockObject() public
- runBare() public
- setBackupGlobals() public
- setBackupStaticAttributes() public
- setDependencies() public
- setDependencyInput() public
- setGroups() public
- setInIsolation() public
- setLocale() protected
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
- setName() public
- setOutputCallback() public
- setPreserveGlobalState() public
- setResult() public
- setTestResultObject() public
- setUpBeforeClass() public static
This method is called before the first test of this test class is run.
- setUseErrorHandler() public
- tearDownAfterClass() public static
This method is called after the last test of this test class is run.
- usesDataProvider() public
Method Detail
__construct() public
__construct(mixed $name, array $data, mixed $dataName)
Parameters
-
string
$name optional -
array
$data optional -
string
$dataName optional
_assertAttributes() protected
_assertAttributes(array $assertions, string $string, bool $fullDebug, mixed $regex)
Check the attributes as part of an assertTags() check.
Parameters
-
array
$assertions Assertions to run.
-
string
$string The HTML string to check.
-
bool
$fullDebug optional Whether or not more verbose output should be used.
-
array|string
$regex optional Full regexp from
assertHtml
Returns
string|false
_getTableClassName() protected
_getTableClassName(string $alias, array $options)
Gets the class name for the table.
Parameters
-
string
$alias The model to get a mock for.
-
array
$options The config data for the mock's constructor.
Returns
string
Throws
Cake\ORM\Exception\MissingTableClassException
_normalizePath() protected
_normalizePath(string $path)
Normalize a path for comparison.
Parameters
-
string
$path Path separated by "/" slash.
Returns
string
Normalized path separated by DIRECTORY_SEPARATOR.
addFixture() protected
addFixture(string $fixture)
Adds a fixture to this test case.
Examples:
- core.Tags
- app.MyRecords
- plugin.MyPluginName.MyModelName
Use this method inside your test cases' {@link getFixtures()} method to build up the fixture list.
Parameters
-
string
$fixture Fixture
Returns
$this
addToAssertionCount() public
addToAssertionCount(int $count)
Parameters
-
int
$count
addWarning() public
addWarning(string $warning)
Parameters
-
string
$warning
any() public static
any()
Returns a matcher that matches when the method is executed zero or more times.
anything() public static
anything()
arrayHasKey() public static
arrayHasKey(mixed $key)
Parameters
-
int|string
$key
assertArrayHasKey() public static
assertArrayHasKey(mixed $key, mixed $array, string $message)
Asserts that an array has a specified key.
Parameters
-
int|string
$key -
array|\ArrayAccess
$array -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertArrayNotHasKey() public static
assertArrayNotHasKey(mixed $key, mixed $array, string $message)
Asserts that an array does not have a specified key.
Parameters
-
int|string
$key -
array|\ArrayAccess
$array -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertArraySubset() public static
assertArraySubset(mixed $subset, mixed $array, bool $checkForObjectIdentity, string $message)
Asserts that an array has a specified subset.
Parameters
-
array|\ArrayAccess
$subset -
array|\ArrayAccess
$array -
bool
$checkForObjectIdentity optional -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeContains() public static
assertAttributeContains(mixed $needle, string $haystackAttributeName, mixed $haystackClassOrObject, string $message, bool $ignoreCase, bool $checkForObjectIdentity, bool $checkForNonObjectIdentity)
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains a needle.
Parameters
-
mixed
$needle -
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
string
$message optional -
bool
$ignoreCase optional -
bool
$checkForObjectIdentity optional -
bool
$checkForNonObjectIdentity optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeContainsOnly() public static
assertAttributeContainsOnly(string $type, string $haystackAttributeName, mixed $haystackClassOrObject, ?bool $isNativeType, string $message)
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains only values of a given type.
Parameters
-
string
$type -
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
bool
$isNativeType optional -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeCount() public static
assertAttributeCount(int $expectedCount, string $haystackAttributeName, mixed $haystackClassOrObject, string $message)
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
Parameters
-
int
$expectedCount -
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeEmpty() public static
assertAttributeEmpty(string $haystackAttributeName, mixed $haystackClassOrObject, string $message)
Asserts that a static attribute of a class or an attribute of an object is empty.
Parameters
-
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeEquals() public static
assertAttributeEquals(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message, float $delta, int $maxDepth, bool $canonicalize, bool $ignoreCase)
Asserts that a variable is equal to an attribute of an object.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional -
float
$delta optional -
int
$maxDepth optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeGreaterThan() public static
assertAttributeGreaterThan(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message)
Asserts that an attribute is greater than another value.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeGreaterThanOrEqual() public static
assertAttributeGreaterThanOrEqual(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message)
Asserts that an attribute is greater than or equal to another value.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeInstanceOf() public static
assertAttributeInstanceOf(string $expected, string $attributeName, mixed $classOrObject, string $message)
Asserts that an attribute is of a given type.
Parameters
-
string
$expected -
string
$attributeName -
object|string
$classOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeInternalType() public static
assertAttributeInternalType(string $expected, string $attributeName, mixed $classOrObject, string $message)
Asserts that an attribute is of a given type.
Parameters
-
string
$expected -
string
$attributeName -
object|string
$classOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeLessThan() public static
assertAttributeLessThan(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message)
Asserts that an attribute is smaller than another value.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeLessThanOrEqual() public static
assertAttributeLessThanOrEqual(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message)
Asserts that an attribute is smaller than or equal to another value.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotContains() public static
assertAttributeNotContains(mixed $needle, string $haystackAttributeName, mixed $haystackClassOrObject, string $message, bool $ignoreCase, bool $checkForObjectIdentity, bool $checkForNonObjectIdentity)
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain a needle.
Parameters
-
mixed
$needle -
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
string
$message optional -
bool
$ignoreCase optional -
bool
$checkForObjectIdentity optional -
bool
$checkForNonObjectIdentity optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotContainsOnly() public static
assertAttributeNotContainsOnly(string $type, string $haystackAttributeName, mixed $haystackClassOrObject, ?bool $isNativeType, string $message)
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain only values of a given type.
Parameters
-
string
$type -
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
bool
$isNativeType optional -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotCount() public static
assertAttributeNotCount(int $expectedCount, string $haystackAttributeName, mixed $haystackClassOrObject, string $message)
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
Parameters
-
int
$expectedCount -
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotEmpty() public static
assertAttributeNotEmpty(string $haystackAttributeName, mixed $haystackClassOrObject, string $message)
Asserts that a static attribute of a class or an attribute of an object is not empty.
Parameters
-
string
$haystackAttributeName -
object|string
$haystackClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotEquals() public static
assertAttributeNotEquals(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message, float $delta, int $maxDepth, bool $canonicalize, bool $ignoreCase)
Asserts that a variable is not equal to an attribute of an object.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional -
float
$delta optional -
int
$maxDepth optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotInstanceOf() public static
assertAttributeNotInstanceOf(string $expected, string $attributeName, mixed $classOrObject, string $message)
Asserts that an attribute is of a given type.
Parameters
-
string
$expected -
string
$attributeName -
object|string
$classOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotInternalType() public static
assertAttributeNotInternalType(string $expected, string $attributeName, mixed $classOrObject, string $message)
Asserts that an attribute is of a given type.
Parameters
-
string
$expected -
string
$attributeName -
object|string
$classOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeNotSame() public static
assertAttributeNotSame(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message)
Asserts that a variable and an attribute of an object do not have the same type and value.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertAttributeSame() public static
assertAttributeSame(mixed $expected, string $actualAttributeName, mixed $actualClassOrObject, string $message)
Asserts that a variable and an attribute of an object have the same type and value.
Parameters
-
mixed
$expected -
string
$actualAttributeName -
object|string
$actualClassOrObject -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertClassHasAttribute() public static
assertClassHasAttribute(string $attributeName, string $className, string $message)
Asserts that a class has a specified attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertClassHasStaticAttribute() public static
assertClassHasStaticAttribute(string $attributeName, string $className, string $message)
Asserts that a class has a specified static attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertClassNotHasAttribute() public static
assertClassNotHasAttribute(string $attributeName, string $className, string $message)
Asserts that a class does not have a specified attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertClassNotHasStaticAttribute() public static
assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message)
Asserts that a class does not have a specified static attribute.
Parameters
-
string
$attributeName -
string
$className -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertContains() public static
assertContains(mixed $needle, mixed $haystack, string $message, bool $ignoreCase, bool $checkForObjectIdentity, bool $checkForNonObjectIdentity)
Asserts that a haystack contains a needle.
Parameters
-
mixed
$needle -
mixed
$haystack -
string
$message optional -
bool
$ignoreCase optional -
bool
$checkForObjectIdentity optional -
bool
$checkForNonObjectIdentity optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertContainsEquals() public static
assertContainsEquals(mixed $needle, iterable $haystack, string $message)
Parameters
-
mixed
$needle -
iterable
$haystack -
string
$message optional
assertContainsOnly() public static
assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType, string $message)
Asserts that a haystack contains only values of a given type.
Parameters
-
string
$type -
iterable
$haystack -
?bool
$isNativeType optional -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertContainsOnlyInstancesOf() public static
assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message)
Asserts that a haystack contains only instances of a given class name.
Parameters
-
string
$className -
iterable
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertCount() public static
assertCount(int $expectedCount, mixed $haystack, string $message)
Asserts the number of elements of an array, Countable or Traversable.
Parameters
-
int
$expectedCount -
\Countable|iterable
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertDirectoryExists() public static
assertDirectoryExists(string $directory, string $message)
Asserts that a directory exists.
Parameters
-
string
$directory -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertDirectoryIsReadable() public static
assertDirectoryIsReadable(string $directory, string $message)
Asserts that a directory exists and is readable.
Parameters
-
string
$directory -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertDirectoryIsWritable() public static
assertDirectoryIsWritable(string $directory, string $message)
Asserts that a directory exists and is writable.
Parameters
-
string
$directory -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertDirectoryNotExists() public static
assertDirectoryNotExists(string $directory, string $message)
Asserts that a directory does not exist.
Parameters
-
string
$directory -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertDirectoryNotIsReadable() public static
assertDirectoryNotIsReadable(string $directory, string $message)
Asserts that a directory exists and is not readable.
Parameters
-
string
$directory -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertDirectoryNotIsWritable() public static
assertDirectoryNotIsWritable(string $directory, string $message)
Asserts that a directory exists and is not writable.
Parameters
-
string
$directory -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEmpty() public static
assertEmpty(mixed $actual, string $message)
Asserts that a variable is empty.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEqualXMLStructure() public static
assertEqualXMLStructure(\DOMElement $expectedElement, \DOMElement $actualElement, bool $checkAttributes, string $message)
Asserts that a hierarchy of DOMElements matches.
Parameters
-
\DOMElement
$expectedElement -
\DOMElement
$actualElement -
bool
$checkAttributes optional -
string
$message optional
Throws
PHPUnit\Framework\AssertionFailedError
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEquals() public static
assertEquals(mixed $expected, mixed $actual, string $message, float $delta, int $maxDepth, bool $canonicalize, bool $ignoreCase)
Asserts that two variables are equal.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional -
float
$delta optional -
int
$maxDepth optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEqualsCanonicalizing() public static
assertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message)
Asserts that two variables are equal (canonicalizing).
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEqualsIgnoringCase() public static
assertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message)
Asserts that two variables are equal (ignoring case).
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEqualsSql() public
assertEqualsSql(string $expected, string $actual, string $message)
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
assertEqualsWithDelta() public static
assertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message)
Asserts that two variables are equal (with delta).
Parameters
-
mixed
$expected -
mixed
$actual -
float
$delta -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertEventFired() public
assertEventFired(string $name, ?\Cake\Event\EventManager $eventManager, string $message)
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
Parameters
-
string
$name Event name
-
\Cake\Event\EventManager|null
$eventManager optional Event manager to check, defaults to global event manager
-
string
$message optional Assertion failure message
assertEventFiredWith() public
assertEventFiredWith(string $name, string $dataKey, mixed $dataValue, ?\Cake\Event\EventManager $eventManager, string $message)
Asserts an event was fired with data
If a third argument is passed, that value is used to compare with the value in $dataKey
Parameters
-
string
$name Event name
-
string
$dataKey Data key
-
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
assertFalse() public static
assertFalse(mixed $condition, string $message)
Asserts that a condition is false.
Parameters
-
mixed
$condition -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileEquals() public static
assertFileEquals(string $expected, string $actual, string $message, bool $canonicalize, bool $ignoreCase)
Asserts that the contents of one file is equal to the contents of another file.
Parameters
-
string
$expected -
string
$actual -
string
$message optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileEqualsCanonicalizing() public static
assertFileEqualsCanonicalizing(string $expected, string $actual, string $message)
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
Parameters
-
string
$expected -
string
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileEqualsIgnoringCase() public static
assertFileEqualsIgnoringCase(string $expected, string $actual, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileExists() public static
assertFileExists(string $filename, string $message)
Asserts that a file exists.
Parameters
-
string
$filename -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileIsReadable() public static
assertFileIsReadable(string $file, string $message)
Asserts that a file exists and is readable.
Parameters
-
string
$file -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileIsWritable() public static
assertFileIsWritable(string $file, string $message)
Asserts that a file exists and is writable.
Parameters
-
string
$file -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileNotEquals() public static
assertFileNotEquals(string $expected, string $actual, string $message, bool $canonicalize, bool $ignoreCase)
Asserts that the contents of one file is not equal to the contents of another file.
Parameters
-
string
$expected -
string
$actual -
string
$message optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileNotEqualsCanonicalizing() public static
assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileNotEqualsIgnoringCase() public static
assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileNotExists() public static
assertFileNotExists(string $filename, string $message)
Asserts that a file does not exist.
Parameters
-
string
$filename -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileNotIsReadable() public static
assertFileNotIsReadable(string $file, string $message)
Asserts that a file exists and is not readable.
Parameters
-
string
$file -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFileNotIsWritable() public static
assertFileNotIsWritable(string $file, string $message)
Asserts that a file exists and is not writable.
Parameters
-
string
$file -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertFinite() public static
assertFinite(mixed $actual, string $message)
Asserts that a variable is finite.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertGreaterThan() public static
assertGreaterThan(mixed $expected, mixed $actual, string $message)
Asserts that a value is greater than another value.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertGreaterThanOrEqual() public static
assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message)
Asserts that a value is greater than or equal to another value.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertHtml() public
assertHtml(array $expected, string $string, bool $fullDebug)
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 or not more verbose output should be used.
Returns
bool
assertInfinite() public static
assertInfinite(mixed $actual, string $message)
Asserts that a variable is infinite.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertInstanceOf() public static
assertInstanceOf(string $expected, mixed $actual, string $message)
Asserts that a variable is of a given type.
Parameters
-
string
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertInternalType() public static
assertInternalType(string $expected, mixed $actual, string $message)
Asserts that a variable is of a given type.
Parameters
-
string
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsArray() public static
assertIsArray(mixed $actual, string $message)
Asserts that a variable is of type array.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsBool() public static
assertIsBool(mixed $actual, string $message)
Asserts that a variable is of type bool.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsCallable() public static
assertIsCallable(mixed $actual, string $message)
Asserts that a variable is of type callable.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsFloat() public static
assertIsFloat(mixed $actual, string $message)
Asserts that a variable is of type float.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsInt() public static
assertIsInt(mixed $actual, string $message)
Asserts that a variable is of type int.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsIterable() public static
assertIsIterable(mixed $actual, string $message)
Asserts that a variable is of type iterable.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotArray() public static
assertIsNotArray(mixed $actual, string $message)
Asserts that a variable is not of type array.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotBool() public static
assertIsNotBool(mixed $actual, string $message)
Asserts that a variable is not of type bool.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotCallable() public static
assertIsNotCallable(mixed $actual, string $message)
Asserts that a variable is not of type callable.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotFloat() public static
assertIsNotFloat(mixed $actual, string $message)
Asserts that a variable is not of type float.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotInt() public static
assertIsNotInt(mixed $actual, string $message)
Asserts that a variable is not of type int.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotIterable() public static
assertIsNotIterable(mixed $actual, string $message)
Asserts that a variable is not of type iterable.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotNumeric() public static
assertIsNotNumeric(mixed $actual, string $message)
Asserts that a variable is not of type numeric.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotObject() public static
assertIsNotObject(mixed $actual, string $message)
Asserts that a variable is not of type object.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotResource() public static
assertIsNotResource(mixed $actual, string $message)
Asserts that a variable is not of type resource.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotScalar() public static
assertIsNotScalar(mixed $actual, string $message)
Asserts that a variable is not of type scalar.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNotString() public static
assertIsNotString(mixed $actual, string $message)
Asserts that a variable is not of type string.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsNumeric() public static
assertIsNumeric(mixed $actual, string $message)
Asserts that a variable is of type numeric.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsObject() public static
assertIsObject(mixed $actual, string $message)
Asserts that a variable is of type object.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsReadable() public static
assertIsReadable(string $filename, string $message)
Asserts that a file/dir is readable.
Parameters
-
string
$filename -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsResource() public static
assertIsResource(mixed $actual, string $message)
Asserts that a variable is of type resource.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsScalar() public static
assertIsScalar(mixed $actual, string $message)
Asserts that a variable is of type scalar.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsString() public static
assertIsString(mixed $actual, string $message)
Asserts that a variable is of type string.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertIsWritable() public static
assertIsWritable(string $filename, string $message)
Asserts that a file/dir exists and is writable.
Parameters
-
string
$filename -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJson() public static
assertJson(string $actualJson, string $message)
Asserts that a string is a valid JSON string.
Parameters
-
string
$actualJson -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJsonFileEqualsJsonFile() public static
assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message)
Asserts that two JSON files are equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJsonFileNotEqualsJsonFile() public static
assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message)
Asserts that two JSON files are not equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJsonStringEqualsJsonFile() public static
assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message)
Asserts that the generated JSON encoded object and the content of the given file are equal.
Parameters
-
string
$expectedFile -
string
$actualJson -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJsonStringEqualsJsonString() public static
assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message)
Asserts that two given JSON encoded objects or arrays are equal.
Parameters
-
string
$expectedJson -
string
$actualJson -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJsonStringNotEqualsJsonFile() public static
assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertJsonStringNotEqualsJsonString() public static
assertJsonStringNotEqualsJsonString(mixed $expectedJson, mixed $actualJson, string $message)
Asserts that two given JSON encoded objects or arrays are not equal.
Parameters
-
string
$expectedJson -
string
$actualJson -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertLessThan() public static
assertLessThan(mixed $expected, mixed $actual, string $message)
Asserts that a value is smaller than another value.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertLessThanOrEqual() public static
assertLessThanOrEqual(mixed $expected, mixed $actual, string $message)
Asserts that a value is smaller than or equal to another value.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNan() public static
assertNan(mixed $actual, string $message)
Asserts that a variable is nan.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotContains() public static
assertNotContains(mixed $needle, mixed $haystack, string $message, bool $ignoreCase, bool $checkForObjectIdentity, bool $checkForNonObjectIdentity)
Asserts that a haystack does not contain a needle.
Parameters
-
mixed
$needle -
mixed
$haystack -
string
$message optional -
bool
$ignoreCase optional -
bool
$checkForObjectIdentity optional -
bool
$checkForNonObjectIdentity optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertNotContainsEquals() public static
assertNotContainsEquals(mixed $needle, iterable $haystack, string $message)
Parameters
-
mixed
$needle -
iterable
$haystack -
string
$message optional
assertNotContainsOnly() public static
assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType, string $message)
Asserts that a haystack does not contain only values of a given type.
Parameters
-
string
$type -
iterable
$haystack -
?bool
$isNativeType optional -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotCount() public static
assertNotCount(int $expectedCount, mixed $haystack, string $message)
Asserts the number of elements of an array, Countable or Traversable.
Parameters
-
int
$expectedCount -
\Countable|iterable
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertNotEmpty() public static
assertNotEmpty(mixed $actual, string $message)
Asserts that a variable is not empty.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotEquals() public static
assertNotEquals(mixed $expected, mixed $actual, string $message, mixed $delta, mixed $maxDepth, mixed $canonicalize, mixed $ignoreCase)
Asserts that two variables are not equal.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional -
float
$delta optional -
int
$maxDepth optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotEqualsCanonicalizing() public static
assertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message)
Asserts that two variables are not equal (canonicalizing).
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotEqualsIgnoringCase() public static
assertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message)
Asserts that two variables are not equal (ignoring case).
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotEqualsWithDelta() public static
assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message)
Asserts that two variables are not equal (with delta).
Parameters
-
mixed
$expected -
mixed
$actual -
float
$delta -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotFalse() public static
assertNotFalse(mixed $condition, string $message)
Asserts that a condition is not false.
Parameters
-
mixed
$condition -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotInstanceOf() public static
assertNotInstanceOf(string $expected, mixed $actual, string $message)
Asserts that a variable is not of a given type.
Parameters
-
string
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertNotInternalType() public static
assertNotInternalType(string $expected, mixed $actual, string $message)
Asserts that a variable is not of a given type.
Parameters
-
string
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotIsReadable() public static
assertNotIsReadable(string $filename, string $message)
Asserts that a file/dir exists and is not readable.
Parameters
-
string
$filename -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotIsWritable() public static
assertNotIsWritable(string $filename, string $message)
Asserts that a file/dir exists and is not writable.
Parameters
-
string
$filename -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotNull() public static
assertNotNull(mixed $actual, string $message)
Asserts that a variable is not null.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotRegExp() public static
assertNotRegExp(string $pattern, string $string, string $message)
Asserts that a string does not match a given regular expression.
Parameters
-
string
$pattern -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotSame() public static
assertNotSame(mixed $expected, mixed $actual, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotSameSize() public static
assertNotSameSize(mixed $expected, mixed $actual, string $message)
Assert that the size of two arrays (or Countable
or Traversable
objects) is not the same.
Parameters
-
\Countable|iterable
$expected -
\Countable|iterable
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertNotTrue() public static
assertNotTrue(mixed $condition, string $message)
Asserts that a condition is not true.
Parameters
-
mixed
$condition -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertNotWithinRange() protected static
assertNotWithinRange(mixed $expected, mixed $result, mixed $margin, mixed $message)
Compatibility function to test if a value is not between an acceptable range.
Parameters
-
float
$expected -
float
$result -
float
$margin the rage of acceptation
-
string
$message optional the text to display if the assertion is not correct
assertNull() public static
assertNull(mixed $actual, string $message)
Asserts that a variable is null.
Parameters
-
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertObjectHasAttribute() public static
assertObjectHasAttribute(string $attributeName, mixed $object, string $message)
Asserts that an object has a specified attribute.
Parameters
-
string
$attributeName -
object
$object -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertObjectNotHasAttribute() public static
assertObjectNotHasAttribute(string $attributeName, mixed $object, string $message)
Asserts that an object does not have a specified attribute.
Parameters
-
string
$attributeName -
object
$object -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertPathEquals() protected static
assertPathEquals(mixed $expected, mixed $result, mixed $message)
Compatibility function to test paths.
Parameters
-
string
$expected -
string
$result -
string
$message optional the text to display if the assertion is not correct
assertPostConditions() protected
assertPostConditions()
Performs assertions shared by all tests of a test case.
This method is called between test and tearDown().
assertPreConditions() protected
assertPreConditions()
Performs assertions shared by all tests of a test case.
This method is called between setUp() and test.
assertRegExp() public static
assertRegExp(string $pattern, string $string, string $message)
Asserts that a string matches a given regular expression.
Parameters
-
string
$pattern -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertRegExpSql() public
assertRegExpSql(string $pattern, string $actual, bool $optional)
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
assertSame() public static
assertSame(mixed $expected, mixed $actual, string $message)
Asserts that two variables have the same type and value.
Used on objects, it asserts that two variables reference the same object.
Parameters
-
mixed
$expected -
mixed
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertSameSize() public static
assertSameSize(mixed $expected, mixed $actual, string $message)
Assert that the size of two arrays (or Countable
or Traversable
objects) is the same.
Parameters
-
\Countable|iterable
$expected -
\Countable|iterable
$actual -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertStringContainsString() public static
assertStringContainsString(string $needle, string $haystack, string $message)
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringContainsStringIgnoringCase() public static
assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message)
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringEndsNotWith() public static
assertStringEndsNotWith(string $suffix, string $string, string $message)
Asserts that a string ends not with a given suffix.
Parameters
-
string
$suffix -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringEndsWith() public static
assertStringEndsWith(string $suffix, string $string, string $message)
Asserts that a string ends with a given suffix.
Parameters
-
string
$suffix -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringEqualsFile() public static
assertStringEqualsFile(string $expectedFile, string $actualString, string $message, bool $canonicalize, bool $ignoreCase)
Asserts that the contents of a string is equal to the contents of a file.
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringEqualsFileCanonicalizing() public static
assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message)
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringEqualsFileIgnoringCase() public static
assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringMatchesFormat() public static
assertStringMatchesFormat(string $format, string $string, string $message)
Asserts that a string matches a given format string.
Parameters
-
string
$format -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringMatchesFormatFile() public static
assertStringMatchesFormatFile(string $formatFile, string $string, string $message)
Asserts that a string matches a given format file.
Parameters
-
string
$formatFile -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotContainsString() public static
assertStringNotContainsString(string $needle, string $haystack, string $message)
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotContainsStringIgnoringCase() public static
assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message)
Parameters
-
string
$needle -
string
$haystack -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotEqualsFile() public static
assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message, bool $canonicalize, bool $ignoreCase)
Asserts that the contents of a string is not equal to the contents of a file.
Parameters
-
string
$expectedFile -
string
$actualString -
string
$message optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotEqualsFileCanonicalizing() public static
assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotEqualsFileIgnoringCase() public static
assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message)
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
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotMatchesFormat() public static
assertStringNotMatchesFormat(string $format, string $string, string $message)
Asserts that a string does not match a given format string.
Parameters
-
string
$format -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringNotMatchesFormatFile() public static
assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message)
Asserts that a string does not match a given format string.
Parameters
-
string
$formatFile -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringStartsNotWith() public static
assertStringStartsNotWith(mixed $prefix, mixed $string, string $message)
Asserts that a string starts not with a given prefix.
Parameters
-
string
$prefix -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertStringStartsWith() public static
assertStringStartsWith(string $prefix, string $string, string $message)
Asserts that a string starts with a given prefix.
Parameters
-
string
$prefix -
string
$string -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertTextContains() public
assertTextContains(string $needle, string $haystack, string $message, bool $ignoreCase)
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 or not the search should be case-sensitive.
assertTextEndsNotWith() public
assertTextEndsNotWith(string $suffix, string $string, string $message)
Asserts that a string ends not with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$suffix The suffix to not find.
-
string
$string The string to search.
-
string
$message optional The message to use for failure.
assertTextEndsWith() public
assertTextEndsWith(string $suffix, string $string, string $message)
Asserts that a string ends with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$suffix The suffix to find.
-
string
$string The string to search.
-
string
$message optional The message to use for failure.
assertTextEquals() public
assertTextEquals(string $expected, string $result, string $message)
Assert text equality, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$expected The expected value.
-
string
$result The actual value.
-
string
$message optional The message to use for failure.
assertTextNotContains() public
assertTextNotContains(string $needle, string $haystack, string $message, bool $ignoreCase)
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 or not the search should be case-sensitive.
assertTextNotEquals() public
assertTextNotEquals(string $expected, string $result, string $message)
Assert text equality, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$expected The expected value.
-
string
$result The actual value.
-
string
$message optional The message to use for failure.
assertTextStartsNotWith() public
assertTextStartsNotWith(string $prefix, string $string, string $message)
Asserts that a string starts not with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$prefix The prefix to not find.
-
string
$string The string to search.
-
string
$message optional The message to use for failure.
assertTextStartsWith() public
assertTextStartsWith(string $prefix, string $string, string $message)
Asserts that a string starts with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
Parameters
-
string
$prefix The prefix to check for.
-
string
$string The string to search in.
-
string
$message optional The message to use for failure.
assertThat() public static
assertThat(mixed $value, \PHPUnit\Framework\Constraint\Constraint $constraint, string $message)
Evaluates a PHPUnit\Framework\Constraint matcher object.
Parameters
-
mixed
$value -
\PHPUnit\Framework\Constraint\Constraint
$constraint -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertTrue() public static
assertTrue(mixed $condition, string $message)
Asserts that a condition is true.
Parameters
-
mixed
$condition -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
assertWithinRange() protected static
assertWithinRange(mixed $expected, mixed $result, mixed $margin, mixed $message)
Compatibility function to test if a value is between an acceptable range.
Parameters
-
float
$expected -
float
$result -
float
$margin the rage of acceptation
-
string
$message optional the text to display if the assertion is not correct
assertXmlFileEqualsXmlFile() public static
assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message)
Asserts that two XML files are equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertXmlFileNotEqualsXmlFile() public static
assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message)
Asserts that two XML files are not equal.
Parameters
-
string
$expectedFile -
string
$actualFile -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertXmlStringEqualsXmlFile() public static
assertXmlStringEqualsXmlFile(string $expectedFile, mixed $actualXml, string $message)
Asserts that two XML documents are equal.
Parameters
-
string
$expectedFile -
\DOMDocument|string
$actualXml -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertXmlStringEqualsXmlString() public static
assertXmlStringEqualsXmlString(mixed $expectedXml, mixed $actualXml, string $message)
Asserts that two XML documents are equal.
Parameters
-
\DOMDocument|string
$expectedXml -
\DOMDocument|string
$actualXml -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertXmlStringNotEqualsXmlFile() public static
assertXmlStringNotEqualsXmlFile(string $expectedFile, mixed $actualXml, string $message)
Asserts that two XML documents are not equal.
Parameters
-
string
$expectedFile -
\DOMDocument|string
$actualXml -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
assertXmlStringNotEqualsXmlString() public static
assertXmlStringNotEqualsXmlString(mixed $expectedXml, mixed $actualXml, string $message)
Asserts that two XML documents are not equal.
Parameters
-
\DOMDocument|string
$expectedXml -
\DOMDocument|string
$actualXml -
string
$message optional
Throws
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
at() public static
at(int $index)
Returns a matcher that matches when the method is executed at the given index.
Parameters
-
int
$index
atLeast() public static
atLeast(int $requiredInvocations)
Returns a matcher that matches when the method is executed at least N times.
Parameters
-
int
$requiredInvocations
atLeastOnce() public static
atLeastOnce()
Returns a matcher that matches when the method is executed at least once.
atMost() public static
atMost(int $allowedInvocations)
Returns a matcher that matches when the method is executed at most N times.
Parameters
-
int
$allowedInvocations
attribute() public static
attribute(\PHPUnit\Framework\Constraint\Constraint $constraint, string $attributeName)
Parameters
-
\PHPUnit\Framework\Constraint\Constraint
$constraint -
string
$attributeName
attributeEqualTo() public static
attributeEqualTo(string $attributeName, mixed $value, float $delta, int $maxDepth, bool $canonicalize, bool $ignoreCase)
Parameters
-
string
$attributeName -
mixed
$value -
float
$delta optional -
int
$maxDepth optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
callback() public static
callback(callable $callback)
Parameters
-
callable
$callback
classHasAttribute() public static
classHasAttribute(string $attributeName)
Parameters
-
string
$attributeName
classHasStaticAttribute() public static
classHasStaticAttribute(string $attributeName)
Parameters
-
string
$attributeName
clearPlugins() public
clearPlugins()
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
contains() public static
contains(mixed $value, bool $checkForObjectIdentity, bool $checkForNonObjectIdentity)
Parameters
-
mixed
$value -
bool
$checkForObjectIdentity optional -
bool
$checkForNonObjectIdentity optional
containsEqual() public static
containsEqual(mixed $value)
Parameters
-
mixed
$value
containsIdentical() public static
containsIdentical(mixed $value)
Parameters
-
mixed
$value
containsOnly() public static
containsOnly(string $type)
Parameters
-
string
$type
containsOnlyInstancesOf() public static
containsOnlyInstancesOf(string $className)
Parameters
-
string
$className
count() public
count()
countOf() public static
countOf(int $count)
Parameters
-
int
$count
createConfiguredMock() protected
createConfiguredMock(mixed $originalClassName, array $configuration)
Returns a configured mock object for the specified class.
Parameters
-
string|string[]
$originalClassName -
array
$configuration
createMock() protected
createMock(mixed $originalClassName)
Returns a mock object for the specified class.
Parameters
-
string|string[]
$originalClassName
createPartialMock() protected
createPartialMock(mixed $originalClassName, array $methods)
Returns a partial mock object for the specified class.
Parameters
-
string|string[]
$originalClassName -
string[]
$methods
createResult() protected
createResult()
Creates a default TestResult object.
createStub() protected
createStub(string $originalClassName)
Makes configurable stub for the specified class.
Parameters
-
string
$originalClassName
createTestProxy() protected
createTestProxy(string $originalClassName, array $constructorArguments)
Returns a test proxy for the specified class.
Parameters
-
string
$originalClassName -
array
$constructorArguments optional
dataDescription() public
dataDescription()
dataName() public
dataName()
Returns
int|string
deprecated() public
deprecated(callable $callable)
Helper method for check deprecation methods
Parameters
-
callable
$callable callable function that will receive asserts
directoryExists() public static
directoryExists()
doesNotPerformAssertions() public
doesNotPerformAssertions()
doubledTypes() public
doubledTypes()
Returns
string[]
equalTo() public static
equalTo(mixed $value, float $delta, int $maxDepth, bool $canonicalize, bool $ignoreCase)
Parameters
-
mixed
$value -
float
$delta optional -
int
$maxDepth optional -
bool
$canonicalize optional -
bool
$ignoreCase optional
exactly() public static
exactly(int $count)
Returns a matcher that matches when the method is executed exactly $count times.
Parameters
-
int
$count
expectDeprecation() public
expectDeprecation()
expectDeprecationMessage() public
expectDeprecationMessage(string $message)
Parameters
-
string
$message
expectDeprecationMessageMatches() public
expectDeprecationMessageMatches(string $regularExpression)
Parameters
-
string
$regularExpression
expectError() public
expectError()
expectErrorMessage() public
expectErrorMessage(string $message)
Parameters
-
string
$message
expectErrorMessageMatches() public
expectErrorMessageMatches(string $regularExpression)
Parameters
-
string
$regularExpression
expectException() public
expectException(string $exception)
Parameters
-
string
$exception
expectExceptionCode() public
expectExceptionCode(mixed $code)
Parameters
-
int|string
$code
expectExceptionMessage() public
expectExceptionMessage(string $message)
Parameters
-
string
$message
expectExceptionMessageMatches() public
expectExceptionMessageMatches(string $regularExpression)
Parameters
-
string
$regularExpression
expectExceptionMessageRegExp() public
expectExceptionMessageRegExp(string $regularExpression)
Parameters
-
string
$regularExpression
expectExceptionObject() public
expectExceptionObject(\Exception $exception)
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
expectNotToPerformAssertions() public
expectNotToPerformAssertions()
expectNotice() public
expectNotice()
expectNoticeMessage() public
expectNoticeMessage(string $message)
Parameters
-
string
$message
expectNoticeMessageMatches() public
expectNoticeMessageMatches(string $regularExpression)
Parameters
-
string
$regularExpression
expectOutputRegex() public
expectOutputRegex(string $expectedRegex)
Parameters
-
string
$expectedRegex
expectOutputString() public
expectOutputString(string $expectedString)
Parameters
-
string
$expectedString
expectWarning() public
expectWarning()
expectWarningMessage() public
expectWarningMessage(string $message)
Parameters
-
string
$message
expectWarningMessageMatches() public
expectWarningMessageMatches(string $regularExpression)
Parameters
-
string
$regularExpression
fail() public static
fail(string $message)
Fails a test with the given message.
Parameters
-
string
$message optional
Throws
PHPUnit\Framework\AssertionFailedError
fileExists() public static
fileExists()
getActualOutput() public
getActualOutput()
getActualOutputForAssertion() public
getActualOutputForAssertion()
getAnnotations() public
getAnnotations()
getCount() public static
getCount()
Return the current assertion count.
getDataSetAsString() public
getDataSetAsString(bool $includeData)
Parameters
-
bool
$includeData optional
getDependencies() public
getDependencies()
getDependencyInput() public
getDependencyInput()
getExpectedException() public
getExpectedException()
getExpectedExceptionCode() public
getExpectedExceptionCode()
Returns
null|int|string
getExpectedExceptionMessage() public
getExpectedExceptionMessage()
getExpectedExceptionMessageRegExp() public
getExpectedExceptionMessageRegExp()
getFixtures() public
getFixtures()
Gets fixtures.
Returns
string[]
getGroups() public
getGroups()
getMockBuilder() public
getMockBuilder(mixed $className)
Returns a builder object to create mock objects using a fluent interface.
Parameters
-
string|string[]
$className
getMockClass() protected
getMockClass(mixed $originalClassName, mixed $methods, array $arguments, mixed $mockClassName, mixed $callOriginalConstructor, mixed $callOriginalClone, mixed $callAutoload, mixed $cloneArguments)
Mocks the specified class and returns the name of the mocked class.
Parameters
-
string
$originalClassName -
array
$methods optional -
array
$arguments optional -
string
$mockClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional -
bool
$cloneArguments optional
getMockForAbstractClass() protected
getMockForAbstractClass(mixed $originalClassName, array $arguments, mixed $mockClassName, mixed $callOriginalConstructor, mixed $callOriginalClone, mixed $callAutoload, mixed $mockedMethods, mixed $cloneArguments)
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default.
To mock concrete methods, use the 7th parameter ($mockedMethods).
Parameters
-
string
$originalClassName -
array
$arguments optional -
string
$mockClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional -
array
$mockedMethods optional -
bool
$cloneArguments optional
getMockForModel() public
getMockForModel(string $alias, array $methods, array $options)
Mock a model, maintain fixtures and table association
Parameters
-
string
$alias The model to get a mock for.
-
string[]
$methods optional The list of methods to mock
-
array
$options optional The config data for the mock's constructor.
Returns
\Cake\ORM\Table|\PHPUnit\Framework\MockObject\MockObject
Throws
Cake\ORM\Exception\MissingTableClassException
getMockForTrait() protected
getMockForTrait(mixed $traitName, array $arguments, mixed $mockClassName, mixed $callOriginalConstructor, mixed $callOriginalClone, mixed $callAutoload, mixed $mockedMethods, mixed $cloneArguments)
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the $mockedMethods
parameter.
Parameters
-
string
$traitName -
array
$arguments optional -
string
$mockClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional -
array
$mockedMethods optional -
bool
$cloneArguments optional
getMockFromWsdl() protected
getMockFromWsdl(mixed $wsdlFile, mixed $originalClassName, mixed $mockClassName, array $methods, mixed $callOriginalConstructor, array $options)
Returns a mock object based on the given WSDL file.
Parameters
-
string
$wsdlFile -
string
$originalClassName optional -
string
$mockClassName optional -
array
$methods optional -
bool
$callOriginalConstructor optional -
array
$options optional An array of options passed to SOAPClient::_construct
getName() public
getName(bool $withDataSet)
Parameters
-
bool
$withDataSet optional
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
getNumAssertions() public
getNumAssertions()
Returns the number of assertions performed by this test.
getObjectAttribute() public static
getObjectAttribute(mixed $object, string $attributeName)
Returns the value of an object's attribute.
This also works for attributes that are declared protected or private.
Parameters
-
object
$object -
string
$attributeName
Throws
PHPUnit\Framework\Exception
getObjectForTrait() protected
getObjectForTrait(mixed $traitName, array $arguments, mixed $traitClassName, mixed $callOriginalConstructor, mixed $callOriginalClone, mixed $callAutoload)
Returns an object for the specified trait.
Parameters
-
string
$traitName -
array
$arguments optional -
string
$traitClassName optional -
bool
$callOriginalConstructor optional -
bool
$callOriginalClone optional -
bool
$callAutoload optional
Returns
object
getProvidedData() public
getProvidedData()
Gets the data set of a TestCase.
getResult() public
getResult()
getSize() public
getSize()
Returns the size of the test.
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
getStaticAttribute() public static
getStaticAttribute(string $className, string $attributeName)
Returns the value of a static attribute.
This also works for attributes that are declared protected or private.
Parameters
-
string
$className -
string
$attributeName
Throws
PHPUnit\Framework\Exception
getStatus() public
getStatus()
getStatusMessage() public
getStatusMessage()
getTableLocator() public
getTableLocator()
Gets the table locator.
Returns
\Cake\ORM\Locator\LocatorInterface
getTestResultObject() public
getTestResultObject()
greaterThan() public static
greaterThan(mixed $value)
Parameters
-
mixed
$value
greaterThanOrEqual() public static
greaterThanOrEqual(mixed $value)
Parameters
-
mixed
$value
hasDependencies() public
hasDependencies()
hasExpectationOnOutput() public
hasExpectationOnOutput()
hasFailed() public
hasFailed()
hasOutput() public
hasOutput()
hasSize() public
hasSize()
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
identicalTo() public static
identicalTo(mixed $value)
Parameters
-
mixed
$value
iniSet() protected
iniSet(string $varName, string $newValue)
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
Parameters
-
string
$varName -
string
$newValue
Throws
PHPUnit\Framework\Exception
isEmpty() public static
isEmpty()
isFalse() public static
isFalse()
isFinite() public static
isFinite()
isInIsolation() public
isInIsolation()
isInfinite() public static
isInfinite()
isInstanceOf() public static
isInstanceOf(string $className)
Parameters
-
string
$className
isJson() public static
isJson()
isLarge() public
isLarge()
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
isMedium() public
isMedium()
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
isNan() public static
isNan()
isNull() public static
isNull()
isReadable() public static
isReadable()
isSmall() public
isSmall()
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
isTrue() public static
isTrue()
isType() public static
isType(string $type)
Parameters
-
string
$type
isWritable() public static
isWritable()
lessThan() public static
lessThan(mixed $value)
Parameters
-
mixed
$value
lessThanOrEqual() public static
lessThanOrEqual(mixed $value)
Parameters
-
mixed
$value
loadFixtures() public
loadFixtures()
Chooses which fixtures to load for a given test
Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc. Passing no parameters will cause all fixtures on the test case to load.
Throws
RuntimeException
when no fixture manager is available.
See Also
loadPlugins() public
loadPlugins(array $plugins)
Load plugins into a simulated application.
Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.
Parameters
-
array
$plugins optional List of Plugins to load.
Returns
\Cake\Http\BaseApplication
loadRoutes() public
loadRoutes(?array $appArgs)
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.
logicalAnd() public static
logicalAnd()
Throws
PHPUnit\Framework\Exception
logicalNot() public static
logicalNot(\PHPUnit\Framework\Constraint\Constraint $constraint)
Parameters
-
\PHPUnit\Framework\Constraint\Constraint
$constraint
logicalOr() public static
logicalOr()
logicalXor() public static
logicalXor()
markAsRisky() public
markAsRisky()
markTestIncomplete() public static
markTestIncomplete(string $message)
Mark the test as incomplete.
Parameters
-
string
$message optional
Throws
PHPUnit\Framework\IncompleteTestError
markTestSkipped() public static
markTestSkipped(string $message)
Mark the test as skipped.
Parameters
-
string
$message optional
Throws
PHPUnit\Framework\SkippedTestError
PHPUnit\Framework\SyntheticSkippedError
matches() public static
matches(string $string)
Parameters
-
string
$string
matchesRegularExpression() public static
matchesRegularExpression(string $pattern)
Parameters
-
string
$pattern
never() public static
never()
Returns a matcher that matches when the method is never executed.
objectHasAttribute() public static
objectHasAttribute(mixed $attributeName)
Parameters
-
mixed
$attributeName
onConsecutiveCalls() public static
onConsecutiveCalls(mixed ...$args)
Parameters
-
mixed
...$args
onNotSuccessfulTest() protected
onNotSuccessfulTest(\Throwable $t)
This method is called when a test method did not execute successfully.
Parameters
-
\Throwable
$t
Throws
Throwable
once() public static
once()
Returns a matcher that matches when the method is executed exactly once.
prophesize() protected
prophesize(mixed $classOrInterface)
Parameters
-
null|string
$classOrInterface optional
Throws
Prophecy\Exception\Doubler\ClassNotFoundException
Prophecy\Exception\Doubler\DoubleException
Prophecy\Exception\Doubler\InterfaceNotFoundException
readAttribute() public static
readAttribute(mixed $classOrObject, string $attributeName)
Returns the value of an attribute of a class or an object.
This also works for attributes that are declared protected or private.
Parameters
-
object|string
$classOrObject -
string
$attributeName
Throws
PHPUnit\Framework\Exception
registerComparator() public
registerComparator(\SebastianBergmann\Comparator\Comparator $comparator)
Parameters
-
\SebastianBergmann\Comparator\Comparator
$comparator
registerMockObject() public
registerMockObject(\PHPUnit\Framework\MockObject\MockObject $mockObject)
Parameters
-
\PHPUnit\Framework\MockObject\MockObject
$mockObject
removePlugins() public
removePlugins(array $names)
Remove plugins from the global plugin collection.
Useful in test case teardown methods.
Parameters
-
string[]
$names optional A list of plugins you want to remove.
resetCount() public static
resetCount()
Reset the assertion counter.
returnArgument() public static
returnArgument(int $argumentIndex)
Parameters
-
int
$argumentIndex
returnCallback() public static
returnCallback(mixed $callback)
Parameters
-
mixed
$callback
returnSelf() public static
returnSelf()
Returns the current object.
This method is useful when mocking a fluent interface.
returnValue() public static
returnValue(mixed $value)
Parameters
-
mixed
$value
returnValueMap() public static
returnValueMap(array $valueMap)
Parameters
-
array
$valueMap
run() public
run(\PHPUnit\Framework\TestResult $result)
Runs the test case and collects the results in a TestResult object.
If no TestResult object is passed a new one will be created.
Parameters
-
\PHPUnit\Framework\TestResult
$result optional
Throws
PHPUnit\Framework\CodeCoverageException
PHPUnit\Util\Exception
SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException
SebastianBergmann\CodeCoverage\InvalidArgumentException
SebastianBergmann\CodeCoverage\MissingCoversAnnotationException
SebastianBergmann\CodeCoverage\RuntimeException
SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException
SebastianBergmann\RecursionContext\InvalidArgumentException
runBare() public
runBare()
Throws
Throwable
runTest() protected
runTest()
Override to run the test and assert its state.
Throws
PHPUnit\Framework\AssertionFailedError
PHPUnit\Framework\Exception
PHPUnit\Framework\ExpectationFailedException
SebastianBergmann\ObjectEnumerator\InvalidArgumentException
Throwable
setAppNamespace() public static
setAppNamespace(string $appNamespace)
Set the app namespace
Parameters
-
string
$appNamespace optional The app namespace, defaults to "TestApp".
Returns
string|null
The previous app namespace or null if not set.
setBackupGlobals() public
setBackupGlobals(?bool $backupGlobals)
Parameters
-
?bool
$backupGlobals
setBackupStaticAttributes() public
setBackupStaticAttributes(?bool $backupStaticAttributes)
Parameters
-
?bool
$backupStaticAttributes
setBeStrictAboutChangesToGlobalState() public
setBeStrictAboutChangesToGlobalState(?bool $beStrictAboutChangesToGlobalState)
Parameters
-
?bool
$beStrictAboutChangesToGlobalState
setDependencies() public
setDependencies(array $dependencies)
Parameters
-
string[]
$dependencies
setDependencyInput() public
setDependencyInput(array $dependencyInput)
Parameters
-
array
$dependencyInput
setGroups() public
setGroups(array $groups)
Parameters
-
array
$groups
setInIsolation() public
setInIsolation(bool $inIsolation)
Parameters
-
bool
$inIsolation
setLocale() protected
setLocale(mixed ...$args)
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
Parameters
-
mixed
...$args
Throws
PHPUnit\Framework\Exception
setName() public
setName(string $name)
Parameters
-
string
$name
setOutputCallback() public
setOutputCallback(callable $callback)
Parameters
-
callable
$callback
setPreserveGlobalState() public
setPreserveGlobalState(bool $preserveGlobalState)
Parameters
-
bool
$preserveGlobalState
setRegisterMockObjectsFromTestArgumentsRecursively() public
setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag)
Parameters
-
bool
$flag
setResult() public
setResult(mixed $result)
Parameters
-
mixed
$result
setRunClassInSeparateProcess() public
setRunClassInSeparateProcess(bool $runClassInSeparateProcess)
Parameters
-
bool
$runClassInSeparateProcess
setRunTestInSeparateProcess() public
setRunTestInSeparateProcess(bool $runTestInSeparateProcess)
Parameters
-
bool
$runTestInSeparateProcess
setTableLocator() public
setTableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator)
Sets the table locator.
Parameters
-
\Cake\ORM\Locator\LocatorInterface
$tableLocator LocatorInterface instance.
Returns
$this
setTestResultObject() public
setTestResultObject(\PHPUnit\Framework\TestResult $result)
Parameters
-
\PHPUnit\Framework\TestResult
$result
setUp() public
setUp()
Setup the test case, backup the static object values so they can be restored.
Specifically backs up the contents of Configure and paths in App if they have not already been backed up.
setUpBeforeClass() public static
setUpBeforeClass()
This method is called before the first test of this test class is run.
setUseErrorHandler() public
setUseErrorHandler(bool $useErrorHandler)
Parameters
-
bool
$useErrorHandler
skipIf() public
skipIf(bool $shouldSkip, string $message)
Overrides SimpleTestCase::skipIf to provide a boolean return value
Parameters
-
bool
$shouldSkip Whether or not the test should be skipped.
-
string
$message optional The message to display.
Returns
bool
skipUnless() protected
skipUnless(mixed $condition, mixed $message)
Compatibility function for skipping.
Parameters
-
bool
$condition Condition to trigger skipping
-
string
$message optional Message for skip
Returns
bool
stringContains() public static
stringContains(string $string, bool $case)
Parameters
-
string
$string -
bool
$case optional
stringEndsWith() public static
stringEndsWith(string $suffix)
Parameters
-
string
$suffix
stringStartsWith() public static
stringStartsWith(mixed $prefix)
Parameters
-
mixed
$prefix
tearDown() public
tearDown()
teardown any static object changes and restore them.
tearDownAfterClass() public static
tearDownAfterClass()
This method is called after the last test of this test class is run.
throwException() public static
throwException(\Throwable $exception)
Parameters
-
\Throwable
$exception
toString() public
toString()
Returns a string representation of the test case.
Throws
SebastianBergmann\RecursionContext\InvalidArgumentException
PHPUnit\Framework\Exception
usesDataProvider() public
usesDataProvider()
withErrorReporting() public
withErrorReporting(int $errorLevel, callable $callable)
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
Property Detail
$_configure protected
Configure values to restore at end of test.
Type
array
$_tableLocator protected
Table locator instance
Type
\Cake\ORM\Locator\LocatorInterface|null
$autoFixtures public
By default, all fixtures attached to this class will be truncated and reloaded after each test.
Set this to false to handle manually
Type
bool
$backupGlobals protected
Type
?bool
$backupGlobalsBlacklist protected
Type
string[]
$backupStaticAttributes protected
Type
bool
$backupStaticAttributesBlacklist protected
Type
array<string,array<int,string>>
$dropTables public
Control table create/drops on each test method.
If true, tables will still be dropped at the end of each test runner execution.
Type
bool
$fixtureManager public
The class responsible for managing the creation, loading and removing of fixtures
Type
\Cake\TestSuite\Fixture\FixtureManager|null
$fixtures protected
Fixtures used by this test case.
Type
string[]
$preserveGlobalState protected
Type
bool
$runTestInSeparateProcess protected
Type
bool
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.TestSuite.TestCase.html