Class TestSuite

A class to contain test cases and run them with shared fixtures

Namespace: Cake\TestSuite

Properties summary

Method Summary

Method Detail

__construct() public

__construct(mixed $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

PHPUnit\Framework\Exception

addTest() 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(string $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(string $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(string $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\Exception

addTestFiles() public

addTestFiles(iterable $fileNames)

Wrapper for addTestFile() that adds multiple test files.

Parameters

iterable $fileNames

Throws

PHPUnit\Framework\Exception

addTestMethod() protected

addTestMethod(\ReflectionClass $class, \ReflectionMethod $method)

Parameters

\ReflectionClass $class
\ReflectionMethod $method

Throws

PHPUnit\Framework\Exception

addTestSuite() public

addTestSuite(mixed $testClass)

Adds the tests from the given class to the suite.

Parameters

object|string $testClass

Throws

PHPUnit\Framework\Exception

count() public

count(bool $preferCache)

Counts the number of test cases that will be run by this test.

Parameters

bool $preferCache optional

createResult() protected

createResult()

Creates a default TestResult object.

getGroupDetails() public

getGroupDetails()

getGroups() public

getGroups()

Returns the test groups of the suite.

getIterator() public

getIterator()

Returns an iterator for this test suite.

getName() public

getName()

Returns the name of the suite.

injectFilter() public

injectFilter(\PHPUnit\Runner\Filter\Factory $filter)

Parameters

\PHPUnit\Runner\Filter\Factory $filter

markTestSuiteSkipped() public

markTestSuiteSkipped(mixed $message)

Mark the test suite as skipped.

Parameters

string $message optional

Throws

PHPUnit\Framework\SkippedTestSuiteError

run() public

run(\PHPUnit\Framework\TestResult $result)

Runs the tests and collects their result in a TestResult.

Parameters

\PHPUnit\Framework\TestResult $result optional

Throws

PHPUnit\Framework\CodeCoverageException

SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException

SebastianBergmann\CodeCoverage\InvalidArgumentException

SebastianBergmann\CodeCoverage\MissingCoversAnnotationException

SebastianBergmann\CodeCoverage\RuntimeException

SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException

SebastianBergmann\RecursionContext\InvalidArgumentException

PHPUnit\Framework\Warning

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(string $name)

Parameters

string $name

setRunTestInSeparateProcess() public

setRunTestInSeparateProcess(bool $runTestInSeparateProcess)

Parameters

bool $runTestInSeparateProcess

setTests() public

setTests(array $tests)

Set tests of the test suite

Parameters

\PHPUnit\Framework\Test[] $tests

testAt() public

testAt(int $index)

Returns the test at the given index.

Parameters

int $index

Returns

false|\PHPUnit\Framework\Test

tests() public

tests()

Returns the tests as an enumeration.

Returns

\PHPUnit\Framework\Test[]

toString() public

toString()

Returns a string representation of the test suite.

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

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\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.1/class-Cake.TestSuite.TestSuite.html