W3cubDocs

/CakePHP 4.4

Class TestCase

Cake TestCase class

Abstract
Namespace: Cake\TestSuite

Property Summary

Method Summary

Method Detail

__construct() public

__construct(?string $name = null, array $data = [], int|string $dataName = '')

Parameters

?string $name optional
array $data optional
int|string $dataName optional

_assertAttributes() protected

_assertAttributes(array<string, mixed> $assertions, string $string, bool $fullDebug = false, array|string $regex = ''): string|false

Check the attributes as part of an assertTags() check.

Parameters

array<string, mixed> $assertions

Assertions to run.

string $string

The HTML string to check.

bool $fullDebug optional

Whether more verbose output should be used.

array|string $regex optional

Full regexp from assertHtml

Returns

string|false

_getTableClassName() protected

_getTableClassName(string $alias, array<string, mixed> $options): string

Gets the class name for the table.

Parameters

string $alias

The model to get a mock for.

array<string, mixed> $options

The config data for the mock's constructor.

Returns

string

Throws

Cake\ORM\Exception\MissingTableClassException

_normalizePath() protected

_normalizePath(string $path): string

Normalize a path for comparison.

Parameters

string $path

Path separated by "/" slash.

Returns

string

addFixture() protected

addFixture(string $fixture): $this

Adds a fixture to this test case.

Examples:

  • core.Tags
  • app.MyRecords
  • plugin.MyPluginName.MyModelName

Use this method inside your test cases' {@link getFixtures()} method to build up the fixture list.

Parameters

string $fixture

Fixture

Returns

$this

addToAssertionCount() public

addToAssertionCount(int $count): void

Parameters

int $count

Returns

void

addWarning() public

addWarning(string $warning): void

Parameters

string $warning

Returns

void

any() public static

any(): AnyInvokedCountMatcher

Returns a matcher that matches when the method is executed zero or more times.

Returns

AnyInvokedCountMatcher

anything() public static

anything(): IsAnything

Returns

IsAnything

arrayHasKey() public static

arrayHasKey(int|string $key): ArrayHasKey

Parameters

int|string $key

Returns

ArrayHasKey

assertArrayHasKey() public static

assertArrayHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void

Asserts that an array has a specified key.

Parameters

int|string $key
array|ArrayAccess $array
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertArrayNotHasKey() public static

assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string $message = ''): void

Asserts that an array does not have a specified key.

Parameters

int|string $key
array|ArrayAccess $array
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertClassHasAttribute() public static

assertClassHasAttribute(string $attributeName, string $className, string $message = ''): void

Asserts that a class has a specified attribute.

Parameters

string $attributeName
string $className
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertClassHasStaticAttribute() public static

assertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void

Asserts that a class has a specified static attribute.

Parameters

string $attributeName
string $className
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertClassNotHasAttribute() public static

assertClassNotHasAttribute(string $attributeName, string $className, string $message = ''): void

Asserts that a class does not have a specified attribute.

Parameters

string $attributeName
string $className
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertClassNotHasStaticAttribute() public static

assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void

Asserts that a class does not have a specified static attribute.

Parameters

string $attributeName
string $className
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertContains() public static

assertContains(mixed $needle, iterable $haystack, string $message = ''): void

Asserts that a haystack contains a needle.

Parameters

$needle
iterable $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertContainsEquals() public static

assertContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void

Parameters

$needle
iterable $haystack
string $message optional

Returns

void

assertContainsOnly() public static

assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void

Asserts that a haystack contains only values of a given type.

Parameters

string $type
iterable $haystack
?bool $isNativeType optional
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertContainsOnlyInstancesOf() public static

assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = ''): void

Asserts that a haystack contains only instances of a given class name.

Parameters

string $className
iterable $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertCount() public static

assertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void

Asserts the number of elements of an array, Countable or Traversable.

Parameters

int $expectedCount
Countable|iterable $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertDirectoryDoesNotExist() public static

assertDirectoryDoesNotExist(string $directory, string $message = ''): void

Asserts that a directory does not exist.

Parameters

string $directory

Directory

string $message optional

Message

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

assertDirectoryExists() public static

assertDirectoryExists(string $directory, string $message = ''): void

Asserts that a directory exists.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryIsNotReadable() public static

assertDirectoryIsNotReadable(string $directory, string $message = ''): void

Asserts that a directory exists and is not readable.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryIsNotWritable() public static

assertDirectoryIsNotWritable(string $directory, string $message = ''): void

Asserts that a directory exists and is not writable.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryIsReadable() public static

assertDirectoryIsReadable(string $directory, string $message = ''): void

Asserts that a directory exists and is readable.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryIsWritable() public static

assertDirectoryIsWritable(string $directory, string $message = ''): void

Asserts that a directory exists and is writable.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryNotExists() public static

assertDirectoryNotExists(string $directory, string $message = ''): void

Asserts that a directory does not exist.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryNotIsReadable() public static

assertDirectoryNotIsReadable(string $directory, string $message = ''): void

Asserts that a directory exists and is not readable.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDirectoryNotIsWritable() public static

assertDirectoryNotIsWritable(string $directory, string $message = ''): void

Asserts that a directory exists and is not writable.

Parameters

string $directory
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertDoesNotMatchRegularExpression() public static

assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = ''): void

Asserts that a string does not match a given regular expression.

Parameters

string $pattern

Regex pattern

string $string

String to test

string $message optional

Message

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

assertEmpty() public static

assertEmpty(mixed $actual, string $message = ''): void

Asserts that a variable is empty.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertEqualXMLStructure() public static

assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void

Asserts that a hierarchy of DOMElements matches.

Parameters

DOMElement $expectedElement
DOMElement $actualElement
bool $checkAttributes optional
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

AssertionFailedError

ExpectationFailedException

assertEquals() public static

assertEquals(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables are equal.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertEqualsCanonicalizing() public static

assertEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables are equal (canonicalizing).

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertEqualsIgnoringCase() public static

assertEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables are equal (ignoring case).

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertEqualsSql() public

assertEqualsSql(string $expected, string $actual, string $message = ''): void

Assert that a string matches SQL with db-specific characters like quotes removed.

Parameters

string $expected

The expected sql

string $actual

The sql to compare

string $message optional

The message to display on failure

Returns

void

assertEqualsWithDelta() public static

assertEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void

Asserts that two variables are equal (with delta).

Parameters

$expected
$actual
float $delta
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertEventFired() public

assertEventFired(string $name, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void

Asserts that a global event was fired. You must track events in your event manager for this assertion to work

Parameters

string $name

Event name

Cake\Event\EventManager|null $eventManager optional

Event manager to check, defaults to global event manager

string $message optional

Assertion failure message

Returns

void

assertEventFiredWith() public

assertEventFiredWith(string $name, string $dataKey, mixed $dataValue, Cake\Event\EventManager|null $eventManager = null, string $message = ''): void

Asserts an event was fired with data

If a third argument is passed, that value is used to compare with the value in $dataKey

Parameters

string $name

Event name

string $dataKey

Data key

mixed $dataValue

Data value

Cake\Event\EventManager|null $eventManager optional

Event manager to check, defaults to global event manager

string $message optional

Assertion failure message

Returns

void

assertFalse() public static

assertFalse(mixed $condition, string $message = ''): void

Asserts that a condition is false.

Parameters

$condition
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileDoesNotExist() public static

assertFileDoesNotExist(string $filename, string $message = ''): void

Asserts that a file does not exist.

Parameters

string $filename

Filename

string $message optional

Message

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

assertFileEquals() public static

assertFileEquals(string $expected, string $actual, string $message = ''): void

Asserts that the contents of one file is equal to the contents of another file.

Parameters

string $expected
string $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileEqualsCanonicalizing() public static

assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void

Asserts that the contents of one file is equal to the contents of another file (canonicalizing).

Parameters

string $expected
string $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileEqualsIgnoringCase() public static

assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void

Asserts that the contents of one file is equal to the contents of another file (ignoring case).

Parameters

string $expected
string $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileExists() public static

assertFileExists(string $filename, string $message = ''): void

Asserts that a file exists.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileIsNotReadable() public static

assertFileIsNotReadable(string $file, string $message = ''): void

Asserts that a file exists and is not readable.

Parameters

string $file
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileIsNotWritable() public static

assertFileIsNotWritable(string $file, string $message = ''): void

Asserts that a file exists and is not writable.

Parameters

string $file
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileIsReadable() public static

assertFileIsReadable(string $file, string $message = ''): void

Asserts that a file exists and is readable.

Parameters

string $file
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileIsWritable() public static

assertFileIsWritable(string $file, string $message = ''): void

Asserts that a file exists and is writable.

Parameters

string $file
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileNotEquals() public static

assertFileNotEquals(string $expected, string $actual, string $message = ''): void

Asserts that the contents of one file is not equal to the contents of another file.

Parameters

string $expected
string $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileNotEqualsCanonicalizing() public static

assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = ''): void

Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).

Parameters

string $expected
string $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileNotEqualsIgnoringCase() public static

assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = ''): void

Asserts that the contents of one file is not equal to the contents of another file (ignoring case).

Parameters

string $expected
string $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileNotExists() public static

assertFileNotExists(string $filename, string $message = ''): void

Asserts that a file does not exist.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileNotIsReadable() public static

assertFileNotIsReadable(string $file, string $message = ''): void

Asserts that a file exists and is not readable.

Parameters

string $file
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFileNotIsWritable() public static

assertFileNotIsWritable(string $file, string $message = ''): void

Asserts that a file exists and is not writable.

Parameters

string $file
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertFinite() public static

assertFinite(mixed $actual, string $message = ''): void

Asserts that a variable is finite.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertGreaterThan() public static

assertGreaterThan(mixed $expected, mixed $actual, string $message = ''): void

Asserts that a value is greater than another value.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertGreaterThanOrEqual() public static

assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void

Asserts that a value is greater than or equal to another value.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertHtml() public

assertHtml(array $expected, string $string, bool $fullDebug = false): bool

Asserts HTML tags.

Takes an array $expected and generates a regex from it to match the provided $string. Samples for $expected:

Checks for an input tag with a name attribute (contains any non-empty value) and an id attribute that contains 'my-input':

['input' => ['name', 'id' => 'my-input']]

Checks for two p elements with some text in them:

[
  ['p' => true],
  'textA',
  '/p',
  ['p' => true],
  'textB',
  '/p'
]

You can also specify a pattern expression as part of the attribute values, or the tag being defined, if you prepend the value with preg: and enclose it with slashes, like so:

[
  ['input' => ['name', 'id' => 'preg:/FieldName\d+/']],
  'preg:/My\s+field/'
]

Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order. It will also allow whitespace between specified tags.

Parameters

array $expected

An array, see above

string $string

An HTML/XHTML/XML string

bool $fullDebug optional

Whether more verbose output should be used.

Returns

bool

assertInfinite() public static

assertInfinite(mixed $actual, string $message = ''): void

Asserts that a variable is infinite.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertInstanceOf() public static

assertInstanceOf(string $expected, mixed $actual, string $message = ''): void

Asserts that a variable is of a given type.

Parameters

string $expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertIsArray() public static

assertIsArray(mixed $actual, string $message = ''): void

Asserts that a variable is of type array.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsBool() public static

assertIsBool(mixed $actual, string $message = ''): void

Asserts that a variable is of type bool.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsCallable() public static

assertIsCallable(mixed $actual, string $message = ''): void

Asserts that a variable is of type callable.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsClosedResource() public static

assertIsClosedResource(mixed $actual, string $message = ''): void

Asserts that a variable is of type resource and is closed.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsFloat() public static

assertIsFloat(mixed $actual, string $message = ''): void

Asserts that a variable is of type float.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsInt() public static

assertIsInt(mixed $actual, string $message = ''): void

Asserts that a variable is of type int.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsIterable() public static

assertIsIterable(mixed $actual, string $message = ''): void

Asserts that a variable is of type iterable.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotArray() public static

assertIsNotArray(mixed $actual, string $message = ''): void

Asserts that a variable is not of type array.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotBool() public static

assertIsNotBool(mixed $actual, string $message = ''): void

Asserts that a variable is not of type bool.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotCallable() public static

assertIsNotCallable(mixed $actual, string $message = ''): void

Asserts that a variable is not of type callable.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotClosedResource() public static

assertIsNotClosedResource(mixed $actual, string $message = ''): void

Asserts that a variable is not of type resource.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotFloat() public static

assertIsNotFloat(mixed $actual, string $message = ''): void

Asserts that a variable is not of type float.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotInt() public static

assertIsNotInt(mixed $actual, string $message = ''): void

Asserts that a variable is not of type int.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotIterable() public static

assertIsNotIterable(mixed $actual, string $message = ''): void

Asserts that a variable is not of type iterable.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotNumeric() public static

assertIsNotNumeric(mixed $actual, string $message = ''): void

Asserts that a variable is not of type numeric.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotObject() public static

assertIsNotObject(mixed $actual, string $message = ''): void

Asserts that a variable is not of type object.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotReadable() public static

assertIsNotReadable(string $filename, string $message = ''): void

Asserts that a file/dir exists and is not readable.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotResource() public static

assertIsNotResource(mixed $actual, string $message = ''): void

Asserts that a variable is not of type resource.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotScalar() public static

assertIsNotScalar(mixed $actual, string $message = ''): void

Asserts that a variable is not of type scalar.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotString() public static

assertIsNotString(mixed $actual, string $message = ''): void

Asserts that a variable is not of type string.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNotWritable() public static

assertIsNotWritable(string $filename, string $message = ''): void

Asserts that a file/dir exists and is not writable.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsNumeric() public static

assertIsNumeric(mixed $actual, string $message = ''): void

Asserts that a variable is of type numeric.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsObject() public static

assertIsObject(mixed $actual, string $message = ''): void

Asserts that a variable is of type object.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsReadable() public static

assertIsReadable(string $filename, string $message = ''): void

Asserts that a file/dir is readable.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsResource() public static

assertIsResource(mixed $actual, string $message = ''): void

Asserts that a variable is of type resource.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsScalar() public static

assertIsScalar(mixed $actual, string $message = ''): void

Asserts that a variable is of type scalar.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsString() public static

assertIsString(mixed $actual, string $message = ''): void

Asserts that a variable is of type string.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertIsWritable() public static

assertIsWritable(string $filename, string $message = ''): void

Asserts that a file/dir exists and is writable.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJson() public static

assertJson(string $actualJson, string $message = ''): void

Asserts that a string is a valid JSON string.

Parameters

string $actualJson
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJsonFileEqualsJsonFile() public static

assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void

Asserts that two JSON files are equal.

Parameters

string $expectedFile
string $actualFile
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJsonFileNotEqualsJsonFile() public static

assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void

Asserts that two JSON files are not equal.

Parameters

string $expectedFile
string $actualFile
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJsonStringEqualsJsonFile() public static

assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void

Asserts that the generated JSON encoded object and the content of the given file are equal.

Parameters

string $expectedFile
string $actualJson
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJsonStringEqualsJsonString() public static

assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void

Asserts that two given JSON encoded objects or arrays are equal.

Parameters

string $expectedJson
string $actualJson
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJsonStringNotEqualsJsonFile() public static

assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void

Asserts that the generated JSON encoded object and the content of the given file are not equal.

Parameters

string $expectedFile
string $actualJson
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertJsonStringNotEqualsJsonString() public static

assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void

Asserts that two given JSON encoded objects or arrays are not equal.

Parameters

string $expectedJson
string $actualJson
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertLessThan() public static

assertLessThan(mixed $expected, mixed $actual, string $message = ''): void

Asserts that a value is smaller than another value.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertLessThanOrEqual() public static

assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = ''): void

Asserts that a value is smaller than or equal to another value.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertMatchesRegularExpression() public static

assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void

Asserts that a string matches a given regular expression.

Parameters

string $pattern

Regex pattern

string $string

String to test

string $message optional

Message

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

assertNan() public static

assertNan(mixed $actual, string $message = ''): void

Asserts that a variable is nan.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotContains() public static

assertNotContains(mixed $needle, iterable $haystack, string $message = ''): void

Asserts that a haystack does not contain a needle.

Parameters

$needle
iterable $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertNotContainsEquals() public static

assertNotContainsEquals(mixed $needle, iterable $haystack, string $message = ''): void

Parameters

$needle
iterable $haystack
string $message optional

Returns

void

assertNotContainsOnly() public static

assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void

Asserts that a haystack does not contain only values of a given type.

Parameters

string $type
iterable $haystack
?bool $isNativeType optional
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotCount() public static

assertNotCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void

Asserts the number of elements of an array, Countable or Traversable.

Parameters

int $expectedCount
Countable|iterable $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertNotEmpty() public static

assertNotEmpty(mixed $actual, string $message = ''): void

Asserts that a variable is not empty.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotEquals() public static

assertNotEquals(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables are not equal.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotEqualsCanonicalizing() public static

assertNotEqualsCanonicalizing(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables are not equal (canonicalizing).

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotEqualsIgnoringCase() public static

assertNotEqualsIgnoringCase(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables are not equal (ignoring case).

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotEqualsWithDelta() public static

assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta, string $message = ''): void

Asserts that two variables are not equal (with delta).

Parameters

$expected
$actual
float $delta
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotFalse() public static

assertNotFalse(mixed $condition, string $message = ''): void

Asserts that a condition is not false.

Parameters

$condition
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotInstanceOf() public static

assertNotInstanceOf(string $expected, mixed $actual, string $message = ''): void

Asserts that a variable is not of a given type.

Parameters

string $expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertNotIsReadable() public static

assertNotIsReadable(string $filename, string $message = ''): void

Asserts that a file/dir exists and is not readable.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotIsWritable() public static

assertNotIsWritable(string $filename, string $message = ''): void

Asserts that a file/dir exists and is not writable.

Parameters

string $filename
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotNull() public static

assertNotNull(mixed $actual, string $message = ''): void

Asserts that a variable is not null.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotRegExp() public static

assertNotRegExp(string $pattern, string $string, string $message = ''): void

Asserts that a string does not match a given regular expression.

Parameters

string $pattern
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotSame() public static

assertNotSame(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables do not have the same type and value. Used on objects, it asserts that two variables do not reference the same object.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotSameSize() public static

assertNotSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void

Assert that the size of two arrays (or Countable or Traversable objects) is not the same.

Parameters

Countable|iterable $expected
Countable|iterable $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertNotTrue() public static

assertNotTrue(mixed $condition, string $message = ''): void

Asserts that a condition is not true.

Parameters

$condition
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertNotWithinRange() protected static

assertNotWithinRange(float $expected, float $result, float $margin, string $message = ''): void

Compatibility function to test if a value is not between an acceptable range.

Parameters

float $expected
float $result
float $margin

the rage of acceptation

string $message optional

the text to display if the assertion is not correct

Returns

void

assertNull() public static

assertNull(mixed $actual, string $message = ''): void

Asserts that a variable is null.

Parameters

$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertObjectEquals() public static

assertObjectEquals(object $expected, object $actual, string $method = 'equals', string $message = ''): void

Parameters

object $expected
object $actual
string $method optional
string $message optional

Returns

void

Throws

ExpectationFailedException

assertObjectHasAttribute() public static

assertObjectHasAttribute(string $attributeName, object $object, string $message = ''): void

Asserts that an object has a specified attribute.

Parameters

string $attributeName
object $object
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertObjectNotHasAttribute() public static

assertObjectNotHasAttribute(string $attributeName, object $object, string $message = ''): void

Asserts that an object does not have a specified attribute.

Parameters

string $attributeName
object $object
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertPathEquals() protected static

assertPathEquals(string $expected, string $result, string $message = ''): void

Compatibility function to test paths.

Parameters

string $expected
string $result
string $message optional

the text to display if the assertion is not correct

Returns

void

assertPostConditions() protected

assertPostConditions(): void

Performs assertions shared by all tests of a test case.

This method is called between test and tearDown().

Returns

void

assertPreConditions() protected

assertPreConditions(): void

Performs assertions shared by all tests of a test case.

This method is called between setUp() and test.

Returns

void

assertRegExp() public static

assertRegExp(string $pattern, string $string, string $message = ''): void

Asserts that a string matches a given regular expression.

Parameters

string $pattern
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertRegExpSql() public

assertRegExpSql(string $pattern, string $actual, bool $optional = false): void

Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters < and >. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries

Parameters

string $pattern

The expected sql pattern

string $actual

The sql to compare

bool $optional optional

Whether quote characters (marked with <>) are optional

Returns

void

assertSame() public static

assertSame(mixed $expected, mixed $actual, string $message = ''): void

Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.

Parameters

$expected
$actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertSameSize() public static

assertSameSize(Countable|iterable $expected, Countable|iterable $actual, string $message = ''): void

Assert that the size of two arrays (or Countable or Traversable objects) is the same.

Parameters

Countable|iterable $expected
Countable|iterable $actual
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertStringContainsString() public static

assertStringContainsString(string $needle, string $haystack, string $message = ''): void

Parameters

string $needle
string $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringContainsStringIgnoringCase() public static

assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void

Parameters

string $needle
string $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringEndsNotWith() public static

assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void

Asserts that a string ends not with a given suffix.

Parameters

string $suffix
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringEndsWith() public static

assertStringEndsWith(string $suffix, string $string, string $message = ''): void

Asserts that a string ends with a given suffix.

Parameters

string $suffix
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringEqualsFile() public static

assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void

Asserts that the contents of a string is equal to the contents of a file.

Parameters

string $expectedFile
string $actualString
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringEqualsFileCanonicalizing() public static

assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void

Asserts that the contents of a string is equal to the contents of a file (canonicalizing).

Parameters

string $expectedFile
string $actualString
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringEqualsFileIgnoringCase() public static

assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void

Asserts that the contents of a string is equal to the contents of a file (ignoring case).

Parameters

string $expectedFile
string $actualString
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringMatchesFormat() public static

assertStringMatchesFormat(string $format, string $string, string $message = ''): void

Asserts that a string matches a given format string.

Parameters

string $format
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringMatchesFormatFile() public static

assertStringMatchesFormatFile(string $formatFile, string $string, string $message = ''): void

Asserts that a string matches a given format file.

Parameters

string $formatFile
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotContainsString() public static

assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void

Parameters

string $needle
string $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotContainsStringIgnoringCase() public static

assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void

Parameters

string $needle
string $haystack
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotEqualsFile() public static

assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void

Asserts that the contents of a string is not equal to the contents of a file.

Parameters

string $expectedFile
string $actualString
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotEqualsFileCanonicalizing() public static

assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void

Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).

Parameters

string $expectedFile
string $actualString
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotEqualsFileIgnoringCase() public static

assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void

Asserts that the contents of a string is not equal to the contents of a file (ignoring case).

Parameters

string $expectedFile
string $actualString
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotMatchesFormat() public static

assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void

Asserts that a string does not match a given format string.

Parameters

string $format
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringNotMatchesFormatFile() public static

assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = ''): void

Asserts that a string does not match a given format string.

Parameters

string $formatFile
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringStartsNotWith() public static

assertStringStartsNotWith(string $prefix, string $string, string $message = ''): void

Asserts that a string starts not with a given prefix.

Parameters

string $prefix
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertStringStartsWith() public static

assertStringStartsWith(string $prefix, string $string, string $message = ''): void

Asserts that a string starts with a given prefix.

Parameters

string $prefix
string $string
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertTextContains() public

assertTextContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void

Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $needle

The string to search for.

string $haystack

The string to search through.

string $message optional

The message to display on failure.

bool $ignoreCase optional

Whether the search should be case-sensitive.

Returns

void

assertTextEndsNotWith() public

assertTextEndsNotWith(string $suffix, string $string, string $message = ''): void

Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $suffix

The suffix to not find.

string $string

The string to search.

string $message optional

The message to use for failure.

Returns

void

assertTextEndsWith() public

assertTextEndsWith(string $suffix, string $string, string $message = ''): void

Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $suffix

The suffix to find.

string $string

The string to search.

string $message optional

The message to use for failure.

Returns

void

assertTextEquals() public

assertTextEquals(string $expected, string $result, string $message = ''): void

Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $expected

The expected value.

string $result

The actual value.

string $message optional

The message to use for failure.

Returns

void

assertTextNotContains() public

assertTextNotContains(string $needle, string $haystack, string $message = '', bool $ignoreCase = false): void

Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $needle

The string to search for.

string $haystack

The string to search through.

string $message optional

The message to display on failure.

bool $ignoreCase optional

Whether the search should be case-sensitive.

Returns

void

assertTextNotEquals() public

assertTextNotEquals(string $expected, string $result, string $message = ''): void

Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $expected

The expected value.

string $result

The actual value.

string $message optional

The message to use for failure.

Returns

void

assertTextStartsNotWith() public

assertTextStartsNotWith(string $prefix, string $string, string $message = ''): void

Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $prefix

The prefix to not find.

string $string

The string to search.

string $message optional

The message to use for failure.

Returns

void

assertTextStartsWith() public

assertTextStartsWith(string $prefix, string $string, string $message = ''): void

Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters

string $prefix

The prefix to check for.

string $string

The string to search in.

string $message optional

The message to use for failure.

Returns

void

assertThat() public static

assertThat(mixed $value, Constraint $constraint, string $message = ''): void

Evaluates a PHPUnit\Framework\Constraint matcher object.

Parameters

$value
Constraint $constraint
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertTrue() public static

assertTrue(mixed $condition, string $message = ''): void

Asserts that a condition is true.

Parameters

$condition
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertWithinRange() protected static

assertWithinRange(float $expected, float $result, float $margin, string $message = ''): void

Compatibility function to test if a value is between an acceptable range.

Parameters

float $expected
float $result
float $margin

the rage of acceptation

string $message optional

the text to display if the assertion is not correct

Returns

void

assertXmlFileEqualsXmlFile() public static

assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void

Asserts that two XML files are equal.

Parameters

string $expectedFile
string $actualFile
string $message optional

Returns

void

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

ExpectationFailedException

assertXmlFileNotEqualsXmlFile() public static

assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void

Asserts that two XML files are not equal.

Parameters

string $expectedFile
string $actualFile
string $message optional

Returns

void

Throws

PHPUnit\Util\Exception

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertXmlStringEqualsXmlFile() public static

assertXmlStringEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void

Asserts that two XML documents are equal.

Parameters

string $expectedFile
DOMDocument|string $actualXml
string $message optional

Returns

void

Throws

PHPUnit\Util\Xml\Exception

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertXmlStringEqualsXmlString() public static

assertXmlStringEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void

Asserts that two XML documents are equal.

Parameters

DOMDocument|string $expectedXml
DOMDocument|string $actualXml
string $message optional

Returns

void

Throws

PHPUnit\Util\Xml\Exception

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertXmlStringNotEqualsXmlFile() public static

assertXmlStringNotEqualsXmlFile(string $expectedFile, DOMDocument|string $actualXml, string $message = ''): void

Asserts that two XML documents are not equal.

Parameters

string $expectedFile
DOMDocument|string $actualXml
string $message optional

Returns

void

Throws

PHPUnit\Util\Xml\Exception

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

assertXmlStringNotEqualsXmlString() public static

assertXmlStringNotEqualsXmlString(DOMDocument|string $expectedXml, DOMDocument|string $actualXml, string $message = ''): void

Asserts that two XML documents are not equal.

Parameters

DOMDocument|string $expectedXml
DOMDocument|string $actualXml
string $message optional

Returns

void

Throws

PHPUnit\Util\Xml\Exception

SebastianBergmann\RecursionContext\InvalidArgumentException

ExpectationFailedException

at() public static

at(int $index): InvokedAtIndexMatcher

Returns a matcher that matches when the method is executed at the given index.

Parameters

int $index

Returns

InvokedAtIndexMatcher

atLeast() public static

atLeast(int $requiredInvocations): InvokedAtLeastCountMatcher

Returns a matcher that matches when the method is executed at least N times.

Parameters

int $requiredInvocations

Returns

InvokedAtLeastCountMatcher

atLeastOnce() public static

atLeastOnce(): InvokedAtLeastOnceMatcher

Returns a matcher that matches when the method is executed at least once.

Returns

InvokedAtLeastOnceMatcher

atMost() public static

atMost(int $allowedInvocations): InvokedAtMostCountMatcher

Returns a matcher that matches when the method is executed at most N times.

Parameters

int $allowedInvocations

Returns

InvokedAtMostCountMatcher

callback() public static

callback(callable $callback): Callback

Parameters

callable $callback

Returns

Callback

classHasAttribute() public static

classHasAttribute(string $attributeName): ClassHasAttribute

Parameters

string $attributeName

Returns

ClassHasAttribute

classHasStaticAttribute() public static

classHasStaticAttribute(string $attributeName): ClassHasStaticAttribute

Parameters

string $attributeName

Returns

ClassHasStaticAttribute

clearPlugins() public

clearPlugins(): void

Clear all plugins from the global plugin collection.

Useful in test case teardown methods.

Returns

void

containsEqual() public static

containsEqual(mixed $value): TraversableContainsEqual

Parameters

$value

Returns

TraversableContainsEqual

containsIdentical() public static

containsIdentical(mixed $value): TraversableContainsIdentical

Parameters

$value

Returns

TraversableContainsIdentical

containsOnly() public static

containsOnly(string $type): TraversableContainsOnly

Parameters

string $type

Returns

TraversableContainsOnly

containsOnlyInstancesOf() public static

containsOnlyInstancesOf(string $className): TraversableContainsOnly

Parameters

string $className

Returns

TraversableContainsOnly

count() public

count(): int

Returns

int

countOf() public static

countOf(int $count): Count

Parameters

int $count

Returns

Count

createConfiguredMock() protected

createConfiguredMock(string $originalClassName, array $configuration): MockObject

Returns a configured mock object for the specified class.

Parameters

string $originalClassName
array $configuration

Returns

MockObject

createMock() protected

createMock(string $originalClassName): MockObject

Returns a mock object for the specified class.

Parameters

string $originalClassName

Returns

MockObject

createPartialMock() protected

createPartialMock(string $originalClassName, string[] $methods): MockObject

Returns a partial mock object for the specified class.

Parameters

string $originalClassName
string[] $methods

Returns

MockObject

createResult() protected

createResult(): TestResult

Creates a default TestResult object.

Returns

TestResult

createStub() protected

createStub(string $originalClassName): Stub

Makes configurable stub for the specified class.

Parameters

string $originalClassName

Returns

Stub

createTestProxy() protected

createTestProxy(string $originalClassName, array $constructorArguments = []): MockObject

Returns a test proxy for the specified class.

Parameters

string $originalClassName
array $constructorArguments optional

Returns

MockObject

dataName() public

dataName(): int|string

Returns

int|string

deprecated() public

deprecated(callable $callable): void

Helper method for check deprecation methods

Parameters

callable $callable

callable function that will receive asserts

Returns

void

directoryExists() public static

directoryExists(): DirectoryExists

Returns

DirectoryExists

doesNotPerformAssertions() public

doesNotPerformAssertions(): bool

Returns

bool

doubledTypes() public

doubledTypes(): string[]

Returns

string[]

equalTo() public static

equalTo(mixed $value): IsEqual

Parameters

$value

Returns

IsEqual

equalToCanonicalizing() public static

equalToCanonicalizing(mixed $value): IsEqualCanonicalizing

Parameters

$value

Returns

IsEqualCanonicalizing

equalToIgnoringCase() public static

equalToIgnoringCase(mixed $value): IsEqualIgnoringCase

Parameters

$value

Returns

IsEqualIgnoringCase

equalToWithDelta() public static

equalToWithDelta(mixed $value, float $delta): IsEqualWithDelta

Parameters

$value
float $delta

Returns

IsEqualWithDelta

exactly() public static

exactly(int $count): InvokedCountMatcher

Returns a matcher that matches when the method is executed exactly $count times.

Parameters

int $count

Returns

InvokedCountMatcher

expectDeprecation() public

expectDeprecation(): void

Returns

void

expectDeprecationMessage() public

expectDeprecationMessage(string $message): void

Parameters

string $message

Returns

void

expectDeprecationMessageMatches() public

expectDeprecationMessageMatches(string $regularExpression): void

Parameters

string $regularExpression

Returns

void

expectError() public

expectError(): void

Returns

void

expectErrorMessage() public

expectErrorMessage(string $message): void

Parameters

string $message

Returns

void

expectErrorMessageMatches() public

expectErrorMessageMatches(string $regularExpression): void

Parameters

string $regularExpression

Returns

void

expectException() public

expectException(string $exception): void

Parameters

string $exception

Returns

void

expectExceptionCode() public

expectExceptionCode(int|string $code): void

Parameters

int|string $code

Returns

void

expectExceptionMessage() public

expectExceptionMessage(string $message): void

Parameters

string $message

Returns

void

expectExceptionMessageMatches() public

expectExceptionMessageMatches(string $regularExpression): void

Parameters

string $regularExpression

Returns

void

expectExceptionObject() public

expectExceptionObject(Exception $exception): void

Sets up an expectation for an exception to be raised by the code under test. Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.

Parameters

Exception $exception

Returns

void

expectNotToPerformAssertions() public

expectNotToPerformAssertions(): void

Returns

void

expectNotice() public

expectNotice(): void

Returns

void

expectNoticeMessage() public

expectNoticeMessage(string $message): void

Parameters

string $message

Returns

void

expectNoticeMessageMatches() public

expectNoticeMessageMatches(string $regularExpression): void

Parameters

string $regularExpression

Returns

void

expectOutputRegex() public

expectOutputRegex(string $expectedRegex): void

Parameters

string $expectedRegex

Returns

void

expectOutputString() public

expectOutputString(string $expectedString): void

Parameters

string $expectedString

Returns

void

expectWarning() public

expectWarning(): void

Returns

void

expectWarningMessage() public

expectWarningMessage(string $message): void

Parameters

string $message

Returns

void

expectWarningMessageMatches() public

expectWarningMessageMatches(string $regularExpression): void

Parameters

string $regularExpression

Returns

void

fail() public static

fail(string $message = ''): void

Fails a test with the given message.

Parameters

string $message optional

Returns

void

Throws

AssertionFailedError

fetchTable() public

fetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table

Convenience method to get a table instance.

Parameters

string|null $alias optional

The alias name you want to get. Should be in CamelCase format. If null then the value of $defaultTable property is used.

array<string, mixed> $options optional

The options you want to build the table with. If a table has already been loaded the registry options will be ignored.

Returns

Cake\ORM\Table

Throws

Cake\Core\Exception\CakeException
If `$alias` argument and `$defaultTable` property both are `null`.

See Also

\Cake\ORM\TableLocator::get()

fileExists() public static

fileExists(): FileExists

Returns

FileExists

getActualOutput() public

getActualOutput(): string

Returns

string

getActualOutputForAssertion() public

getActualOutputForAssertion(): string

Returns

string

getCount() public static

getCount(): int

Return the current assertion count.

Returns

int

getDataSetAsString() public

getDataSetAsString(bool $includeData = true): string

Parameters

bool $includeData optional

Returns

string

getExpectedException() public

getExpectedException(): ?string

Returns

?string

getExpectedExceptionCode() public

getExpectedExceptionCode(): null|int|string

Returns

null|int|string

getExpectedExceptionMessage() public

getExpectedExceptionMessage(): ?string

Returns

?string

getExpectedExceptionMessageRegExp() public

getExpectedExceptionMessageRegExp(): ?string

Returns

?string

getFixtureStrategy() protected

getFixtureStrategy(): Cake\TestSuite\Fixture\FixtureStrategyInterface

Returns fixture strategy used by these tests.

Returns

Cake\TestSuite\Fixture\FixtureStrategyInterface

getFixtures() public

getFixtures(): array<string>

Get the fixtures this test should use.

Returns

array<string>

getGroups() public

getGroups(): array

Returns

array

getMockBuilder() public

getMockBuilder(string $className): MockBuilder

Returns a builder object to create mock objects using a fluent interface.

Parameters

string $className

Returns

MockBuilder

getMockClass() protected

getMockClass(string $originalClassName, null|array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = false, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = false): string

Mocks the specified class and returns the name of the mocked class.

Parameters

string $originalClassName
null|array $methods optional

$methods

array $arguments optional
string $mockClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional
bool $cloneArguments optional

Returns

string

getMockForAbstractClass() protected

getMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject

Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default. To mock concrete methods, use the 7th parameter ($mockedMethods).

Parameters

string $originalClassName
array $arguments optional
string $mockClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional
array $mockedMethods optional
bool $cloneArguments optional

Returns

MockObject

getMockForModel() public

getMockForModel(string $alias, array<string> $methods = [], array<string, mixed> $options = []): Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject

Mock a model, maintain fixtures and table association

Parameters

string $alias

The model to get a mock for.

array<string> $methods optional

The list of methods to mock

array<string, mixed> $options optional

The config data for the mock's constructor.

Returns

Cake\ORM\TablePHPUnit\Framework\MockObject\MockObject

Throws

Cake\ORM\Exception\MissingTableClassException

getMockForTrait() protected

getMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false): MockObject

Returns a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the $mockedMethods parameter.

Parameters

string $traitName
array $arguments optional
string $mockClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional
array $mockedMethods optional
bool $cloneArguments optional

Returns

MockObject

getMockFromWsdl() protected

getMockFromWsdl(string $wsdlFile, string $originalClassName = '', string $mockClassName = '', array $methods = [], bool $callOriginalConstructor = true, array $options = []): MockObject

Returns a mock object based on the given WSDL file.

Parameters

string $wsdlFile
string $originalClassName optional
string $mockClassName optional
array $methods optional
bool $callOriginalConstructor optional
array $options optional

Returns

MockObject

getName() public

getName(bool $withDataSet = true): string

Parameters

bool $withDataSet optional

Returns

string

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

getNumAssertions() public

getNumAssertions(): int

Returns the number of assertions performed by this test.

Returns

int

getObjectForTrait() protected

getObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true): object

Returns an object for the specified trait.

Parameters

string $traitName
array $arguments optional
string $traitClassName optional
bool $callOriginalConstructor optional
bool $callOriginalClone optional
bool $callAutoload optional

Returns

object

getProvidedData() public

getProvidedData(): array

Gets the data set of a TestCase.

Returns

array

getResult() public

getResult()

getSize() public

getSize(): int

Returns the size of the test.

Returns

int

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

getStatus() public

getStatus(): int

Returns

int

getStatusMessage() public

getStatusMessage(): string

Returns

string

getTableLocator() public

getTableLocator(): Cake\ORM\Locator\LocatorInterface

Gets the table locator.

Returns

Cake\ORM\Locator\LocatorInterface

getTestResultObject() public

getTestResultObject(): ?TestResult

Returns

?TestResult

greaterThan() public static

greaterThan(mixed $value): GreaterThan

Parameters

$value

Returns

GreaterThan

greaterThanOrEqual() public static

greaterThanOrEqual(mixed $value): LogicalOr

Parameters

$value

Returns

LogicalOr

hasExpectationOnOutput() public

hasExpectationOnOutput(): bool

Returns

bool

hasFailed() public

hasFailed(): bool

Returns

bool

hasOutput() public

hasOutput(): bool

Returns

bool

hasSize() public

hasSize(): bool

Returns

bool

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

identicalTo() public static

identicalTo(mixed $value): IsIdentical

Parameters

$value

Returns

IsIdentical

iniSet() protected

iniSet(string $varName, string $newValue): void

This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.

Parameters

string $varName
string $newValue

Returns

void

Throws

Exception

isEmpty() public static

isEmpty(): IsEmpty

Returns

IsEmpty

isFalse() public static

isFalse(): IsFalse

Returns

IsFalse

isFinite() public static

isFinite(): IsFinite

Returns

IsFinite

isInIsolation() public

isInIsolation(): bool

Returns

bool

isInfinite() public static

isInfinite(): IsInfinite

Returns

IsInfinite

isInstanceOf() public static

isInstanceOf(string $className): IsInstanceOf

Parameters

string $className

Returns

IsInstanceOf

isJson() public static

isJson(): IsJson

Returns

IsJson

isLarge() public

isLarge(): bool

Returns

bool

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

isMedium() public

isMedium(): bool

Returns

bool

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

isNan() public static

isNan(): IsNan

Returns

IsNan

isNull() public static

isNull(): IsNull

Returns

IsNull

isReadable() public static

isReadable(): IsReadable

Returns

IsReadable

isSmall() public

isSmall(): bool

Returns

bool

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

isTrue() public static

isTrue(): IsTrue

Returns

IsTrue

isType() public static

isType(string $type): IsType

Parameters

string $type

Returns

IsType

isWritable() public static

isWritable(): IsWritable

Returns

IsWritable

lessThan() public static

lessThan(mixed $value): LessThan

Parameters

$value

Returns

LessThan

lessThanOrEqual() public static

lessThanOrEqual(mixed $value): LogicalOr

Parameters

$value

Returns

LogicalOr

loadFixtures() public

loadFixtures(): void

Chooses which fixtures to load for a given test

Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc. Passing no parameters will cause all fixtures on the test case to load.

Returns

void

Throws

RuntimeException
when no fixture manager is available.

See Also

\Cake\TestSuite\TestCase::$autoFixtures

loadPlugins() public

loadPlugins(array<string, mixed> $plugins = []): Cake\Http\BaseApplication

Load plugins into a simulated application.

Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.

Parameters

array<string, mixed> $plugins optional

List of Plugins to load.

Returns

Cake\Http\BaseApplication

loadRoutes() public

loadRoutes(array|null $appArgs = null): void

Load routes for the application.

If no application class can be found an exception will be raised. Routes for plugins will not be loaded. Use loadPlugins() or use Cake\TestSuite\IntegrationTestCaseTrait to better simulate all routes and plugins being loaded.

Parameters

array|null $appArgs optional

Constructor parameters for the application class.

Returns

void

logicalAnd() public static

logicalAnd(): LogicalAnd

Returns

LogicalAnd

Throws

Exception

logicalNot() public static

logicalNot(Constraint $constraint): LogicalNot

Parameters

Constraint $constraint

Returns

LogicalNot

logicalOr() public static

logicalOr(): LogicalOr

Returns

LogicalOr

logicalXor() public static

logicalXor(): LogicalXor

Returns

LogicalXor

markAsRisky() public

markAsRisky(): void

Returns

void

markTestIncomplete() public static

markTestIncomplete(string $message = ''): void

Mark the test as incomplete.

Parameters

string $message optional

Returns

void

Throws

IncompleteTestError

markTestSkipped() public static

markTestSkipped(string $message = ''): void

Mark the test as skipped.

Parameters

string $message optional

Returns

void

Throws

SkippedTestError

SyntheticSkippedError

matches() public static

matches(string $string): StringMatchesFormatDescription

Parameters

string $string

Returns

StringMatchesFormatDescription

matchesRegularExpression() public static

matchesRegularExpression(string $pattern): RegularExpression

Parameters

string $pattern

Returns

RegularExpression

never() public static

never(): InvokedCountMatcher

Returns a matcher that matches when the method is never executed.

Returns

InvokedCountMatcher

objectEquals() public static

objectEquals(object $object, string $method = 'equals'): ObjectEquals

Parameters

object $object
string $method optional

Returns

ObjectEquals

objectHasAttribute() public static

objectHasAttribute(mixed $attributeName): ObjectHasAttribute

Parameters

$attributeName

Returns

ObjectHasAttribute

onConsecutiveCalls() public static

onConsecutiveCalls(mixed ...$args): ConsecutiveCallsStub

Parameters

...$args

Returns

ConsecutiveCallsStub

onNotSuccessfulTest() protected

onNotSuccessfulTest(Throwable $t): void

This method is called when a test method did not execute successfully.

Parameters

Throwable $t

Returns

void

Throws

Throwable

once() public static

once(): InvokedCountMatcher

Returns a matcher that matches when the method is executed exactly once.

Returns

InvokedCountMatcher

prophesize() protected

prophesize(?string $classOrInterface = null): ObjectProphecy

Parameters

?string $classOrInterface optional

Returns

ObjectProphecy

Throws

Prophecy\Exception\Doubler\ClassNotFoundException

Prophecy\Exception\Doubler\DoubleException

Prophecy\Exception\Doubler\InterfaceNotFoundException

provides() public

provides(): list<ExecutionOrderDependency>

Returns the normalized test name as class::method.

Returns

list<ExecutionOrderDependency>

recordDoubledType() protected

recordDoubledType(string $originalClassName): void

Parameters

string $originalClassName

Returns

void

registerComparator() public

registerComparator(Comparator $comparator): void

Parameters

Comparator $comparator

Returns

void

registerMockObject() public

registerMockObject(MockObject $mockObject): void

Parameters

MockObject $mockObject

Returns

void

removePlugins() public

removePlugins(array<string> $names = []): void

Remove plugins from the global plugin collection.

Useful in test case teardown methods.

Parameters

array<string> $names optional

A list of plugins you want to remove.

Returns

void

requires() public

requires(): list<ExecutionOrderDependency>

Returns a list of normalized dependency names, class::method.

This list can differ from the raw dependencies as the resolver has no need for the [!][shallow]clone prefix that is filtered out during normalization.

Returns

list<ExecutionOrderDependency>

resetCount() public static

resetCount(): void

Reset the assertion counter.

Returns

void

returnArgument() public static

returnArgument(int $argumentIndex): ReturnArgumentStub

Parameters

int $argumentIndex

Returns

ReturnArgumentStub

returnCallback() public static

returnCallback(mixed $callback): ReturnCallbackStub

Parameters

$callback

Returns

ReturnCallbackStub

returnSelf() public static

returnSelf(): ReturnSelfStub

Returns the current object.

This method is useful when mocking a fluent interface.

Returns

ReturnSelfStub

returnValue() public static

returnValue(mixed $value): ReturnStub

Parameters

$value

Returns

ReturnStub

returnValueMap() public static

returnValueMap(array $valueMap): ReturnValueMapStub

Parameters

array $valueMap

Returns

ReturnValueMapStub

run() public

run(TestResult $result = null): TestResult

Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.

Parameters

TestResult $result optional

Returns

TestResult

Throws

SebastianBergmann\CodeCoverage\InvalidArgumentException

SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException

SebastianBergmann\RecursionContext\InvalidArgumentException

CodeCoverageException

UtilException

runBare() public

runBare(): void

Returns

void

Throws

Throwable

runTest() protected

runTest()

Override to run the test and assert its state.

Throws

SebastianBergmann\ObjectEnumerator\InvalidArgumentException

AssertionFailedError

Exception

ExpectationFailedException

Throwable

setAppNamespace() public static

setAppNamespace(string $appNamespace = 'TestApp'): string|null

Set the app namespace

Parameters

string $appNamespace optional

The app namespace, defaults to "TestApp".

Returns

string|null

setBackupGlobals() public

setBackupGlobals(?bool $backupGlobals): void

Parameters

?bool $backupGlobals

Returns

void

setBackupStaticAttributes() public

setBackupStaticAttributes(?bool $backupStaticAttributes): void

Parameters

?bool $backupStaticAttributes

Returns

void

setBeStrictAboutChangesToGlobalState() public

setBeStrictAboutChangesToGlobalState(?bool $beStrictAboutChangesToGlobalState): void

Parameters

?bool $beStrictAboutChangesToGlobalState

Returns

void

setDependencies() public

setDependencies(list<ExecutionOrderDependency> $dependencies): void

Parameters

list<ExecutionOrderDependency> $dependencies

Returns

void

setDependencyInput() public

setDependencyInput(array $dependencyInput): void

Parameters

array $dependencyInput

Returns

void

setGroups() public

setGroups(array $groups): void

Parameters

array $groups

Returns

void

setInIsolation() public

setInIsolation(bool $inIsolation): void

Parameters

bool $inIsolation

Returns

void

setLocale() protected

setLocale(mixed ...$args): void

This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.

Parameters

...$args

Returns

void

Throws

Exception

setName() public

setName(string $name): void

Parameters

string $name

Returns

void

setOutputCallback() public

setOutputCallback(callable $callback): void

Parameters

callable $callback

Returns

void

setPreserveGlobalState() public

setPreserveGlobalState(bool $preserveGlobalState): void

Parameters

bool $preserveGlobalState

Returns

void

setRegisterMockObjectsFromTestArgumentsRecursively() public

setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag): void

Parameters

bool $flag

Returns

void

setResult() public

setResult(mixed $result): void

Parameters

$result

Returns

void

setRunClassInSeparateProcess() public

setRunClassInSeparateProcess(bool $runClassInSeparateProcess): void

Parameters

bool $runClassInSeparateProcess

Returns

void

setRunTestInSeparateProcess() public

setRunTestInSeparateProcess(bool $runTestInSeparateProcess): void

Parameters

bool $runTestInSeparateProcess

Returns

void

setTableLocator() public

setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this

Sets the table locator.

Parameters

Cake\ORM\Locator\LocatorInterface $tableLocator

LocatorInterface instance.

Returns

$this

setTestResultObject() public

setTestResultObject(TestResult $result): void

Parameters

TestResult $result

Returns

void

setUp() protected

setUp(): void

Setup the test case, backup the static object values so they can be restored. Specifically backs up the contents of Configure and paths in App if they have not already been backed up.

Returns

void

setUpBeforeClass() public static

setUpBeforeClass(): void

This method is called before the first test of this test class is run.

Returns

void

setupFixtures() protected

setupFixtures(): void

Initialized and loads any use fixtures.

Returns

void

skipIf() public

skipIf(bool $shouldSkip, string $message = ''): bool

Overrides SimpleTestCase::skipIf to provide a boolean return value

Parameters

bool $shouldSkip

Whether the test should be skipped.

string $message optional

The message to display.

Returns

bool

skipUnless() protected

skipUnless(bool $condition, string $message = ''): bool

Compatibility function for skipping.

Parameters

bool $condition

Condition to trigger skipping

string $message optional

Message for skip

Returns

bool

sortId() public

sortId(): string

Returns

string

stringContains() public static

stringContains(string $string, bool $case = true): StringContains

Parameters

string $string
bool $case optional

Returns

StringContains

stringEndsWith() public static

stringEndsWith(string $suffix): StringEndsWith

Parameters

string $suffix

Returns

StringEndsWith

stringStartsWith() public static

stringStartsWith(mixed $prefix): StringStartsWith

Parameters

$prefix

Returns

StringStartsWith

tearDown() protected

tearDown(): void

teardown any static object changes and restore them.

Returns

void

tearDownAfterClass() public static

tearDownAfterClass(): void

This method is called after the last test of this test class is run.

Returns

void

teardownFixtures() protected

teardownFixtures(): void

Unloads any use fixtures.

Returns

void

throwException() public static

throwException(Throwable $exception): ExceptionStub

Parameters

Throwable $exception

Returns

ExceptionStub

toString() public

toString(): string

Returns a string representation of the test case.

Returns

string

Throws

SebastianBergmann\RecursionContext\InvalidArgumentException

Exception

usesDataProvider() public

usesDataProvider(): bool

Returns

bool

withErrorReporting() public

withErrorReporting(int $errorLevel, callable $callable): void

Helper method for tests that needs to use error_reporting()

Parameters

int $errorLevel

value of error_reporting() that needs to use

callable $callable

callable function that will receive asserts

Returns

void

Property Detail

$_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 deprecated

By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually

Type

bool

$backupGlobals protected

Type

?bool

$backupGlobalsBlacklist protected deprecated

Type

string[]

$backupGlobalsExcludeList protected

Type

string[]

$backupStaticAttributes protected

Type

bool

$backupStaticAttributesBlacklist protected deprecated

Type

array<string, array<int, string>>

$backupStaticAttributesExcludeList protected

Type

array<string, array<int, string>>

$defaultTable protected

This object's default table alias.

Type

string|null

$dropTables public deprecated

Control table create/drops on each test method.

If true, tables will still be dropped at the end of each test runner execution.

Type

bool

$fixtureManager public static

The class responsible for managing the creation, loading and removing of fixtures

Type

Cake\TestSuite\Fixture\FixtureManager|null

$fixtureStrategy protected

Type

Cake\TestSuite\Fixture\FixtureStrategyInterface|null

$fixtures protected

Fixtures used by this test case.

Type

array<string>

$preserveGlobalState protected

Type

bool

$providedTests protected

Type

list<ExecutionOrderDependency>

$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.4/class-Cake.TestSuite.TestCase.html