On this page
Class TestSuite
A class to contain test cases and run them with shared fixtures
Property Summary
-
$backupGlobals protected
bool
Enable or disable the backup and restoration of the $GLOBALS array.
-
$backupStaticAttributes protected
bool
Enable or disable the backup and restoration of static attributes.
-
$foundClasses protected
string[]
-
$groups protected
The test groups of the test suite.
-
$name protected
string
The name of the test suite.
-
$numTests protected
int
The number of tests in the test suite.
-
$providedTests protected
null|list<ExecutionOrderDependency>
-
$requiredTests protected
null|list<ExecutionOrderDependency>
-
$runTestInSeparateProcess protected
bool
-
$testCase protected
bool
-
$tests protected
Test[]
The tests in the test suite.
Method Summary
__construct() public
Constructs a new TestSuite.
addTest() public
Adds a test to the suite.
addTestDirectory() public
Adds all the files in a directory to the test suite. Does not recursive through directories.
addTestDirectoryRecursive() public
Recursively adds all the files in a directory to the test suite.
addTestFile() public
Wraps both
addTest()
andaddTestSuite
as well as the separate import statements for the user's convenience.addTestFiles() public
Wrapper for addTestFile() that adds multiple test files.
addTestMethod() protected
addTestSuite() public
Adds the tests from the given class to the suite.
addWarning() public
count() public
Counts the number of test cases that will be run by this test.
createResult() protected
Creates a default TestResult object.
getGroupDetails() public
getGroups() public
Returns the test groups of the suite.
getIterator() public
Returns an iterator for this test suite.
getName() public
Returns the name of the suite.
injectFilter() public
markTestSuiteSkipped() public
Mark the test suite as skipped.
provides() public
requires() public
run() public
Runs the tests and collects their result in a TestResult.
setBackupGlobals() public
setBackupStaticAttributes() public
setBeStrictAboutChangesToGlobalState() public
setGroupDetails() public
Set tests groups of the test case.
setName() public
setRunTestInSeparateProcess() public
setTests() public
Set tests of the test suite.
sortId() public
tests() public
Returns the tests as an enumeration.
toString() public
Returns a string representation of the test suite.
warnings() public
Method Detail
__construct() public
__construct(ReflectionClass|string $theClass = '', string $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
ReflectionClass|string
$theClass optionalstring
$name optional
Throws
Exception
addTest() public
addTest(Test $test, array $groups = []): void
Adds a test to the suite.
Parameters
Test
$testarray
$groups optional
Returns
void
addTestDirectory() public
addTestDirectory(string $directory = '.'): void
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.
Returns
void
addTestDirectoryRecursive() public
addTestDirectoryRecursive(string $directory = '.'): void
Recursively adds all the files in a directory to the test suite.
Parameters
string
$directory optional-
The directory subtree to add tests from.
Returns
void
addTestFile() public
addTestFile(string $filename): void
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
Returns
void
Throws
Exception
addTestFiles() public
addTestFiles(iterable $fileNames): void
Wrapper for addTestFile() that adds multiple test files.
Parameters
iterable
$fileNames
Returns
void
Throws
Exception
addTestMethod() protected
addTestMethod(ReflectionClass $class, ReflectionMethod $method): void
Parameters
ReflectionClass
$classReflectionMethod
$method
Returns
void
Throws
Exception
addTestSuite() public
addTestSuite(mixed $testClass): void
Adds the tests from the given class to the suite.
Parameters
- $testClass
Returns
void
Throws
Exception
addWarning() public
addWarning(string $warning): void
Parameters
string
$warning
Returns
void
count() public
count(): int
Counts the number of test cases that will be run by this test.
Returns
int
createResult() protected
createResult(): TestResult
Creates a default TestResult object.
Returns
TestResult
getGroupDetails() public
getGroupDetails(): array
Returns
array
getGroups() public
getGroups(): array
Returns the test groups of the suite.
Returns
array
getIterator() public
getIterator(): Iterator
Returns an iterator for this test suite.
Returns
Iterator
getName() public
getName(): string
Returns the name of the suite.
Returns
string
injectFilter() public
injectFilter(Factory $filter): void
Parameters
Factory
$filter
Returns
void
markTestSuiteSkipped() public
markTestSuiteSkipped(string $message = ''): void
Mark the test suite as skipped.
Parameters
string
$message optional
Returns
void
Throws
SkippedTestSuiteError
provides() public
provides(): list<ExecutionOrderDependency>
Returns
list<ExecutionOrderDependency>
requires() public
requires(): list<ExecutionOrderDependency>
Returns
list<ExecutionOrderDependency>
run() public
run(TestResult $result = null): TestResult
Runs the tests and collects their result in a TestResult.
Parameters
TestResult
$result optional
Returns
TestResult
Throws
PHPUnit\Framework\CodeCoverageException
SebastianBergmann\CodeCoverage\InvalidArgumentException
SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException
SebastianBergmann\RecursionContext\InvalidArgumentException
Warning
setBackupGlobals() public
setBackupGlobals(bool $backupGlobals): void
Parameters
bool
$backupGlobals
Returns
void
setBackupStaticAttributes() public
setBackupStaticAttributes(bool $backupStaticAttributes): void
Parameters
bool
$backupStaticAttributes
Returns
void
setBeStrictAboutChangesToGlobalState() public
setBeStrictAboutChangesToGlobalState(bool $beStrictAboutChangesToGlobalState): void
Parameters
bool
$beStrictAboutChangesToGlobalState
Returns
void
setGroupDetails() public
setGroupDetails(array $groups): void
Set tests groups of the test case.
Parameters
array
$groups
Returns
void
setName() public
setName(string $name): void
Parameters
string
$name
Returns
void
setRunTestInSeparateProcess() public
setRunTestInSeparateProcess(bool $runTestInSeparateProcess): void
Parameters
bool
$runTestInSeparateProcess
Returns
void
setTests() public
setTests(Test[] $tests): void
Set tests of the test suite.
Parameters
Test[]
$tests
Returns
void
sortId() public
sortId(): string
Returns
string
tests() public
tests(): Test[]
Returns the tests as an enumeration.
Returns
Test[]
toString() public
toString(): string
Returns a string representation of the test suite.
Returns
string
warnings() public
warnings(): array
Returns
array
Property 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
string[]
$groups protected
The test groups of the test suite.
Type
$name protected
The name of the test suite.
Type
string
$numTests protected
The number of tests in the test suite.
Type
int
$providedTests protected
Type
null|list<ExecutionOrderDependency>
$requiredTests protected
Type
null|list<ExecutionOrderDependency>
$runTestInSeparateProcess protected
Type
bool
$testCase protected
Type
bool
$tests protected
The tests in the test suite.
Type
Test[]
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.TestSuite.TestSuite.html