TestCase
class TestCase extends Assert implements Test, SelfDescribing (View source)
A TestCase defines the fixture to run multiple tests.
To define a TestCase
1) Implement a subclass of PHPUnit\Framework\TestCase. 2) Define instance variables that store the state of the fixture. 3) Initialize the fixture state by overriding setUp(). 4) Clean-up after a test by overriding tearDown().
Each test runs in its own fixture so there can be no side effects among test runs.
Here is an example:
value1 = 2;
$this->value2 = 3;
}
}
?>
For each test implement a method which interacts with the fixture. Verify the expected results with assertions specified by calling assert with a boolean.
assertTrue($this->value1 + $this->value2 == 5);
}
?>
Properties
protected bool | $backupGlobals | Enable or disable the backup and restoration of the $GLOBALS array. | |
protected array | $backupGlobalsBlacklist | ||
protected bool | $backupStaticAttributes | Enable or disable the backup and restoration of static attributes. | |
protected array | $backupStaticAttributesBlacklist | ||
protected bool | $runTestInSeparateProcess | Whether or not this test is to be run in a separate PHP process. | |
protected bool | $preserveGlobalState | Whether or not this test should preserve the global state when running in a separate PHP process. |
Methods
Asserts that an array has a specified key.
Asserts that an array has a specified subset.
Asserts that an array does not have a specified key.
Asserts that a haystack contains a needle.
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains a needle.
Asserts that a haystack does not contain a needle.
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain a needle.
Asserts that a haystack contains only values of a given type.
Asserts that a haystack contains only instances of a given classname
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains only values of a given type.
Asserts that a haystack does not contain only values of a given type.
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain only values of a given type.
Asserts the number of elements of an array, Countable or Traversable.
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
Asserts the number of elements of an array, Countable or Traversable.
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
Asserts that two variables are equal.
Asserts that a variable is equal to an attribute of an object.
Asserts that two variables are not equal.
Asserts that a variable is not equal to an attribute of an object.
Asserts that a variable is empty.
Asserts that a static attribute of a class or an attribute of an object is empty.
Asserts that a variable is not empty.
Asserts that a static attribute of a class or an attribute of an object is not empty.
Asserts that a value is greater than another value.
Asserts that an attribute is greater than another value.
Asserts that a value is greater than or equal to another value.
Asserts that an attribute is greater than or equal to another value.
Asserts that a value is smaller than another value.
Asserts that an attribute is smaller than another value.
Asserts that a value is smaller than or equal to another value.
Asserts that an attribute is smaller than or equal to another value.
Asserts that the contents of one file is equal to the contents of another file.
Asserts that the contents of one file is not equal to the contents of another file.
Asserts that the contents of a string is equal to the contents of a file.
Asserts that the contents of a string is not equal to the contents of a file.
Asserts that a file/dir is readable.
Asserts that a file/dir exists and is not readable.
Asserts that a file/dir exists and is writable.
Asserts that a file/dir exists and is not writable.
Asserts that a directory exists.
Asserts that a directory does not exist.
Asserts that a directory exists and is readable.
Asserts that a directory exists and is not readable.
Asserts that a directory exists and is writable.
Asserts that a directory exists and is not writable.
Asserts that a file exists.
Asserts that a file does not exist.
Asserts that a file exists and is readable.
Asserts that a file exists and is not readable.
Asserts that a file exists and is writable.
Asserts that a file exists and is not writable.
Asserts that a condition is true.
Asserts that a condition is not true.
Asserts that a condition is false.
Asserts that a condition is not false.
Asserts that a variable is not null.
Asserts that a variable is finite.
Asserts that a variable is infinite.
Asserts that a class has a specified attribute.
Asserts that a class does not have a specified attribute.
Asserts that a class has a specified static attribute.
Asserts that a class does not have a specified static attribute.
Asserts that an object has a specified attribute.
Asserts that an object does not have a specified attribute.
Asserts that two variables have the same type and value.
Asserts that a variable and an attribute of an object have the same type and value.
Asserts that two variables do not have the same type and value.
Asserts that a variable and an attribute of an object do not have the same type and value.
Asserts that a variable is of a given type.
Asserts that an attribute is of a given type.
Asserts that a variable is not of a given type.
Asserts that an attribute is of a given type.
Asserts that a variable is of a given type.
Asserts that an attribute is of a given type.
Asserts that a variable is not of a given type.
Asserts that an attribute is of a given type.
Asserts that a string matches a given regular expression.
Asserts that a string does not match a given regular expression.
Assert that the size of two arrays (or Countable
or Traversable
objects)
is the same.
Assert that the size of two arrays (or Countable
or Traversable
objects)
is not the same.
Asserts that a string matches a given format string.
Asserts that a string does not match a given format string.
Asserts that a string matches a given format file.
Asserts that a string does not match a given format string.
Asserts that a string starts with a given prefix.
Asserts that a string starts not with a given prefix.
Asserts that a string ends with a given suffix.
Asserts that a string ends not with a given suffix.
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 not equal.
Asserts that two XML documents are equal.
Asserts that two XML documents are not equal.
Asserts that a hierarchy of DOMElements matches.
Evaluates a PHPUnit\Framework\Constraint matcher object.
Asserts that a string is a valid JSON string.
Asserts that two given JSON encoded objects or arrays are equal.
Asserts that two given JSON encoded objects or arrays are not equal.
Asserts that the generated JSON encoded object and the content of the given file are equal.
Asserts that the generated JSON encoded object and the content of the given file are not equal.
Asserts that two JSON files are equal.
Asserts that two JSON files are not equal.
No description
No description
No description
No description
No description
Returns the value of an attribute of a class or an object.
Returns the value of a static attribute.
Returns the value of an object's attribute.
Constructs a test case with the given name.
Returns a string representation of the test case.
Counts the number of test cases executed by run(TestResult result).
No description
No description
Returns the annotations for this test.
Gets the name of a TestCase.
Returns the size of the test.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Sets up an expectation for an exception to be raised by the code under test.
No description
No description
No description
No description
No description
Returns the status of this test.
No description
Returns the status message of this test.
Returns whether or not this test has failed.
Runs the bare test sequence.
Override to run the test and assert its state.
Verifies the mock object expectations.
Sets the name of a TestCase.
Sets the dependencies of a TestCase.
Returns true if the tests has dependencies
Sets
No description
Calling this method in setUp() has no effect!
Calling this method in setUp() has no effect!
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
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.
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
Returns a builder object to create mock objects using a fluent interface.
Returns a test double for the specified class.
Returns a configured test double for the specified class.
Returns a partial test double for the specified class.
Returns a test proxy for the specified class.
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.
Returns a mock object based on the given WSDL file.
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 an object for the specified trait.
No description
Adds a value to the assertion counter.
Returns the number of assertions performed by this test.
Returns a matcher that matches when the method is executed zero or more times.
Returns a matcher that matches when the method is never executed.
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 exactly once.
Returns a matcher that matches when the method is executed exactly $count times.
Returns a matcher that matches when the method is executed at most N times.
Returns a matcher that matches when the method is executed at the given index.
No description
No description
No description
No description
Returns the current object.
No description
No description
No description
No description
Gets the data set description of a TestCase.
Gets the data set of a TestCase.
Creates a default TestResult object.
No description
This method is called before the first test of this test class is run.
Sets up the fixture, for example, open a network connection.
Performs assertions shared by all tests of a test case.
Performs assertions shared by all tests of a test case.
Tears down the fixture, for example, close a network connection.
This method is called after the last test of this test class is run.
This method is called when a test method did not execute successfully.
Performs custom preparations on the process isolation template.
Details
static
assertArrayHasKey(mixed $key, array|ArrayAccess $array, string $message = '')
Asserts that an array has a specified key.
static
assertArraySubset(array|ArrayAccess $subset, array|ArrayAccess $array, bool $strict = false, string $message = '')
Asserts that an array has a specified subset.
static
assertArrayNotHasKey(mixed $key, array|ArrayAccess $array, string $message = '')
Asserts that an array does not have a specified key.
static
assertContains(mixed $needle, mixed $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
Asserts that a haystack contains a needle.
static
assertAttributeContains(mixed $needle, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains a needle.
static
assertNotContains(mixed $needle, mixed $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
Asserts that a haystack does not contain a needle.
static
assertAttributeNotContains(mixed $needle, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain a needle.
static
assertContainsOnly(string $type, mixed $haystack, bool $isNativeType = null, string $message = '')
Asserts that a haystack contains only values of a given type.
static
assertContainsOnlyInstancesOf(string $classname, array|Traversable $haystack, string $message = '')
Asserts that a haystack contains only instances of a given classname
static
assertAttributeContainsOnly(string $type, string $haystackAttributeName, string|object $haystackClassOrObject, bool $isNativeType = null, string $message = '')
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object contains only values of a given type.
static
assertNotContainsOnly(string $type, mixed $haystack, bool $isNativeType = null, string $message = '')
Asserts that a haystack does not contain only values of a given type.
static
assertAttributeNotContainsOnly(string $type, string $haystackAttributeName, string|object $haystackClassOrObject, bool $isNativeType = null, string $message = '')
Asserts that a haystack that is stored in a static attribute of a class or an attribute of an object does not contain only values of a given type.
static
assertCount(int $expectedCount, mixed $haystack, string $message = '')
Asserts the number of elements of an array, Countable or Traversable.
static
assertAttributeCount(int $expectedCount, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
static
assertNotCount(int $expectedCount, mixed $haystack, string $message = '')
Asserts the number of elements of an array, Countable or Traversable.
static
assertAttributeNotCount(int $expectedCount, string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')
Asserts the number of elements of an array, Countable or Traversable that is stored in an attribute.
static
assertEquals(mixed $expected, mixed $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
Asserts that two variables are equal.
static
assertAttributeEquals(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
Asserts that a variable is equal to an attribute of an object.
static
assertNotEquals(mixed $expected, mixed $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
Asserts that two variables are not equal.
static
assertAttributeNotEquals(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
Asserts that a variable is not equal to an attribute of an object.
static
assertEmpty(mixed $actual, string $message = '')
Asserts that a variable is empty.
static
assertAttributeEmpty(string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')
Asserts that a static attribute of a class or an attribute of an object is empty.
static
assertNotEmpty(mixed $actual, string $message = '')
Asserts that a variable is not empty.
static
assertAttributeNotEmpty(string $haystackAttributeName, string|object $haystackClassOrObject, string $message = '')
Asserts that a static attribute of a class or an attribute of an object is not empty.
static
assertGreaterThan(mixed $expected, mixed $actual, string $message = '')
Asserts that a value is greater than another value.
static
assertAttributeGreaterThan(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')
Asserts that an attribute is greater than another value.
static
assertGreaterThanOrEqual(mixed $expected, mixed $actual, string $message = '')
Asserts that a value is greater than or equal to another value.
static
assertAttributeGreaterThanOrEqual(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')
Asserts that an attribute is greater than or equal to another value.
static
assertLessThan(mixed $expected, mixed $actual, string $message = '')
Asserts that a value is smaller than another value.
static
assertAttributeLessThan(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')
Asserts that an attribute is smaller than another value.
static
assertLessThanOrEqual(mixed $expected, mixed $actual, string $message = '')
Asserts that a value is smaller than or equal to another value.
static
assertAttributeLessThanOrEqual(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')
Asserts that an attribute is smaller than or equal to another value.
static
assertFileEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)
Asserts that the contents of one file is equal to the contents of another file.
static
assertFileNotEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)
Asserts that the contents of one file is not equal to the contents of another file.
static
assertStringEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)
Asserts that the contents of a string is equal to the contents of a file.
static
assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false)
Asserts that the contents of a string is not equal to the contents of a file.
static
assertIsReadable(string $filename, string $message = '')
Asserts that a file/dir is readable.
static
assertNotIsReadable(string $filename, string $message = '')
Asserts that a file/dir exists and is not readable.
static
assertIsWritable(string $filename, string $message = '')
Asserts that a file/dir exists and is writable.
static
assertNotIsWritable(string $filename, string $message = '')
Asserts that a file/dir exists and is not writable.
static
assertDirectoryExists(string $directory, string $message = '')
Asserts that a directory exists.
static
assertDirectoryNotExists(string $directory, string $message = '')
Asserts that a directory does not exist.
static
assertDirectoryIsReadable(string $directory, string $message = '')
Asserts that a directory exists and is readable.
static
assertDirectoryNotIsReadable(string $directory, string $message = '')
Asserts that a directory exists and is not readable.
static
assertDirectoryIsWritable(string $directory, string $message = '')
Asserts that a directory exists and is writable.
static
assertDirectoryNotIsWritable(string $directory, string $message = '')
Asserts that a directory exists and is not writable.
static
assertFileExists(string $filename, string $message = '')
Asserts that a file exists.
static
assertFileNotExists(string $filename, string $message = '')
Asserts that a file does not exist.
static
assertFileIsReadable(string $file, string $message = '')
Asserts that a file exists and is readable.
static
assertFileNotIsReadable(string $file, string $message = '')
Asserts that a file exists and is not readable.
static
assertFileIsWritable(string $file, string $message = '')
Asserts that a file exists and is writable.
static
assertFileNotIsWritable(string $file, string $message = '')
Asserts that a file exists and is not writable.
static
assertTrue(bool $condition, string $message = '')
Asserts that a condition is true.
static
assertNotTrue(bool $condition, string $message = '')
Asserts that a condition is not true.
static
assertFalse(bool $condition, string $message = '')
Asserts that a condition is false.
static
assertNotFalse(bool $condition, string $message = '')
Asserts that a condition is not false.
static
assertNull(mixed $actual, string $message = '')
Asserts that a variable is null.
static
assertNotNull(mixed $actual, string $message = '')
Asserts that a variable is not null.
static
assertFinite(mixed $actual, string $message = '')
Asserts that a variable is finite.
static
assertInfinite(mixed $actual, string $message = '')
Asserts that a variable is infinite.
static
assertNan(mixed $actual, string $message = '')
Asserts that a variable is nan.
static
assertClassHasAttribute(string $attributeName, string $className, string $message = '')
Asserts that a class has a specified attribute.
static
assertClassNotHasAttribute(string $attributeName, string $className, string $message = '')
Asserts that a class does not have a specified attribute.
static
assertClassHasStaticAttribute(string $attributeName, string $className, string $message = '')
Asserts that a class has a specified static attribute.
static
assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = '')
Asserts that a class does not have a specified static attribute.
static
assertObjectHasAttribute(string $attributeName, object $object, string $message = '')
Asserts that an object has a specified attribute.
static
assertObjectNotHasAttribute(string $attributeName, object $object, string $message = '')
Asserts that an object does not have a specified attribute.
static
assertSame(mixed $expected, mixed $actual, string $message = '')
Asserts that two variables have the same type and value.
Used on objects, it asserts that two variables reference the same object.
static
assertAttributeSame(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')
Asserts that a variable and an attribute of an object have the same type and value.
static
assertNotSame(mixed $expected, mixed $actual, string $message = '')
Asserts that two variables do not have the same type and value.
Used on objects, it asserts that two variables do not reference the same object.
static
assertAttributeNotSame(mixed $expected, string $actualAttributeName, string|object $actualClassOrObject, string $message = '')
Asserts that a variable and an attribute of an object do not have the same type and value.
static
assertInstanceOf(string $expected, mixed $actual, string $message = '')
Asserts that a variable is of a given type.
static
assertAttributeInstanceOf(string $expected, string $attributeName, string|object $classOrObject, string $message = '')
Asserts that an attribute is of a given type.
static
assertNotInstanceOf(string $expected, mixed $actual, string $message = '')
Asserts that a variable is not of a given type.
static
assertAttributeNotInstanceOf(string $expected, string $attributeName, string|object $classOrObject, string $message = '')
Asserts that an attribute is of a given type.
static
assertInternalType(string $expected, mixed $actual, string $message = '')
Asserts that a variable is of a given type.
static
assertAttributeInternalType(string $expected, string $attributeName, string|object $classOrObject, string $message = '')
Asserts that an attribute is of a given type.
static
assertNotInternalType(string $expected, mixed $actual, string $message = '')
Asserts that a variable is not of a given type.
static
assertAttributeNotInternalType(string $expected, string $attributeName, string|object $classOrObject, string $message = '')
Asserts that an attribute is of a given type.
static
assertRegExp(string $pattern, string $string, string $message = '')
Asserts that a string matches a given regular expression.
static
assertNotRegExp(string $pattern, string $string, string $message = '')
Asserts that a string does not match a given regular expression.
static
assertSameSize(array|Countable|Traversable $expected, array|Countable|Traversable $actual, string $message = '')
Assert that the size of two arrays (or Countable
or Traversable
objects)
is the same.
static
assertNotSameSize(array|Countable|Traversable $expected, array|Countable|Traversable $actual, string $message = '')
Assert that the size of two arrays (or Countable
or Traversable
objects)
is not the same.
static
assertStringMatchesFormat(string $format, string $string, string $message = '')
Asserts that a string matches a given format string.
static
assertStringNotMatchesFormat(string $format, string $string, string $message = '')
Asserts that a string does not match a given format string.
static
assertStringMatchesFormatFile(string $formatFile, string $string, string $message = '')
Asserts that a string matches a given format file.
static
assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = '')
Asserts that a string does not match a given format string.
static
assertStringStartsWith(string $prefix, string $string, string $message = '')
Asserts that a string starts with a given prefix.
static
assertStringStartsNotWith(string $prefix, string $string, string $message = '')
Asserts that a string starts not with a given prefix.
static
assertStringEndsWith(string $suffix, string $string, string $message = '')
Asserts that a string ends with a given suffix.
static
assertStringEndsNotWith(string $suffix, string $string, string $message = '')
Asserts that a string ends not with a given suffix.
static
assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = '')
Asserts that two XML files are equal.
static
assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = '')
Asserts that two XML files are not equal.
static
assertXmlStringEqualsXmlFile(string $expectedFile, string|DOMDocument $actualXml, string $message = '')
Asserts that two XML documents are equal.
static
assertXmlStringNotEqualsXmlFile(string $expectedFile, string|DOMDocument $actualXml, string $message = '')
Asserts that two XML documents are not equal.
static
assertXmlStringEqualsXmlString(string|DOMDocument $expectedXml, string|DOMDocument $actualXml, string $message = '')
Asserts that two XML documents are equal.
static
assertXmlStringNotEqualsXmlString(string|DOMDocument $expectedXml, string|DOMDocument $actualXml, string $message = '')
Asserts that two XML documents are not equal.
static
assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = '')
Asserts that a hierarchy of DOMElements matches.
static
assertThat(mixed $value, Constraint $constraint, string $message = '')
Evaluates a PHPUnit\Framework\Constraint matcher object.
static
assertJson(string $actualJson, string $message = '')
Asserts that a string is a valid JSON string.
static
assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = '')
Asserts that two given JSON encoded objects or arrays are equal.
static
assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = '')
Asserts that two given JSON encoded objects or arrays are not equal.
static
assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = '')
Asserts that the generated JSON encoded object and the content of the given file are equal.
static
assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = '')
Asserts that the generated JSON encoded object and the content of the given file are not equal.
static
assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = '')
Asserts that two JSON files are equal.
static
assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = '')
Asserts that two JSON files are not equal.
static LogicalAnd
logicalAnd()
static LogicalNot
logicalNot(Constraint $constraint)
static LogicalXor
logicalXor()
static IsAnything
anything()
static IsInfinite
isInfinite()
static Attribute
attribute(Constraint $constraint, string $attributeName)
static TraversableContains
contains(mixed $value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
static TraversableContainsOnly
containsOnly(string $type)
static TraversableContainsOnly
containsOnlyInstancesOf(string $classname)
static ArrayHasKey
arrayHasKey(mixed $key)
static IsEqual
equalTo(mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
static Attribute
attributeEqualTo(string $attributeName, mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
static IsWritable
isWritable()
static IsReadable
isReadable()
static DirectoryExists
directoryExists()
static FileExists
fileExists()
static GreaterThan
greaterThan(mixed $value)
static ClassHasAttribute
classHasAttribute(string $attributeName)
static ClassHasStaticAttribute
classHasStaticAttribute(string $attributeName)
static ObjectHasAttribute
objectHasAttribute(string $attributeName)
static IsIdentical
identicalTo(mixed $value)
static IsInstanceOf
isInstanceOf(string $className)
static RegularExpression
matchesRegularExpression(string $pattern)
static StringMatchesFormatDescription
matches(string $string)
static StringStartsWith
stringStartsWith(mixed $prefix)
static StringContains
stringContains(string $string, bool $case = true)
static StringEndsWith
stringEndsWith(mixed $suffix)
static mixed
readAttribute(string|object $classOrObject, string $attributeName)
Returns the value of an attribute of a class or an object.
This also works for attributes that are declared protected or private.
static mixed
getStaticAttribute(string $className, string $attributeName)
Returns the value of a static attribute.
This also works for attributes that are declared protected or private.
static mixed
getObjectAttribute(object $object, string $attributeName)
Returns the value of an object's attribute.
This also works for attributes that are declared protected or private.
at line 342
__construct(string $name = null, array $data = [], string $dataName = '')
Constructs a test case with the given name.
at line 357
string
toString()
Returns a string representation of the test case.
at line 375
int
count()
Counts the number of test cases executed by run(TestResult result).
at line 380
getGroups()
at line 388
setGroups(array $groups)
at line 398
array
getAnnotations()
Returns the annotations for this test.
at line 413
string
getName(bool $withDataSet = true)
Gets the name of a TestCase.
at line 427
int
getSize()
Returns the size of the test.
at line 438
bool
hasSize()
at line 446
bool
isSmall()
at line 454
bool
isMedium()
at line 462
bool
isLarge()
at line 470
string
getActualOutput()
at line 482
bool
hasOutput()
at line 498
bool
doesNotPerformAssertions()
at line 508
expectOutputRegex(string $expectedRegex)
at line 522
expectOutputString(string $expectedString)
at line 536
bool
hasExpectationOnOutput()
at line 544
null|string
getExpectedException()
at line 552
null|int|string
getExpectedExceptionCode()
at line 560
string
getExpectedExceptionMessage()
at line 568
string
getExpectedExceptionMessageRegExp()
at line 576
expectException(string $exception)
at line 590
expectExceptionCode(int|string $code)
at line 604
expectExceptionMessage(string $message)
at line 618
expectExceptionMessageRegExp(string $messageRegExp)
at line 632
expectExceptionObject(Exception $exception)
Sets up an expectation for an exception to be raised by the code under test.
Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.
at line 642
setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag)
at line 651
protected
setExpectedExceptionFromAnnotation()
at line 679
setUseErrorHandler(bool $useErrorHandler)
at line 684
protected
setUseErrorHandlerFromAnnotation()
at line 699
protected
checkRequirements()
at line 720
int
getStatus()
Returns the status of this test.
at line 725
markAsRisky()
at line 735
string
getStatusMessage()
Returns the status message of this test.
at line 745
bool
hasFailed()
Returns whether or not this test has failed.
at line 763
TestResult
run(TestResult $result = null)
Runs the test case and collects the results in a TestResult object.
If no TestResult object is passed a new one will be created.
at line 909
runBare()
Runs the bare test sequence.
at line 1051
protected mixed
runTest()
Override to run the test and assert its state.
at line 1180
protected
verifyMockObjects()
Verifies the mock object expectations.
at line 1218
setName(string $name)
Sets the name of a TestCase.
at line 1228
setDependencies(array $dependencies)
Sets the dependencies of a TestCase.
at line 1238
bool
hasDependencies()
Returns true if the tests has dependencies
at line 1248
setDependencyInput(array $dependencyInput)
Sets
at line 1256
setBeStrictAboutChangesToGlobalState(bool $beStrictAboutChangesToGlobalState)
at line 1266
setBackupGlobals(bool $backupGlobals)
Calling this method in setUp() has no effect!
at line 1278
setBackupStaticAttributes(bool $backupStaticAttributes)
Calling this method in setUp() has no effect!
at line 1291
setRunTestInSeparateProcess(bool $runTestInSeparateProcess)
at line 1307
setRunClassInSeparateProcess(bool $runClassInSeparateProcess)
at line 1323
setPreserveGlobalState(bool $preserveGlobalState)
at line 1337
setInIsolation(bool $inIsolation)
at line 1349
bool
isInIsolation()
at line 1357
mixed
getResult()
at line 1365
setResult(mixed $result)
at line 1375
setOutputCallback(callable $callback)
at line 1387
TestResult
getTestResultObject()
at line 1395
setTestResultObject(TestResult $result)
at line 1403
registerMockObject(PHPUnit_Framework_MockObject_MockObject $mockObject)
at line 1418
protected
iniSet(string $varName, string $newValue)
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
at line 1448
protected
setLocale()
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
at line 1494
PHPUnit_Framework_MockObject_MockBuilder
getMockBuilder(string|string[] $className)
Returns a builder object to create mock objects using a fluent interface.
at line 1508
protected PHPUnit_Framework_MockObject_MockObject
createMock(string $originalClassName)
Returns a test double for the specified class.
at line 1528
protected PHPUnit_Framework_MockObject_MockObject
createConfiguredMock(string $originalClassName, array $configuration)
Returns a configured test double for the specified class.
at line 1549
protected PHPUnit_Framework_MockObject_MockObject
createPartialMock(string $originalClassName, array $methods)
Returns a partial test double for the specified class.
at line 1570
protected PHPUnit_Framework_MockObject_MockObject
createTestProxy(string $originalClassName, array $constructorArguments = [])
Returns a test proxy for the specified class.
at line 1594
protected string
getMockClass(string $originalClassName, array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = false, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = false)
Mocks the specified class and returns the name of the mocked class.
at line 1628
protected PHPUnit_Framework_MockObject_MockObject
getMockForAbstractClass(string $originalClassName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false)
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).
at line 1658
protected PHPUnit_Framework_MockObject_MockObject
getMockFromWsdl(string $wsdlFile, string $originalClassName = '', string $mockClassName = '', array $methods = [], bool $callOriginalConstructor = true, array $options = [])
Returns a mock object based on the given WSDL file.
at line 1708
protected PHPUnit_Framework_MockObject_MockObject
getMockForTrait(string $traitName, array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, array $mockedMethods = [], bool $cloneArguments = false)
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.
at line 1740
protected object
getObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true)
Returns an object for the specified trait.
at line 1759
protected ObjectProphecy
prophesize(string|null $classOrInterface = null)
at line 1769
addToAssertionCount(int $count)
Adds a value to the assertion counter.
at line 1779
int
getNumAssertions()
Returns the number of assertions performed by this test.
at line 1790
static PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
any()
Returns a matcher that matches when the method is executed zero or more times.
at line 1800
static PHPUnit_Framework_MockObject_Matcher_InvokedCount
never()
Returns a matcher that matches when the method is never executed.
at line 1813
static PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastCount
atLeast(int $requiredInvocations)
Returns a matcher that matches when the method is executed at least N times.
at line 1825
static PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce
atLeastOnce()
Returns a matcher that matches when the method is executed at least once.
at line 1835
static PHPUnit_Framework_MockObject_Matcher_InvokedCount
once()
Returns a matcher that matches when the method is executed exactly once.
at line 1848
static PHPUnit_Framework_MockObject_Matcher_InvokedCount
exactly(int $count)
Returns a matcher that matches when the method is executed exactly $count times.
at line 1861
static PHPUnit_Framework_MockObject_Matcher_InvokedAtMostCount
atMost(int $allowedInvocations)
Returns a matcher that matches when the method is executed at most N times.
at line 1876
static PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
at(int $index)
Returns a matcher that matches when the method is executed at the given index.
at line 1886
static PHPUnit_Framework_MockObject_Stub_Return
returnValue(mixed $value)
at line 1896
static PHPUnit_Framework_MockObject_Stub_ReturnValueMap
returnValueMap(array $valueMap)
at line 1906
static PHPUnit_Framework_MockObject_Stub_ReturnArgument
returnArgument(int $argumentIndex)
at line 1918
static PHPUnit_Framework_MockObject_Stub_ReturnCallback
returnCallback(mixed $callback)
at line 1930
static PHPUnit_Framework_MockObject_Stub_ReturnSelf
returnSelf()
Returns the current object.
This method is useful when mocking a fluent interface.
at line 1940
static PHPUnit_Framework_MockObject_Stub_Exception
throwException(Throwable $exception)
at line 1950
static PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls
onConsecutiveCalls()
at line 1960
bool
usesDataProvider()
at line 1968
string
dataDescription()
at line 1973
registerComparator(Comparator $comparator)
at line 1987
string
getDataSetAsString(bool $includeData = true)
Gets the data set description of a TestCase.
at line 2013
protected array
getProvidedData()
Gets the data set of a TestCase.
at line 2023
protected TestResult
createResult()
Creates a default TestResult object.
at line 2028
protected
handleDependencies()
at line 2113
static
setUpBeforeClass()
This method is called before the first test of this test class is run.
at line 2121
protected
setUp()
Sets up the fixture, for example, open a network connection.
This method is called before a test is executed.
at line 2131
protected
assertPreConditions()
Performs assertions shared by all tests of a test case.
This method is called before the execution of a test starts and after setUp() is called.
at line 2141
protected
assertPostConditions()
Performs assertions shared by all tests of a test case.
This method is called before the execution of a test ends and before tearDown() is called.
at line 2149
protected
tearDown()
Tears down the fixture, for example, close a network connection.
This method is called after a test is executed.
at line 2156
static
tearDownAfterClass()
This method is called after the last test of this test class is run.
at line 2167
protected
onNotSuccessfulTest(Throwable $t)
This method is called when a test method did not execute successfully.
at line 2177
protected
prepareTemplate(Text_Template $template)
Performs custom preparations on the process isolation template.