Class TestSuite
A class to contain test cases and run them with shared fixtures
Property Summary
- 
        $backupGlobals protectedboolEnable or disable the backup and restoration of the $GLOBALS array. 
- 
        $backupStaticAttributes protectedboolEnable or disable the backup and restoration of static attributes. 
- 
        $foundClasses protectedstring[]
- 
        $groups protectedThe test groups of the test suite. 
- 
        $name protectedstringThe name of the test suite. 
- 
        $numTests protectedintThe number of tests in the test suite. 
- 
        $providedTests protectednull|list<ExecutionOrderDependency>
- 
        $requiredTests protectednull|list<ExecutionOrderDependency>
- 
        $runTestInSeparateProcess protectedbool
- 
        $testCase protectedbool
- 
        $tests protectedTest[]The tests in the test suite. 
Method Summary
- 
          __construct() publicConstructs a new TestSuite. 
- 
          addTest() publicAdds a test to the suite. 
- 
          addTestDirectory() publicAdds all the files in a directory to the test suite. Does not recursive through directories. 
- 
          addTestDirectoryRecursive() publicRecursively adds all the files in a directory to the test suite. 
- 
          addTestFile() publicWraps both addTest()andaddTestSuiteas well as the separate import statements for the user's convenience.
- 
          addTestFiles() publicWrapper for addTestFile() that adds multiple test files. 
- 
          addTestMethod() protected
- 
          addTestSuite() publicAdds the tests from the given class to the suite. 
- 
          addWarning() public
- 
          count() publicCounts the number of test cases that will be run by this test. 
- 
          createResult() protectedCreates a default TestResult object. 
- 
          getGroupDetails() public
- 
          getGroups() publicReturns the test groups of the suite. 
- 
          getIterator() publicReturns an iterator for this test suite. 
- 
          getName() publicReturns the name of the suite. 
- 
          injectFilter() public
- 
          markTestSuiteSkipped() publicMark the test suite as skipped. 
- 
          provides() public
- 
          requires() public
- 
          run() publicRuns the tests and collects their result in a TestResult. 
- 
          setBackupGlobals() public
- 
          setBackupStaticAttributes() public
- 
          setBeStrictAboutChangesToGlobalState() public
- 
          setGroupDetails() publicSet tests groups of the test case. 
- 
          setName() public
- 
          setRunTestInSeparateProcess() public
- 
          setTests() publicSet tests of the test suite. 
- 
          sortId() public
- 
          tests() publicReturns the tests as an enumeration. 
- 
          toString() publicReturns 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 optional
- 
                string$name optional
Throws
ExceptionaddTest() ¶ public
addTest(Test $test, array $groups = []): voidAdds a test to the suite.
Parameters
- 
                Test$test
- 
                array$groups optional
Returns
voidaddTestDirectory() ¶ public
addTestDirectory(string $directory = '.'): voidAdds 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
voidaddTestDirectoryRecursive() ¶ public
addTestDirectoryRecursive(string $directory = '.'): voidRecursively adds all the files in a directory to the test suite.
Parameters
- 
                string$directory optional
- The directory subtree to add tests from. 
Returns
voidaddTestFile() ¶ public
addTestFile(string $filename): voidWraps 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
voidThrows
ExceptionaddTestFiles() ¶ public
addTestFiles(iterable $fileNames): voidWrapper for addTestFile() that adds multiple test files.
Parameters
- 
                iterable$fileNames
Returns
voidThrows
ExceptionaddTestMethod() ¶ protected
addTestMethod(ReflectionClass $class, ReflectionMethod $method): voidParameters
- 
                ReflectionClass$class
- 
                ReflectionMethod$method
Returns
voidThrows
ExceptionaddTestSuite() ¶ public
addTestSuite(mixed $testClass): voidAdds the tests from the given class to the suite.
Parameters
- 
                $testClass
Returns
voidThrows
Exceptioncount() ¶ public
count(): intCounts the number of test cases that will be run by this test.
Returns
intcreateResult() ¶ protected
createResult(): TestResultCreates a default TestResult object.
Returns
TestResultgetIterator() ¶ public
getIterator(): IteratorReturns an iterator for this test suite.
Returns
IteratormarkTestSuiteSkipped() ¶ public
markTestSuiteSkipped(string $message = ''): voidMark the test suite as skipped.
Parameters
- 
                string$message optional
Returns
voidThrows
SkippedTestSuiteErrorprovides() ¶ public
provides(): list<ExecutionOrderDependency>Returns
list<ExecutionOrderDependency>requires() ¶ public
requires(): list<ExecutionOrderDependency>Returns
list<ExecutionOrderDependency>run() ¶ public
run(?TestResult $result = null): TestResultRuns the tests and collects their result in a TestResult.
Parameters
- 
                ?TestResult$result optional
Returns
TestResultThrows
SebastianBergmann\CodeCoverage\InvalidArgumentExceptionSebastianBergmann\RecursionContext\InvalidArgumentExceptionCodeCoverageExceptionUnintentionallyCoveredCodeExceptionWarningsetBackupGlobals() ¶ public
setBackupGlobals(bool $backupGlobals): voidParameters
- 
                bool$backupGlobals
Returns
voidsetBackupStaticAttributes() ¶ public
setBackupStaticAttributes(bool $backupStaticAttributes): voidParameters
- 
                bool$backupStaticAttributes
Returns
voidsetBeStrictAboutChangesToGlobalState() ¶ public
setBeStrictAboutChangesToGlobalState(bool $beStrictAboutChangesToGlobalState): voidParameters
- 
                bool$beStrictAboutChangesToGlobalState
Returns
voidsetGroupDetails() ¶ public
setGroupDetails(array $groups): voidSet tests groups of the test case.
Parameters
- 
                array$groups
Returns
voidsetRunTestInSeparateProcess() ¶ public
setRunTestInSeparateProcess(bool $runTestInSeparateProcess): voidParameters
- 
                bool$runTestInSeparateProcess
Returns
voidsetTests() ¶ public
setTests(Test[] $tests): voidSet tests of the test suite.
Parameters
- 
                Test[]$tests
Returns
voidtoString() ¶ public
toString(): stringReturns a string representation of the test suite.
Returns
string