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, 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\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(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\Exception

addTestFiles() public

addTestFiles(mixed $filenames)

Wrapper for addTestFile() that adds multiple test files.

Parameters

array|\Iterator $filenames

Throws

PHPUnit\Framework\Exception

addTestMethod() 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\Exception

count() 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

int

createResult() protected

createResult()

Creates a default TestResult object.

Returns

\PHPUnit\Framework\TestResult

createTest() public static

createTest(\ReflectionClass $theClass, mixed $name)

Parameters

\ReflectionClass $theClass
string $name

Returns

\PHPUnit\Framework\Test

Throws

PHPUnit\Framework\Exception

getGroupDetails() public

getGroupDetails()

getGroups() public

getGroups()

Returns the test groups of the suite.

Returns

array

getIterator() public

getIterator()

Returns an iterator for this test suite.

Returns

\PHPUnit\Framework\TestSuiteIterator

getName() public

getName()

Returns the name of the suite.

Returns

string

incompleteTest() protected static

incompleteTest(mixed $class, mixed $methodName, mixed $message)

Parameters

string $class
string $methodName
string $message

Returns

\PHPUnit\Framework\IncompleteTestCase

injectFilter() public

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

Parameters

\PHPUnit\Runner\Filter\Factory $filter

isTestMethod() public static

isTestMethod(\ReflectionMethod $method)

Parameters

\ReflectionMethod $method

Returns

bool

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

Returns

\PHPUnit\Framework\TestResult

runTest() 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\Exception

setTests() 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\SkippedTestCase

tearDown() 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|false

tests() public

tests()

Returns the tests as an enumeration.

Returns

array

toString() public

toString()

Returns a string representation of the test suite.

Returns

string

warning() protected static

warning(mixed $message)

Parameters

string $message

Returns

\PHPUnit\Framework\WarningTestCase

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

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