Cake TestCase class
arrayConfigure values to restore at end of test.
Cake\ORM\Locator\LocatorInterface|nullTable locator instance
boolBy default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
?boolstring[]string[]boolarray<string, array<int, string>>array<string, array<int, string>>string|nullThis object's default table alias.
boolControl table create/drops on each test method.
Cake\TestSuite\Fixture\FixtureManager|nullThe class responsible for managing the creation, loading and removing of fixtures
Cake\TestSuite\Fixture\FixtureStrategyInterface|nullarray<string>Fixtures used by this test case.
boollist<ExecutionOrderDependency>boolCheck the attributes as part of an assertTags() check.
Gets the class name for the table.
Normalize a path for comparison.
Adds a fixture to this test case.
Returns a matcher that matches when the method is executed zero or more times.
Asserts that an array has a specified key.
Asserts that an array does not have a specified key.
Asserts that a class has a specified attribute.
Asserts that a class has a specified static attribute.
Asserts that a class does not have a specified attribute.
Asserts that a class does not have a specified static attribute.
Asserts that a haystack contains a needle.
Asserts that a haystack contains only values of a given type.
Asserts that a haystack contains only instances of a given class name.
Asserts the number of elements of an array, Countable or Traversable.
Asserts that a directory does not exist.
Asserts that a directory exists.
Asserts that a directory exists and is not readable.
Asserts that a directory exists and is not writable.
Asserts that a directory exists and is readable.
Asserts that a directory exists and is writable.
Asserts that a directory does not exist.
Asserts that a directory exists and is not readable.
Asserts that a directory exists and is not writable.
Asserts that a string does not match a given regular expression.
Asserts that a variable is empty.
Asserts that a hierarchy of DOMElements matches.
Asserts that two variables are equal.
Asserts that two variables are equal (canonicalizing).
Asserts that two variables are equal (ignoring case).
Assert that a string matches SQL with db-specific characters like quotes removed.
Asserts that two variables are equal (with delta).
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
Asserts an event was fired with data
Asserts that a condition is false.
Asserts that a file does not exist.
Asserts that the contents of one file is equal to the contents of another file.
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
Asserts that a file exists.
Asserts that a file exists and is not readable.
Asserts that a file exists and is not writable.
Asserts that a file exists and is readable.
Asserts that a file exists and is writable.
Asserts that the contents of one file is not equal to the contents of another file.
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
Asserts that a file does not exist.
Asserts that a file exists and is not readable.
Asserts that a file exists and is not writable.
Asserts that a variable is finite.
Asserts that a value is greater than another value.
Asserts that a value is greater than or equal to another value.
Asserts HTML tags.
Asserts that a variable is infinite.
Asserts that a variable is of a given type.
Asserts that a variable is of type array.
Asserts that a variable is of type bool.
Asserts that a variable is of type callable.
Asserts that a variable is of type resource and is closed.
Asserts that a variable is of type float.
Asserts that a variable is of type int.
Asserts that a variable is of type iterable.
Asserts that a variable is not of type array.
Asserts that a variable is not of type bool.
Asserts that a variable is not of type callable.
Asserts that a variable is not of type resource.
Asserts that a variable is not of type float.
Asserts that a variable is not of type int.
Asserts that a variable is not of type iterable.
Asserts that a variable is not of type numeric.
Asserts that a variable is not of type object.
Asserts that a file/dir exists and is not readable.
Asserts that a variable is not of type resource.
Asserts that a variable is not of type scalar.
Asserts that a variable is not of type string.
Asserts that a file/dir exists and is not writable.
Asserts that a variable is of type numeric.
Asserts that a variable is of type object.
Asserts that a file/dir is readable.
Asserts that a variable is of type resource.
Asserts that a variable is of type scalar.
Asserts that a variable is of type string.
Asserts that a file/dir exists and is writable.
Asserts that a string is a valid JSON string.
Asserts that two JSON files are equal.
Asserts that two JSON files are not equal.
Asserts that the generated JSON encoded object and the content of the given file are equal.
Asserts that two given JSON encoded objects or arrays are equal.
Asserts that the generated JSON encoded object and the content of the given file are not equal.
Asserts that two given JSON encoded objects or arrays are not equal.
Asserts that a value is smaller than another value.
Asserts that a value is smaller than or equal to another value.
Asserts that a string matches a given regular expression.
Asserts that a variable is nan.
Asserts that a haystack does not contain a needle.
Asserts that a haystack does not contain only values of a given type.
Asserts the number of elements of an array, Countable or Traversable.
Asserts that a variable is not empty.
Asserts that two variables are not equal.
Asserts that two variables are not equal (canonicalizing).
Asserts that two variables are not equal (ignoring case).
Asserts that two variables are not equal (with delta).
Asserts that a condition is not false.
Asserts that a variable is not of a given type.
Asserts that a file/dir exists and is not readable.
Asserts that a file/dir exists and is not writable.
Asserts that a variable is not null.
Asserts that a string does not match a given regular expression.
Asserts that two variables do not have the same type and value. Used on objects, it asserts that two variables do not reference the same object.
Assert that the size of two arrays (or Countable or Traversable objects) is not the same.
Asserts that a condition is not true.
Compatibility function to test if a value is not between an acceptable range.
Asserts that a variable is null.
Asserts that an object has a specified attribute.
Asserts that an object does not have a specified attribute.
Compatibility function to test paths.
Performs assertions shared by all tests of a test case.
Performs assertions shared by all tests of a test case.
Asserts that a string matches a given regular expression.
Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters < and >. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries
Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.
Assert that the size of two arrays (or Countable or Traversable objects) is the same.
Asserts that a string ends not with a given suffix.
Asserts that a string ends with a given suffix.
Asserts that the contents of a string is equal to the contents of a file.
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
Asserts that a string matches a given format string.
Asserts that a string matches a given format file.
Asserts that the contents of a string is not equal to the contents of a file.
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
Asserts that a string does not match a given format string.
Asserts that a string does not match a given format string.
Asserts that a string starts not with a given prefix.
Asserts that a string starts with a given prefix.
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Evaluates a PHPUnit\Framework\Constraint matcher object.
Asserts that a condition is true.
Compatibility function to test if a value is between an acceptable range.
Asserts that two XML files are equal.
Asserts that two XML files are not equal.
Asserts that two XML documents are equal.
Asserts that two XML documents are equal.
Asserts that two XML documents are not equal.
Asserts that two XML documents are not equal.
Returns a matcher that matches when the method is executed at the given index.
Returns a matcher that matches when the method is executed at least N times.
Returns a matcher that matches when the method is executed at least once.
Returns a matcher that matches when the method is executed at most N times.
Clear all plugins from the global plugin collection.
Returns a configured mock object for the specified class.
Returns a mock object for the specified class.
Returns a partial mock object for the specified class.
Creates a default TestResult object.
Makes configurable stub for the specified class.
Returns a test proxy for the specified class.
Helper method for check deprecation methods
Returns a matcher that matches when the method is executed exactly $count times.
Sets up an expectation for an exception to be raised by the code under test. Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.
Fails a test with the given message.
Convenience method to get a table instance.
Return the current assertion count.
Returns fixture strategy used by these tests.
Get the fixtures this test should use.
Returns a builder object to create mock objects using a fluent interface.
Mocks the specified class and returns the name of the mocked class.
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default. To mock concrete methods, use the 7th parameter ($mockedMethods).
Mock a model, maintain fixtures and table association
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the $mockedMethods parameter.
Returns a mock object based on the given WSDL file.
Returns the number of assertions performed by this test.
Returns an object for the specified trait.
Gets the data set of a TestCase.
Returns the size of the test.
Gets the table locator.
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
Chooses which fixtures to load for a given test
Load plugins into a simulated application.
Load routes for the application.
Mark the test as incomplete.
Mark the test as skipped.
Returns a matcher that matches when the method is never executed.
This method is called when a test method did not execute successfully.
Returns a matcher that matches when the method is executed exactly once.
Returns the normalized test name as class::method.
Remove plugins from the global plugin collection.
Returns a list of normalized dependency names, class::method.
Reset the assertion counter.
Returns the current object.
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.
Override to run the test and assert its state.
Set the app namespace
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
Sets the table locator.
Setup the test case, backup the static object values so they can be restored. Specifically backs up the contents of Configure and paths in App if they have not already been backed up.
This method is called before the first test of this test class is run.
Initialized and loads any use fixtures.
Overrides SimpleTestCase::skipIf to provide a boolean return value
Compatibility function for skipping.
teardown any static object changes and restore them.
This method is called after the last test of this test class is run.
Unloads any use fixtures.
Returns a string representation of the test case.
Helper method for tests that needs to use error_reporting()
__construct(?string $name = null, array $data = [], int|string $dataName = '')
?string $name optional array $data optional int|string $dataName optional _assertAttributes(array<string, mixed> $assertions, string $string, bool $fullDebug = false, array|string $regex = ''): string|false
Check the attributes as part of an assertTags() check.
array<string, mixed> $assertions Assertions to run.
string $string The HTML string to check.
bool $fullDebug optional Whether more verbose output should be used.
array|string $regex optional Full regexp from assertHtml
string|false_getTableClassName(string $alias, array<string, mixed> $options): string
Gets the class name for the table.
string $alias The model to get a mock for.
array<string, mixed> $options The config data for the mock's constructor.
stringCake\ORM\Exception\MissingTableClassException_normalizePath(string $path): string
Normalize a path for comparison.
string $path Path separated by "/" slash.
stringaddFixture(string $fixture): $this
Adds a fixture to this test case.
Examples:
Use this method inside your test cases' {@link getFixtures()} method to build up the fixture list.
string $fixture Fixture
$thisaddToAssertionCount(int $count): void
int $count voidaddWarning(string $warning): void
string $warning voidany(): AnyInvokedCountMatcher
Returns a matcher that matches when the method is executed zero or more times.
AnyInvokedCountMatcheranything(): IsAnything
IsAnythingarrayHasKey(int|string $key): ArrayHasKey
int|string $key ArrayHasKeyassertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
Asserts that an array has a specified key.
int|string $key array|ArrayAccess $array string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void
Asserts that an array does not have a specified key.
int|string $key array|ArrayAccess $array string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassHasAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class has a specified attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class has a specified static attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class does not have a specified attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
Asserts that a class does not have a specified static attribute.
string $attributeName string $className string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertContains(mixed $needle, iterable $haystack, string $message = ''): void
Asserts that a haystack contains a needle.
iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
iterable $haystack string $message optional voidassertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack contains only values of a given type.
string $type iterable $haystack ?bool $isNativeType optional string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void
Asserts that a haystack contains only instances of a given class name.
string $className iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
int $expectedCount Countable|iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertDirectoryDoesNotExist(string $directory, string $message = ''): void
Asserts that a directory does not exist.
string $directory Directory
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertDirectoryExists(string $directory, string $message = ''): void
Asserts that a directory exists.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsNotReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsNotWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is readable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is writable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryNotExists(string $directory, string $message = ''): void
Asserts that a directory does not exist.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryNotIsReadable(string $directory, string $message = ''): void
Asserts that a directory exists and is not readable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDirectoryNotIsWritable(string $directory, string $message = ''): void
Asserts that a directory exists and is not writable.
string $directory string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void
Asserts that a string does not match a given regular expression.
string $pattern Regex pattern
string $string String to test
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is empty.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void
Asserts that a hierarchy of DOMElements matches.
DOMElement $expectedElement DOMElement $actualElement bool $checkAttributes optional string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionAssertionFailedErrorExpectationFailedExceptionassertEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (canonicalizing).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are equal (ignoring case).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEqualsSql(string $expected, string $actual, string $message = ''): void
Assert that a string matches SQL with db-specific characters like quotes removed.
string $expected The expected sql
string $actual The sql to compare
string $message optional The message to display on failure
voidassertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are equal (with delta).
float $delta string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertEventFired(string $name, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
string $name Event name
Cake\Event\EventManager|null $eventManager optional Event manager to check, defaults to global event manager
string $message optional Assertion failure message
voidassertEventFiredWith(string $name, string $dataKey, mixed $dataValue, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void
Asserts an event was fired with data
If a third argument is passed, that value is used to compare with the value in $dataKey
string $name Event name
string $dataKey Data key
mixed $dataValue Data value
Cake\Event\EventManager|null $eventManager optional Event manager to check, defaults to global event manager
string $message optional Assertion failure message
voidassertFalse(mixed $condition, string $message = ''): void
Asserts that a condition is false.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileDoesNotExist(string $filename, string $message = ''): void
Asserts that a file does not exist.
string $filename Filename
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertFileEquals(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file.
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileExists(string $filename, string $message = ''): void
Asserts that a file exists.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsNotReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsNotWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is readable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is writable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotEquals(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file.
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void
Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
string $expected string $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotExists(string $filename, string $message = ''): void
Asserts that a file does not exist.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotIsReadable(string $file, string $message = ''): void
Asserts that a file exists and is not readable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFileNotIsWritable(string $file, string $message = ''): void
Asserts that a file exists and is not writable.
string $file string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertFinite(mixed $actual, string $message = ''): void
Asserts that a variable is finite.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertGreaterThan(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is greater than another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is greater than or equal to another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertHtml(array $expected, string $string, bool $fullDebug = false): bool
Asserts HTML tags.
Takes an array $expected and generates a regex from it to match the provided $string. Samples for $expected:
Checks for an input tag with a name attribute (contains any non-empty value) and an id attribute that contains 'my-input':
['input' => ['name', 'id' => 'my-input']]
Checks for two p elements with some text in them:
[ ['p' => true], 'textA', '/p', ['p' => true], 'textB', '/p' ]
You can also specify a pattern expression as part of the attribute values, or the tag being defined, if you prepend the value with preg: and enclose it with slashes, like so:
[ ['input' => ['name', 'id' => 'preg:/FieldName\d+/']], 'preg:/My\s+field/' ]
Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order. It will also allow whitespace between specified tags.
array $expected An array, see above
string $string An HTML/XHTML/XML string
bool $fullDebug optional Whether more verbose output should be used.
boolassertInfinite(mixed $actual, string $message = ''): void
Asserts that a variable is infinite.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertInstanceOf(string $expected, mixed $actual, string $message = ''): void
Asserts that a variable is of a given type.
string $expected string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertIsArray(mixed $actual, string $message = ''): void
Asserts that a variable is of type array.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsBool(mixed $actual, string $message = ''): void
Asserts that a variable is of type bool.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsCallable(mixed $actual, string $message = ''): void
Asserts that a variable is of type callable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource and is closed.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsFloat(mixed $actual, string $message = ''): void
Asserts that a variable is of type float.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsInt(mixed $actual, string $message = ''): void
Asserts that a variable is of type int.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsIterable(mixed $actual, string $message = ''): void
Asserts that a variable is of type iterable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotArray(mixed $actual, string $message = ''): void
Asserts that a variable is not of type array.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotBool(mixed $actual, string $message = ''): void
Asserts that a variable is not of type bool.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotCallable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type callable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotClosedResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotFloat(mixed $actual, string $message = ''): void
Asserts that a variable is not of type float.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotInt(mixed $actual, string $message = ''): void
Asserts that a variable is not of type int.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotIterable(mixed $actual, string $message = ''): void
Asserts that a variable is not of type iterable.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is not of type numeric.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotObject(mixed $actual, string $message = ''): void
Asserts that a variable is not of type object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotReadable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not readable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotResource(mixed $actual, string $message = ''): void
Asserts that a variable is not of type resource.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotScalar(mixed $actual, string $message = ''): void
Asserts that a variable is not of type scalar.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotString(mixed $actual, string $message = ''): void
Asserts that a variable is not of type string.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNotWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not writable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsNumeric(mixed $actual, string $message = ''): void
Asserts that a variable is of type numeric.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsObject(mixed $actual, string $message = ''): void
Asserts that a variable is of type object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir is readable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsResource(mixed $actual, string $message = ''): void
Asserts that a variable is of type resource.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsScalar(mixed $actual, string $message = ''): void
Asserts that a variable is of type scalar.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsString(mixed $actual, string $message = ''): void
Asserts that a variable is of type string.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is writable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJson(string $actualJson, string $message = ''): void
Asserts that a string is a valid JSON string.
string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two JSON files are equal.
string $expectedFile string $actualFile string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two JSON files are not equal.
string $expectedFile string $actualFile string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
Asserts that the generated JSON encoded object and the content of the given file are equal.
string $expectedFile string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
Asserts that two given JSON encoded objects or arrays are equal.
string $expectedJson string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
Asserts that the generated JSON encoded object and the content of the given file are not equal.
string $expectedFile string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
Asserts that two given JSON encoded objects or arrays are not equal.
string $expectedJson string $actualJson string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertLessThan(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is smaller than another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertLessThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void
Asserts that a value is smaller than or equal to another value.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
Asserts that a string matches a given regular expression.
string $pattern Regex pattern
string $string String to test
string $message optional Message
voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionassertNan(mixed $actual, string $message = ''): void
Asserts that a variable is nan.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotContains(mixed $needle, iterable $haystack, string $message = ''): void
Asserts that a haystack does not contain a needle.
iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void
iterable $haystack string $message optional voidassertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
Asserts that a haystack does not contain only values of a given type.
string $type iterable $haystack ?bool $isNativeType optional string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void
Asserts the number of elements of an array, Countable or Traversable.
int $expectedCount Countable|iterable $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotEmpty(mixed $actual, string $message = ''): void
Asserts that a variable is not empty.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEquals(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (canonicalizing).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables are not equal (ignoring case).
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void
Asserts that two variables are not equal (with delta).
float $delta string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotFalse(mixed $condition, string $message = ''): void
Asserts that a condition is not false.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotInstanceOf(string $expected, mixed $actual, string $message = ''): void
Asserts that a variable is not of a given type.
string $expected string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotIsReadable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not readable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotIsWritable(string $filename, string $message = ''): void
Asserts that a file/dir exists and is not writable.
string $filename string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotNull(mixed $actual, string $message = ''): void
Asserts that a variable is not null.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotRegExp(string $pattern, string $string, string $message = ''): void
Asserts that a string does not match a given regular expression.
string $pattern string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotSame(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables do not have the same type and value. Used on objects, it asserts that two variables do not reference the same object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
Assert that the size of two arrays (or Countable or Traversable objects) is not the same.
Countable|iterable $expected Countable|iterable $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertNotTrue(mixed $condition, string $message = ''): void
Asserts that a condition is not true.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertNotWithinRange(float $expected, float $result, float $margin, string $message = ''): void
Compatibility function to test if a value is not between an acceptable range.
float $expected float $result float $margin the rage of acceptation
string $message optional the text to display if the assertion is not correct
voidassertNull(mixed $actual, string $message = ''): void
Asserts that a variable is null.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertObjectEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void
object $expected object $actual string $method optional string $message optional voidExpectationFailedExceptionassertObjectHasAttribute(string $attributeName, object $object, string $message = ''): void
Asserts that an object has a specified attribute.
string $attributeName object $object string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertObjectNotHasAttribute(string $attributeName, object $object, string $message = ''): void
Asserts that an object does not have a specified attribute.
string $attributeName object $object string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertPathEquals(string $expected, string $result, string $message = ''): void
Compatibility function to test paths.
string $expected string $result string $message optional the text to display if the assertion is not correct
voidassertPostConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between test and tearDown().
voidassertPreConditions(): void
Performs assertions shared by all tests of a test case.
This method is called between setUp() and test.
voidassertRegExp(string $pattern, string $string, string $message = ''): void
Asserts that a string matches a given regular expression.
string $pattern string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertRegExpSql(string $pattern, string $actual, bool $optional = false): void
Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters < and >. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries
string $pattern The expected sql pattern
string $actual The sql to compare
bool $optional optional Whether quote characters (marked with <>) are optional
voidassertSame(mixed $expected, mixed $actual, string $message = ''): void
Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void
Assert that the size of two arrays (or Countable or Traversable objects) is the same.
Countable|iterable $expected Countable|iterable $actual string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertStringContainsString(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEndsNotWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends not with a given suffix.
string $suffix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEndsWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends with a given suffix.
string $suffix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file.
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringMatchesFormat(string $format, string $string, string $message = ''): void
Asserts that a string matches a given format string.
string $format string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
Asserts that a string matches a given format file.
string $formatFile string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
string $needle string $haystack string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file.
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
string $expectedFile string $actualString string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
Asserts that a string does not match a given format string.
string $format string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void
Asserts that a string does not match a given format string.
string $formatFile string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringStartsNotWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts not with a given prefix.
string $prefix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertStringStartsWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts with a given prefix.
string $prefix string $string string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertTextContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $needle The string to search for.
string $haystack The string to search through.
string $message optional The message to display on failure.
bool $ignoreCase optional Whether the search should be case-sensitive.
voidassertTextEndsNotWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $suffix The suffix to not find.
string $string The string to search.
string $message optional The message to use for failure.
voidassertTextEndsWith(string $suffix, string $string, string $message = ''): void
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $suffix The suffix to find.
string $string The string to search.
string $message optional The message to use for failure.
voidassertTextEquals(string $expected, string $result, string $message = ''): void
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $expected The expected value.
string $result The actual value.
string $message optional The message to use for failure.
voidassertTextNotContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $needle The string to search for.
string $haystack The string to search through.
string $message optional The message to display on failure.
bool $ignoreCase optional Whether the search should be case-sensitive.
voidassertTextNotEquals(string $expected, string $result, string $message = ''): void
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $expected The expected value.
string $result The actual value.
string $message optional The message to use for failure.
voidassertTextStartsNotWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $prefix The prefix to not find.
string $string The string to search.
string $message optional The message to use for failure.
voidassertTextStartsWith(string $prefix, string $string, string $message = ''): void
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
string $prefix The prefix to check for.
string $string The string to search in.
string $message optional The message to use for failure.
voidassertThat(mixed $value, Constraint $constraint, string $message = ''): void
Evaluates a PHPUnit\Framework\Constraint matcher object.
Constraint $constraint string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertTrue(mixed $condition, string $message = ''): void
Asserts that a condition is true.
string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertWithinRange(float $expected, float $result, float $margin, string $message = ''): void
Compatibility function to test if a value is between an acceptable range.
float $expected float $result float $margin the rage of acceptation
string $message optional the text to display if the assertion is not correct
voidassertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two XML files are equal.
string $expectedFile string $actualFile string $message optional voidSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionExpectationFailedExceptionassertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
Asserts that two XML files are not equal.
string $expectedFile string $actualFile string $message optional voidPHPUnit\Util\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
string $expectedFile DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are equal.
DOMDocument|string $expectedXml DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringNotEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
string $expectedFile DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionassertXmlStringNotEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void
Asserts that two XML documents are not equal.
DOMDocument|string $expectedXml DOMDocument|string $actualXml string $message optional voidPHPUnit\Util\Xml\ExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionExpectationFailedExceptionat(int $index): InvokedAtIndexMatcher
Returns a matcher that matches when the method is executed at the given index.
int $index InvokedAtIndexMatcheratLeast(int $requiredInvocations): InvokedAtLeastCountMatcher
Returns a matcher that matches when the method is executed at least N times.
int $requiredInvocations InvokedAtLeastCountMatcheratLeastOnce(): InvokedAtLeastOnceMatcher
Returns a matcher that matches when the method is executed at least once.
InvokedAtLeastOnceMatcheratMost(int $allowedInvocations): InvokedAtMostCountMatcher
Returns a matcher that matches when the method is executed at most N times.
int $allowedInvocations InvokedAtMostCountMatchercallback(callable $callback): Callback
callable $callback CallbackclassHasAttribute(string $attributeName): ClassHasAttribute
string $attributeName ClassHasAttributeclassHasStaticAttribute(string $attributeName): ClassHasStaticAttribute
string $attributeName ClassHasStaticAttributeclearPlugins(): void
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
voidcontainsEqual(mixed $value): TraversableContainsEqual
TraversableContainsEqualcontainsIdentical(mixed $value): TraversableContainsIdentical
TraversableContainsIdenticalcontainsOnly(string $type): TraversableContainsOnly
string $type TraversableContainsOnlycontainsOnlyInstancesOf(string $className): TraversableContainsOnly
string $className TraversableContainsOnlycount(): int
intcountOf(int $count): Count
int $count CountcreateConfiguredMock(string $originalClassName, array $configuration): MockObject
Returns a configured mock object for the specified class.
string $originalClassName array $configuration MockObjectcreateMock(string $originalClassName): MockObject
Returns a mock object for the specified class.
string $originalClassName MockObjectcreatePartialMock(string $originalClassName, string[] $methods): MockObject
Returns a partial mock object for the specified class.
string $originalClassName string[] $methods MockObjectcreateResult(): TestResult
Creates a default TestResult object.
TestResultcreateStub(string $originalClassName): Stub
Makes configurable stub for the specified class.
string $originalClassName StubcreateTestProxy(string $originalClassName, array $constructorArguments = []): MockObject
Returns a test proxy for the specified class.
string $originalClassName array $constructorArguments optional MockObjectdataName(): int|string
int|stringdeprecated(callable $callable): void
Helper method for check deprecation methods
callable $callable callable function that will receive asserts
voiddirectoryExists(): DirectoryExists
DirectoryExistsdoesNotPerformAssertions(): bool
booldoubledTypes(): string[]
string[]equalTo(mixed $value): IsEqual
IsEqualequalToCanonicalizing(mixed $value): IsEqualCanonicalizing
IsEqualCanonicalizingequalToIgnoringCase(mixed $value): IsEqualIgnoringCase
IsEqualIgnoringCaseequalToWithDelta(mixed $value, float $delta): IsEqualWithDelta
float $delta IsEqualWithDeltaexactly(int $count): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly $count times.
int $count InvokedCountMatcherexpectDeprecation(): void
voidexpectDeprecationMessage(string $message): void
string $message voidexpectDeprecationMessageMatches(string $regularExpression): void
string $regularExpression voidexpectError(): void
voidexpectErrorMessage(string $message): void
string $message voidexpectErrorMessageMatches(string $regularExpression): void
string $regularExpression voidexpectException(string $exception): void
string $exception voidexpectExceptionCode(int|string $code): void
int|string $code voidexpectExceptionMessage(string $message): void
string $message voidexpectExceptionMessageMatches(string $regularExpression): void
string $regularExpression voidexpectExceptionObject(Exception $exception): void
Sets up an expectation for an exception to be raised by the code under test. Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.
Exception $exception voidexpectNotToPerformAssertions(): void
voidexpectNotice(): void
voidexpectNoticeMessage(string $message): void
string $message voidexpectNoticeMessageMatches(string $regularExpression): void
string $regularExpression voidexpectOutputRegex(string $expectedRegex): void
string $expectedRegex voidexpectOutputString(string $expectedString): void
string $expectedString voidexpectWarning(): void
voidexpectWarningMessage(string $message): void
string $message voidexpectWarningMessageMatches(string $regularExpression): void
string $regularExpression voidfail(string $message = ''): void
Fails a test with the given message.
string $message optional voidAssertionFailedErrorfetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table
Convenience method to get a table instance.
string|null $alias optional The alias name you want to get. Should be in CamelCase format. If null then the value of $defaultTable property is used.
array<string, mixed> $options optional The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Cake\ORM\TableCake\Core\Exception\CakeExceptionfileExists(): FileExists
FileExistsgetActualOutput(): string
stringgetActualOutputForAssertion(): string
stringgetCount(): int
Return the current assertion count.
intgetDataSetAsString(bool $includeData = true): string
bool $includeData optional stringgetExpectedException(): ?string
?stringgetExpectedExceptionCode(): null|int|string
null|int|stringgetExpectedExceptionMessage(): ?string
?stringgetExpectedExceptionMessageRegExp(): ?string
?stringgetFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface
Returns fixture strategy used by these tests.
Cake\TestSuite\Fixture\FixtureStrategyInterfacegetFixtures(): array<string>
Get the fixtures this test should use.
array<string>getGroups(): array
arraygetMockBuilder(string $className): MockBuilder
Returns a builder object to create mock objects using a fluent interface.
string $className MockBuildergetMockClass(string $originalClassName, null|array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = false, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = false): string
Mocks the specified class and returns the name of the mocked class.
string $originalClassName null|array $methods optional $methods
array $arguments optional string $mockClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional bool $cloneArguments optional stringgetMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default. To mock concrete methods, use the 7th parameter ($mockedMethods).
string $originalClassName array $arguments optional string $mockClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional array $mockedMethods optional bool $cloneArguments optional MockObjectgetMockForModel(string $alias, array<string> $methods = [], array<string, mixed> $options = []): Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject
Mock a model, maintain fixtures and table association
string $alias The model to get a mock for.
array<string> $methods optional The list of methods to mock
array<string, mixed> $options optional The config data for the mock's constructor.
Cake\ORM\TablePHPUnit\Framework\MockObject\MockObjectCake\ORM\Exception\MissingTableClassExceptiongetMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject
Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the $mockedMethods parameter.
string $traitName array $arguments optional string $mockClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional array $mockedMethods optional bool $cloneArguments optional MockObjectgetMockFromWsdl(string $wsdlFile, string $originalClassName = '', string $mockClassName = '', array $methods = [], bool $callOriginalConstructor = true, array $options = []): MockObject
Returns a mock object based on the given WSDL file.
string $wsdlFile string $originalClassName optional string $mockClassName optional array $methods optional bool $callOriginalConstructor optional array $options optional MockObjectgetName(bool $withDataSet = true): string
bool $withDataSet optional stringSebastianBergmann\RecursionContext\InvalidArgumentExceptiongetNumAssertions(): int
Returns the number of assertions performed by this test.
intgetObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true): object
Returns an object for the specified trait.
string $traitName array $arguments optional string $traitClassName optional bool $callOriginalConstructor optional bool $callOriginalClone optional bool $callAutoload optional objectgetProvidedData(): array
Gets the data set of a TestCase.
arraygetResult()
getSize(): int
Returns the size of the test.
intSebastianBergmann\RecursionContext\InvalidArgumentExceptiongetStatus(): int
intgetStatusMessage(): string
stringgetTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Cake\ORM\Locator\LocatorInterfacegetTestResultObject(): ?TestResult
?TestResultgreaterThan(mixed $value): GreaterThan
GreaterThangreaterThanOrEqual(mixed $value): LogicalOr
LogicalOrhasExpectationOnOutput(): bool
boolhasFailed(): bool
boolhasOutput(): bool
boolhasSize(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionidenticalTo(mixed $value): IsIdentical
IsIdenticaliniSet(string $varName, string $newValue): void
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
string $varName string $newValue voidExceptionisEmpty(): IsEmpty
IsEmptyisFalse(): IsFalse
IsFalseisFinite(): IsFinite
IsFiniteisInIsolation(): bool
boolisInfinite(): IsInfinite
IsInfiniteisInstanceOf(string $className): IsInstanceOf
string $className IsInstanceOfisJson(): IsJson
IsJsonisLarge(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionisMedium(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionisNan(): IsNan
IsNanisNull(): IsNull
IsNullisReadable(): IsReadable
IsReadableisSmall(): bool
boolSebastianBergmann\RecursionContext\InvalidArgumentExceptionisTrue(): IsTrue
IsTrueisType(string $type): IsType
string $type IsTypeisWritable(): IsWritable
IsWritablelessThan(mixed $value): LessThan
LessThanlessThanOrEqual(mixed $value): LogicalOr
LogicalOrloadFixtures(): void
Chooses which fixtures to load for a given test
Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc. Passing no parameters will cause all fixtures on the test case to load.
voidRuntimeExceptionloadPlugins(array<string, mixed> $plugins = []): Cake\Http\BaseApplication
Load plugins into a simulated application.
Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.
array<string, mixed> $plugins optional List of Plugins to load.
Cake\Http\BaseApplicationloadRoutes(array|null $appArgs = null): void
Load routes for the application.
If no application class can be found an exception will be raised. Routes for plugins will not be loaded. Use loadPlugins() or use Cake\TestSuite\IntegrationTestCaseTrait to better simulate all routes and plugins being loaded.
array|null $appArgs optional Constructor parameters for the application class.
voidlogicalAnd(): LogicalAnd
LogicalAndExceptionlogicalNot(Constraint $constraint): LogicalNot
Constraint $constraint LogicalNotlogicalOr(): LogicalOr
LogicalOrlogicalXor(): LogicalXor
LogicalXormarkAsRisky(): void
voidmarkTestIncomplete(string $message = ''): void
Mark the test as incomplete.
string $message optional voidIncompleteTestErrormarkTestSkipped(string $message = ''): void
Mark the test as skipped.
string $message optional voidSkippedTestErrorSyntheticSkippedErrormatches(string $string): StringMatchesFormatDescription
string $string StringMatchesFormatDescriptionmatchesRegularExpression(string $pattern): RegularExpression
string $pattern RegularExpressionnever(): InvokedCountMatcher
Returns a matcher that matches when the method is never executed.
InvokedCountMatcherobjectEquals(object $object, string $method = 'equals'): ObjectEquals
object $object string $method optional ObjectEqualsobjectHasAttribute(mixed $attributeName): ObjectHasAttribute
ObjectHasAttributeonConsecutiveCalls(mixed ...$args): ConsecutiveCallsStub
ConsecutiveCallsStubonNotSuccessfulTest(Throwable $t): void
This method is called when a test method did not execute successfully.
Throwable $t voidThrowableonce(): InvokedCountMatcher
Returns a matcher that matches when the method is executed exactly once.
InvokedCountMatcherprophesize(?string $classOrInterface = null): ObjectProphecy
?string $classOrInterface optional ObjectProphecyProphecy\Exception\Doubler\ClassNotFoundExceptionProphecy\Exception\Doubler\DoubleExceptionProphecy\Exception\Doubler\InterfaceNotFoundExceptionprovides(): list<ExecutionOrderDependency>
Returns the normalized test name as class::method.
list<ExecutionOrderDependency>recordDoubledType(string $originalClassName): void
string $originalClassName voidregisterComparator(Comparator $comparator): void
Comparator $comparator voidregisterMockObject(MockObject $mockObject): void
MockObject $mockObject voidremovePlugins(array<string> $names = []): void
Remove plugins from the global plugin collection.
Useful in test case teardown methods.
array<string> $names optional A list of plugins you want to remove.
voidrequires(): list<ExecutionOrderDependency>
Returns a list of normalized dependency names, class::method.
This list can differ from the raw dependencies as the resolver has no need for the [!][shallow]clone prefix that is filtered out during normalization.
list<ExecutionOrderDependency>resetCount(): void
Reset the assertion counter.
voidreturnArgument(int $argumentIndex): ReturnArgumentStub
int $argumentIndex ReturnArgumentStubreturnCallback(mixed $callback): ReturnCallbackStub
ReturnCallbackStubreturnSelf(): ReturnSelfStub
Returns the current object.
This method is useful when mocking a fluent interface.
ReturnSelfStubreturnValue(mixed $value): ReturnStub
ReturnStubreturnValueMap(array $valueMap): ReturnValueMapStub
array $valueMap ReturnValueMapStubrun(TestResult $result = null): TestResult
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.
TestResult $result optional TestResultSebastianBergmann\CodeCoverage\InvalidArgumentExceptionSebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionCodeCoverageExceptionUtilExceptionrunBare(): void
voidThrowablerunTest()
Override to run the test and assert its state.
SebastianBergmann\ObjectEnumerator\InvalidArgumentExceptionAssertionFailedErrorExceptionExpectationFailedExceptionThrowablesetAppNamespace(string $appNamespace = 'TestApp'): string|null
Set the app namespace
string $appNamespace optional The app namespace, defaults to "TestApp".
string|nullsetBackupGlobals(?bool $backupGlobals): void
?bool $backupGlobals voidsetBackupStaticAttributes(?bool $backupStaticAttributes): void
?bool $backupStaticAttributes voidsetBeStrictAboutChangesToGlobalState(?bool $beStrictAboutChangesToGlobalState): void
?bool $beStrictAboutChangesToGlobalState voidsetDependencies(list<ExecutionOrderDependency> $dependencies): void
list<ExecutionOrderDependency> $dependencies voidsetDependencyInput(array $dependencyInput): void
array $dependencyInput voidsetGroups(array $groups): void
array $groups voidsetInIsolation(bool $inIsolation): void
bool $inIsolation voidsetLocale(mixed ...$args): void
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
voidExceptionsetName(string $name): void
string $name voidsetOutputCallback(callable $callback): void
callable $callback voidsetPreserveGlobalState(bool $preserveGlobalState): void
bool $preserveGlobalState voidsetRegisterMockObjectsFromTestArgumentsRecursively(bool $flag): void
bool $flag voidsetResult(mixed $result): void
voidsetRunClassInSeparateProcess(bool $runClassInSeparateProcess): void
bool $runClassInSeparateProcess voidsetRunTestInSeparateProcess(bool $runTestInSeparateProcess): void
bool $runTestInSeparateProcess voidsetTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Cake\ORM\Locator\LocatorInterface $tableLocator LocatorInterface instance.
$thissetTestResultObject(TestResult $result): void
TestResult $result voidsetUp(): void
Setup the test case, backup the static object values so they can be restored. Specifically backs up the contents of Configure and paths in App if they have not already been backed up.
voidsetUpBeforeClass(): void
This method is called before the first test of this test class is run.
voidsetupFixtures(): void
Initialized and loads any use fixtures.
voidskipIf(bool $shouldSkip, string $message = ''): bool
Overrides SimpleTestCase::skipIf to provide a boolean return value
bool $shouldSkip Whether the test should be skipped.
string $message optional The message to display.
boolskipUnless(bool $condition, string $message = ''): bool
Compatibility function for skipping.
bool $condition Condition to trigger skipping
string $message optional Message for skip
boolsortId(): string
stringstringContains(string $string, bool $case = true): StringContains
string $string bool $case optional StringContainsstringEndsWith(string $suffix): StringEndsWith
string $suffix StringEndsWithstringStartsWith(mixed $prefix): StringStartsWith
StringStartsWithtearDown(): void
teardown any static object changes and restore them.
voidtearDownAfterClass(): void
This method is called after the last test of this test class is run.
voidteardownFixtures(): void
Unloads any use fixtures.
voidthrowException(Throwable $exception): ExceptionStub
Throwable $exception ExceptionStubtoString(): string
Returns a string representation of the test case.
stringSebastianBergmann\RecursionContext\InvalidArgumentExceptionExceptionusesDataProvider(): bool
boolwithErrorReporting(int $errorLevel, callable $callable): void
Helper method for tests that needs to use error_reporting()
int $errorLevel value of error_reporting() that needs to use
callable $callable callable function that will receive asserts
voidConfigure values to restore at end of test.
arrayTable locator instance
Cake\ORM\Locator\LocatorInterface|nullBy default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
bool?boolstring[]string[]boolarray<string, array<int, string>>array<string, array<int, string>>This object's default table alias.
string|nullControl table create/drops on each test method.
If true, tables will still be dropped at the end of each test runner execution.
boolThe class responsible for managing the creation, loading and removing of fixtures
Cake\TestSuite\Fixture\FixtureManager|nullCake\TestSuite\Fixture\FixtureStrategyInterface|nullFixtures used by this test case.
array<string>boollist<ExecutionOrderDependency>bool
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.TestSuite.TestCase.html