PHPUnit_Framework_TestCase
class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_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 null.
Asserts that a variable is not null.
Asserts that a variable is finite.
Asserts that a variable is infinite.
Asserts that a variable is nan.
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.
Returns a PHPUnit_Framework_Constraint_And matcher object.
Returns a PHPUnit_Framework_Constraint_Or matcher object.
Returns a PHPUnit_Framework_Constraint_Not matcher object.
Returns a PHPUnit_Framework_Constraint_Xor matcher object.
Returns a PHPUnit_Framework_Constraint_IsAnything matcher object.
Returns a PHPUnit_Framework_Constraint_IsTrue matcher object.
Returns a PHPUnit_Framework_Constraint_Callback matcher object.
Returns a PHPUnit_Framework_Constraint_IsFalse matcher object.
Returns a PHPUnit_Framework_Constraint_IsJson matcher object.
Returns a PHPUnit_Framework_Constraint_IsNull matcher object.
Returns a PHPUnit_Framework_Constraint_IsFinite matcher object.
Returns a PHPUnit_Framework_Constraint_IsInfinite matcher object.
Returns a PHPUnit_Framework_Constraint_IsNan matcher object.
Returns a PHPUnit_Framework_Constraint_Attribute matcher object.
Returns a PHPUnit_Framework_Constraint_TraversableContains matcher object.
Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher object.
Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher object.
Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object.
Returns a PHPUnit_Framework_Constraint_IsEqual matcher object.
Returns a PHPUnit_Framework_Constraint_IsEqual matcher object that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher object.
Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object.
Returns a PHPUnit_Framework_Constraint_IsWritable matcher object.
Returns a PHPUnit_Framework_Constraint_IsReadable matcher object.
Returns a PHPUnit_Framework_Constraint_DirectoryExists matcher object.
Returns a PHPUnit_Framework_Constraint_FileExists matcher object.
Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object.
Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps a PHPUnit_Framework_Constraint_IsEqual and a PHPUnit_Framework_Constraint_GreaterThan matcher object.
Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object.
Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher object.
Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object.
Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object.
Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object.
Returns a PHPUnit_Framework_Constraint_IsType matcher object.
Returns a PHPUnit_Framework_Constraint_LessThan matcher object.
Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps a PHPUnit_Framework_Constraint_IsEqual and a PHPUnit_Framework_Constraint_LessThan matcher object.
Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object.
Returns a PHPUnit_Framework_Constraint_StringMatches matcher object.
Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object.
Returns a PHPUnit_Framework_Constraint_StringContains matcher object.
Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object.
Returns a PHPUnit_Framework_Constraint_Count matcher object.
Fails a test with the given message.
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.
Mark the test as incomplete.
Mark the test as skipped.
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
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 test case and collects the results in a TestResult object.
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
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 mock object for the specified class.
Returns a mock with disabled constructor object 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
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.
Get the mock object generator, creating it if it doesn't exist.
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 $actualXml, string $message = '')
Asserts that two XML documents are equal.
static
assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml, string $message = '')
Asserts that two XML documents are not equal.
static
assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml, string $message = '')
Asserts that two XML documents are equal.
static
assertXmlStringNotEqualsXmlString(string $expectedXml, string $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, PHPUnit_Framework_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 PHPUnit_Framework_Constraint_And
logicalAnd()
Returns a PHPUnit_Framework_Constraint_And matcher object.
static PHPUnit_Framework_Constraint_Or
logicalOr()
Returns a PHPUnit_Framework_Constraint_Or matcher object.
static PHPUnit_Framework_Constraint_Not
logicalNot(PHPUnit_Framework_Constraint $constraint)
Returns a PHPUnit_Framework_Constraint_Not matcher object.
static PHPUnit_Framework_Constraint_Xor
logicalXor()
Returns a PHPUnit_Framework_Constraint_Xor matcher object.
static PHPUnit_Framework_Constraint_IsAnything
anything()
Returns a PHPUnit_Framework_Constraint_IsAnything matcher object.
static PHPUnit_Framework_Constraint_IsTrue
isTrue()
Returns a PHPUnit_Framework_Constraint_IsTrue matcher object.
static PHPUnit_Framework_Constraint_Callback
callback(callable $callback)
Returns a PHPUnit_Framework_Constraint_Callback matcher object.
static PHPUnit_Framework_Constraint_IsFalse
isFalse()
Returns a PHPUnit_Framework_Constraint_IsFalse matcher object.
static PHPUnit_Framework_Constraint_IsJson
isJson()
Returns a PHPUnit_Framework_Constraint_IsJson matcher object.
static PHPUnit_Framework_Constraint_IsNull
isNull()
Returns a PHPUnit_Framework_Constraint_IsNull matcher object.
static PHPUnit_Framework_Constraint_IsFinite
isFinite()
Returns a PHPUnit_Framework_Constraint_IsFinite matcher object.
static PHPUnit_Framework_Constraint_IsInfinite
isInfinite()
Returns a PHPUnit_Framework_Constraint_IsInfinite matcher object.
static PHPUnit_Framework_Constraint_IsNan
isNan()
Returns a PHPUnit_Framework_Constraint_IsNan matcher object.
static PHPUnit_Framework_Constraint_Attribute
attribute(PHPUnit_Framework_Constraint $constraint, string $attributeName)
Returns a PHPUnit_Framework_Constraint_Attribute matcher object.
static PHPUnit_Framework_Constraint_TraversableContains
contains(mixed $value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
Returns a PHPUnit_Framework_Constraint_TraversableContains matcher object.
static PHPUnit_Framework_Constraint_TraversableContainsOnly
containsOnly(string $type)
Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher object.
static PHPUnit_Framework_Constraint_TraversableContainsOnly
containsOnlyInstancesOf(string $classname)
Returns a PHPUnit_Framework_Constraint_TraversableContainsOnly matcher object.
static PHPUnit_Framework_Constraint_ArrayHasKey
arrayHasKey(mixed $key)
Returns a PHPUnit_Framework_Constraint_ArrayHasKey matcher object.
static PHPUnit_Framework_Constraint_IsEqual
equalTo(mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
Returns a PHPUnit_Framework_Constraint_IsEqual matcher object.
static PHPUnit_Framework_Constraint_Attribute
attributeEqualTo(string $attributeName, mixed $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
Returns a PHPUnit_Framework_Constraint_IsEqual matcher object that is wrapped in a PHPUnit_Framework_Constraint_Attribute matcher object.
static PHPUnit_Framework_Constraint_IsEmpty
isEmpty()
Returns a PHPUnit_Framework_Constraint_IsEmpty matcher object.
static PHPUnit_Framework_Constraint_IsWritable
isWritable()
Returns a PHPUnit_Framework_Constraint_IsWritable matcher object.
static PHPUnit_Framework_Constraint_IsReadable
isReadable()
Returns a PHPUnit_Framework_Constraint_IsReadable matcher object.
static PHPUnit_Framework_Constraint_DirectoryExists
directoryExists()
Returns a PHPUnit_Framework_Constraint_DirectoryExists matcher object.
static PHPUnit_Framework_Constraint_FileExists
fileExists()
Returns a PHPUnit_Framework_Constraint_FileExists matcher object.
static PHPUnit_Framework_Constraint_GreaterThan
greaterThan(mixed $value)
Returns a PHPUnit_Framework_Constraint_GreaterThan matcher object.
static PHPUnit_Framework_Constraint_Or
greaterThanOrEqual(mixed $value)
Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps a PHPUnit_Framework_Constraint_IsEqual and a PHPUnit_Framework_Constraint_GreaterThan matcher object.
static PHPUnit_Framework_Constraint_ClassHasAttribute
classHasAttribute(string $attributeName)
Returns a PHPUnit_Framework_Constraint_ClassHasAttribute matcher object.
static PHPUnit_Framework_Constraint_ClassHasStaticAttribute
classHasStaticAttribute(string $attributeName)
Returns a PHPUnit_Framework_Constraint_ClassHasStaticAttribute matcher object.
static PHPUnit_Framework_Constraint_ObjectHasAttribute
objectHasAttribute(string $attributeName)
Returns a PHPUnit_Framework_Constraint_ObjectHasAttribute matcher object.
static PHPUnit_Framework_Constraint_IsIdentical
identicalTo(mixed $value)
Returns a PHPUnit_Framework_Constraint_IsIdentical matcher object.
static PHPUnit_Framework_Constraint_IsInstanceOf
isInstanceOf(string $className)
Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object.
static PHPUnit_Framework_Constraint_IsType
isType(string $type)
Returns a PHPUnit_Framework_Constraint_IsType matcher object.
static PHPUnit_Framework_Constraint_LessThan
lessThan(mixed $value)
Returns a PHPUnit_Framework_Constraint_LessThan matcher object.
static PHPUnit_Framework_Constraint_Or
lessThanOrEqual(mixed $value)
Returns a PHPUnit_Framework_Constraint_Or matcher object that wraps a PHPUnit_Framework_Constraint_IsEqual and a PHPUnit_Framework_Constraint_LessThan matcher object.
static PHPUnit_Framework_Constraint_PCREMatch
matchesRegularExpression(string $pattern)
Returns a PHPUnit_Framework_Constraint_PCREMatch matcher object.
static PHPUnit_Framework_Constraint_StringMatches
matches(string $string)
Returns a PHPUnit_Framework_Constraint_StringMatches matcher object.
static PHPUnit_Framework_Constraint_StringStartsWith
stringStartsWith(mixed $prefix)
Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object.
static PHPUnit_Framework_Constraint_StringContains
stringContains(string $string, bool $case = true)
Returns a PHPUnit_Framework_Constraint_StringContains matcher object.
static PHPUnit_Framework_Constraint_StringEndsWith
stringEndsWith(mixed $suffix)
Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object.
static PHPUnit_Framework_Constraint_Count
countOf(int $count)
Returns a PHPUnit_Framework_Constraint_Count matcher object.
static
fail(string $message = '')
Fails a test with the given message.
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.
static
markTestIncomplete(string $message = '')
Mark the test as incomplete.
static
markTestSkipped(string $message = '')
Mark the test as skipped.
static int
getCount()
Return the current assertion count.
static
resetCount()
Reset the assertion counter.
at line 294
__construct(string $name = null, array $data = [], string $dataName = '')
Constructs a test case with the given name.
at line 309
string
toString()
Returns a string representation of the test case.
at line 327
int
count()
Counts the number of test cases executed by run(TestResult result).
at line 332
getGroups()
at line 340
setGroups(array $groups)
at line 350
array
getAnnotations()
Returns the annotations for this test.
at line 365
string
getName(bool $withDataSet = true)
Gets the name of a TestCase.
at line 379
int
getSize()
Returns the size of the test.
at line 390
bool
hasSize()
at line 398
bool
isSmall()
at line 406
bool
isMedium()
at line 414
bool
isLarge()
at line 422
string
getActualOutput()
at line 434
bool
hasOutput()
at line 450
bool
doesNotPerformAssertions()
at line 460
expectOutputRegex(string $expectedRegex)
at line 474
expectOutputString(string $expectedString)
at line 490
bool
hasPerformedExpectationsOnOutput()
deprecated
deprecated
at line 498
bool
hasExpectationOnOutput()
at line 506
string
getExpectedException()
at line 520
setExpectedException(mixed $exception, string $message = '', int|string $code = null)
deprecated
deprecated
at line 542
setExpectedExceptionRegExp(mixed $exception, string $messageRegExp = '', int $code = null)
deprecated
deprecated
at line 559
expectException(string $exception)
at line 573
expectExceptionCode(int|string $code)
at line 591
expectExceptionMessage(string $message)
at line 609
expectExceptionMessageRegExp(string $messageRegExp)
at line 621
setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag)
at line 630
protected
setExpectedExceptionFromAnnotation()
at line 658
setUseErrorHandler(bool $useErrorHandler)
at line 663
protected
setUseErrorHandlerFromAnnotation()
at line 678
protected
checkRequirements()
at line 699
int
getStatus()
Returns the status of this test.
at line 704
markAsRisky()
at line 714
string
getStatusMessage()
Returns the status message of this test.
at line 724
bool
hasFailed()
Returns whether or not this test has failed.
at line 742
PHPUnit_Framework_TestResult
run(PHPUnit_Framework_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 875
runBare()
Runs the bare test sequence.
at line 1034
protected mixed
runTest()
Override to run the test and assert its state.
at line 1136
protected
verifyMockObjects()
Verifies the mock object expectations.
at line 1176
setName(string $name)
Sets the name of a TestCase.
at line 1186
setDependencies(array $dependencies)
Sets the dependencies of a TestCase.
at line 1196
bool
hasDependencies()
Returns true if the tests has dependencies
at line 1206
setDependencyInput(array $dependencyInput)
Sets
at line 1214
setBeStrictAboutChangesToGlobalState(bool $beStrictAboutChangesToGlobalState)
at line 1224
setBackupGlobals(bool $backupGlobals)
Calling this method in setUp() has no effect!
at line 1236
setBackupStaticAttributes(bool $backupStaticAttributes)
Calling this method in setUp() has no effect!
at line 1249
setRunTestInSeparateProcess(bool $runTestInSeparateProcess)
at line 1265
setPreserveGlobalState(bool $preserveGlobalState)
at line 1279
setInIsolation(bool $inIsolation)
at line 1291
bool
isInIsolation()
at line 1299
mixed
getResult()
at line 1307
setResult(mixed $result)
at line 1317
setOutputCallback(callable $callback)
at line 1329
PHPUnit_Framework_TestResult
getTestResultObject()
at line 1337
setTestResultObject(PHPUnit_Framework_TestResult $result)
at line 1345
registerMockObject(PHPUnit_Framework_MockObject_MockObject $mockObject)
at line 1360
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 1390
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 1437
PHPUnit_Framework_MockObject_MockBuilder
getMockBuilder(string|string[] $className)
Returns a builder object to create mock objects using a fluent interface.
at line 1451
protected PHPUnit_Framework_MockObject_MockObject
createMock(string $originalClassName)
Returns a test double for the specified class.
at line 1471
protected PHPUnit_Framework_MockObject_MockObject
createConfiguredMock(string $originalClassName, array $configuration)
Returns a configured test double for the specified class.
at line 1492
protected PHPUnit_Framework_MockObject_MockObject
createPartialMock(string $originalClassName, array $methods)
Returns a partial test double for the specified class.
at line 1526
protected PHPUnit_Framework_MockObject_MockObject
getMock(string $originalClassName, array|null $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = false, bool $callOriginalMethods = false, object $proxyTarget = null)
deprecated
deprecated
Returns a mock object for the specified class.
at line 1559
protected PHPUnit_Framework_MockObject_MockObject
getMockWithoutInvokingTheOriginalConstructor(string $originalClassName)
deprecated
deprecated
Returns a mock with disabled constructor object for the specified class.
at line 1584
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 1618
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 1648
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 1698
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 1731
protected object
getObjectForTrait(string $traitName, array $arguments = [], string $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, bool $callAutoload = true, bool $cloneArguments = false)
Returns an object for the specified trait.
at line 1751
protected ObjectProphecy
prophesize(string|null $classOrInterface = null)
at line 1761
addToAssertionCount(int $count)
Adds a value to the assertion counter.
at line 1771
int
getNumAssertions()
Returns the number of assertions performed by this test.
at line 1782
static PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount
any()
Returns a matcher that matches when the method is executed zero or more times.
at line 1792
static PHPUnit_Framework_MockObject_Matcher_InvokedCount
never()
Returns a matcher that matches when the method is never executed.
at line 1805
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 1817
static PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce
atLeastOnce()
Returns a matcher that matches when the method is executed at least once.
at line 1827
static PHPUnit_Framework_MockObject_Matcher_InvokedCount
once()
Returns a matcher that matches when the method is executed exactly once.
at line 1840
static PHPUnit_Framework_MockObject_Matcher_InvokedCount
exactly(int $count)
Returns a matcher that matches when the method is executed exactly $count times.
at line 1853
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 1868
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 1878
static PHPUnit_Framework_MockObject_Stub_Return
returnValue(mixed $value)
at line 1888
static PHPUnit_Framework_MockObject_Stub_ReturnValueMap
returnValueMap(array $valueMap)
at line 1898
static PHPUnit_Framework_MockObject_Stub_ReturnArgument
returnArgument(int $argumentIndex)
at line 1910
static PHPUnit_Framework_MockObject_Stub_ReturnCallback
returnCallback(mixed $callback)
at line 1922
static PHPUnit_Framework_MockObject_Stub_ReturnSelf
returnSelf()
Returns the current object.
This method is useful when mocking a fluent interface.
at line 1934
static PHPUnit_Framework_MockObject_Stub_Exception
throwException(Throwable|Exception $exception)
at line 1944
static PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls
onConsecutiveCalls()
at line 1954
bool
usesDataProvider()
at line 1962
string
dataDescription()
at line 1974
protected string
getDataSetAsString(bool $includeData = true)
Gets the data set description of a TestCase.
at line 2000
protected array
getProvidedData()
Gets the data set of a TestCase.
at line 2010
protected PHPUnit_Framework_TestResult
createResult()
Creates a default TestResult object.
at line 2015
protected
handleDependencies()
at line 2100
static
setUpBeforeClass()
This method is called before the first test of this test class is run.
at line 2108
protected
setUp()
Sets up the fixture, for example, open a network connection.
This method is called before a test is executed.
at line 2118
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 2128
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 2136
protected
tearDown()
Tears down the fixture, for example, close a network connection.
This method is called after a test is executed.
at line 2143
static
tearDownAfterClass()
This method is called after the last test of this test class is run.
at line 2154
protected
onNotSuccessfulTest(Exception|Throwable $e)
This method is called when a test method did not execute successfully.
at line 2173
protected
prepareTemplate(Text_Template $template)
Performs custom preparations on the process isolation template.
at line 2182
protected PHPUnit_Framework_MockObject_Generator
getMockObjectGenerator()
Get the mock object generator, creating it if it doesn't exist.