Class TestSuite
A class to contain test cases and run them with shared fixtures
Properties summary
- $backupGlobals protected
boolEnable or disable the backup and restoration of the $GLOBALS array.
- $backupStaticAttributes protected
boolEnable or disable the backup and restoration of static attributes.
- $foundClasses protected
array - $groups protected
arrayThe test groups of the test suite.
- $name protected
stringThe name of the test suite.
- $numTests protected
intThe number of tests in the test suite.
- $runTestInSeparateProcess protected
bool - $testCase protected
bool - $tests protected
\PHPUnit\Framework\TestCase[]The tests in the test suite.
Method Summary
- addTestDirectory() public
Adds all the files in a directory to the test suite. Does not recursive through directories.
- addTestFile() public
Wraps both
addTest()andaddTestSuiteas well as the separate import statements for the user's convenience. - addTestMethod() protected
- getGroupDetails() public
- injectFilter() public
- setBackupGlobals() public
- setBackupStaticAttributes() public
- tearDown() protected
Template Method that is called after the tests of this test suite have finished running.
Method Detail
__construct() public
__construct(mixed $theClass, mixed $name)
Constructs a new TestSuite:
-
PHPUnit\Framework\TestSuite() constructs an empty TestSuite.
-
PHPUnit\Framework\TestSuite(ReflectionClass) constructs a TestSuite from the given class.
-
PHPUnit\Framework\TestSuite(ReflectionClass, String) constructs a TestSuite from the given class with the given name.
-
PHPUnit\Framework\TestSuite(String) either constructs a TestSuite from the given class (if the passed string is the name of an existing class) or constructs an empty TestSuite with the given name.
Parameters
-
mixed$theClass optional -
string$name optional
Throws
PHPUnit\Framework\ExceptionaddTest() public
addTest(\PHPUnit\Framework\Test $test, mixed $groups)
Adds a test to the suite.
Parameters
-
\PHPUnit\Framework\Test$test -
array$groups optional
addTestDirectory() public
addTestDirectory(mixed $directory)
Adds all the files in a directory to the test suite. Does not recursive through directories.
Parameters
-
string$directory optional The directory to add tests from.
addTestDirectoryRecursive() public
addTestDirectoryRecursive(mixed $directory)
Recursively adds all the files in a directory to the test suite.
Parameters
-
string$directory optional The directory subtree to add tests from.
addTestFile() public
addTestFile(mixed $filename)
Wraps both addTest() and addTestSuite as well as the separate import statements for the user's convenience.
If the named file cannot be read or there are no new tests that can be added, a PHPUnit\Framework\WarningTestCase will be created instead, leaving the current test run untouched.
Parameters
-
string$filename
Throws
PHPUnit\Framework\ExceptionaddTestFiles() public
addTestFiles(mixed $filenames)
Wrapper for addTestFile() that adds multiple test files.
Parameters
-
array|\Iterator$filenames
Throws
PHPUnit\Framework\ExceptionaddTestMethod() protected
addTestMethod(\ReflectionClass $class, \ReflectionMethod $method)
Parameters
-
\ReflectionClass$class -
\ReflectionMethod$method
addTestSuite() public
addTestSuite(mixed $testClass)
Adds the tests from the given class to the suite.
Parameters
-
mixed$testClass
Throws
PHPUnit\Framework\Exceptioncount() public
count(mixed $preferCache)
Counts the number of test cases that will be run by this test.
Parameters
-
bool$preferCache optional Indicates if cache is preferred.
Returns
intcreateResult() protected
createResult()
Creates a default TestResult object.
Returns
\PHPUnit\Framework\TestResultcreateTest() public static
createTest(\ReflectionClass $theClass, mixed $name)
Parameters
-
\ReflectionClass$theClass -
string$name
Returns
\PHPUnit\Framework\TestThrows
PHPUnit\Framework\ExceptiongetGroupDetails() public
getGroupDetails()
getGroups() public
getGroups()
Returns the test groups of the suite.
Returns
arraygetIterator() public
getIterator()
Returns an iterator for this test suite.
Returns
\PHPUnit\Framework\TestSuiteIteratorgetName() public
getName()
Returns the name of the suite.
Returns
stringincompleteTest() protected static
incompleteTest(mixed $class, mixed $methodName, mixed $message)
Parameters
-
string$class -
string$methodName -
string$message
Returns
\PHPUnit\Framework\IncompleteTestCaseinjectFilter() public
injectFilter(\PHPUnit\Runner\Filter\Factory $filter)
Parameters
-
\PHPUnit\Runner\Filter\Factory$filter
isTestMethod() public static
isTestMethod(\ReflectionMethod $method)
Parameters
-
\ReflectionMethod$method
Returns
boolmarkTestSuiteSkipped() public
markTestSuiteSkipped(mixed $message)
Mark the test suite as skipped.
Parameters
-
string$message optional
Throws
PHPUnit\Framework\SkippedTestSuiteErrorrun() public
run(\PHPUnit\Framework\TestResult $result)
Runs the tests and collects their result in a TestResult.
Parameters
-
\PHPUnit\Framework\TestResult$result optional
Returns
\PHPUnit\Framework\TestResultrunTest() public
runTest(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\TestResult $result)
Runs a test.
Parameters
-
\PHPUnit\Framework\Test$test -
\PHPUnit\Framework\TestResult$result
setBackupGlobals() public
setBackupGlobals(mixed $backupGlobals)
Parameters
-
bool$backupGlobals
setBackupStaticAttributes() public
setBackupStaticAttributes(mixed $backupStaticAttributes)
Parameters
-
bool$backupStaticAttributes
setBeStrictAboutChangesToGlobalState() public
setBeStrictAboutChangesToGlobalState(mixed $beStrictAboutChangesToGlobalState)
Parameters
-
bool$beStrictAboutChangesToGlobalState
setGroupDetails() public
setGroupDetails(array $groups)
Set tests groups of the test case
Parameters
-
array$groups
setName() public
setName(mixed $name)
Sets the name of the suite.
Parameters
-
mixed$name
setRunTestInSeparateProcess() public
setRunTestInSeparateProcess(mixed $runTestInSeparateProcess)
Parameters
-
bool$runTestInSeparateProcess
Throws
PHPUnit\Framework\ExceptionsetTests() public
setTests(array $tests)
Set tests of the test suite
Parameters
-
array$tests
setUp() protected
setUp()
Template Method that is called before the tests of this test suite are run.
skipTest() protected static
skipTest(mixed $class, mixed $methodName, mixed $message)
Parameters
-
string$class -
string$methodName -
string$message
Returns
\PHPUnit\Framework\SkippedTestCasetearDown() protected
tearDown()
Template Method that is called after the tests of this test suite have finished running.
testAt() public
testAt(mixed $index)
Returns the test at the given index.
Parameters
-
mixed$index
Returns
\PHPUnit\Framework\Test|falsetests() public
tests()
Returns the tests as an enumeration.
Returns
arraytoString() public
toString()
Returns a string representation of the test suite.
Returns
stringwarning() protected static
warning(mixed $message)
Parameters
-
string$message
Returns
\PHPUnit\Framework\WarningTestCaseProperty Detail
$backupGlobals protected
Enable or disable the backup and restoration of the $GLOBALS array.
Type
bool$backupStaticAttributes protected
Enable or disable the backup and restoration of static attributes.
Type
bool$foundClasses protected
Type
array$groups protected
The test groups of the test suite.
Type
array$name protected
The name of the test suite.
Type
string$numTests protected
The number of tests in the test suite.
Type
int$runTestInSeparateProcess protected
Type
bool$testCase protected
Type
bool$tests protected
The tests in the test suite.
Type
\PHPUnit\Framework\TestCase[]
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.9/class-Cake.TestSuite.TestSuite.html