class (none) \ PHPUnit_Framework_TestSuite

All implemented interfaces:
Countable, PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing, IteratorAggregate
All known direct subclasses:
PHPUnit_Extensions_GroupTestSuite, PHPUnit_Extensions_PhptTestSuite, PHPUnit_Framework_TestSuite_DataProvider

A TestSuite is a composite of Tests. It runs a collection of test cases.

Here is an example using the dynamic test definition.

addTest(new MathTest('testPass')); ?>

Alternatively, a TestSuite can extract the tests to be run automatically. To do so you pass a ReflectionClass instance for your PHPUnit_Framework_TestCase class to the PHPUnit_Framework_TestSuite constructor.

This constructor creates a suite with all the methods starting with "test" that take no arguments.


Method Summary

Name Description
__construct($theClass = "", $name = "")Constructs a new TestSuite:
addTest(PHPUnit_Framework_Test $test, $groups = array())Adds a test to the suite.
addTestFile($filename)Wraps both addTest() and addTestSuite as well as the separate import statements for the user's convenience.
addTestFiles($filenames)Wrapper for addTestFile() that adds multiple test files.
addTestMethod(ReflectionClass $class, ReflectionMethod $method)
addTestSuite($testClass)Adds the tests from the given class to the suite.
count($preferCache = false)Counts the number of test cases that will be run by this test.
createResult()Creates a default TestResult object.
createTest(ReflectionClass $theClass, $name)
getGroupDetails()
getGroups()Returns the test groups of the suite.
getIterator()Returns an iterator for this test suite.
getName()Returns the name of the suite.
incompleteTest($class, $methodName, $message)
injectFilter(PHPUnit_Runner_Filter_Factory $filter)
isTestMethod(ReflectionMethod $method)
markTestSuiteSkipped($message = "")Mark the test suite as skipped.
run(PHPUnit_Framework_TestResult $result = null)Runs the tests and collects their result in a TestResult.
runTest(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result)Runs a test.
setBackupGlobals($backupGlobals)
setBackupStaticAttributes($backupStaticAttributes)
setDisallowChangesToGlobalState($disallowChangesToGlobalState)
setGroupDetails(array $groups)Set tests groups of the test case
setName($name)Sets the name of the suite.
setRunTestInSeparateProcess($runTestInSeparateProcess)
setTests(array $tests)Set tests of the test suite
setUp()Template Method that is called before the tests of this test suite are run.
skipTest($class, $methodName, $message)
tearDown()Template Method that is called after the tests of this test suite have finished running.
testAt($index)Returns the test at the given index.
tests()Returns the tests as an enumeration.
toString()Returns a string representation of the test suite.
warning($message)

public function __construct($theClass = "", $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
string - $name
Defaults:
theClass = ""
name = ""
Throws:
PHPUnit_Framework_Exception

public function addTest(PHPUnit_Framework_Test $test, $groups = array())

Adds a test to the suite.

Parameters:
PHPUnit_Framework_Test - $test
array - $groups
Defaults:
groups = array()

public function addTestFile($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_Warning will be created instead, leaving the current test run untouched.

Parameters:
string - $filename
Throws:
PHPUnit_Framework_Exception

public function addTestFiles($filenames)

Wrapper for addTestFile() that adds multiple test files.

Parameters:
array|Iterator - $filenames
Throws:
PHPUnit_Framework_Exception

protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method)

Parameters:
ReflectionClass - $class
ReflectionMethod - $method

public function addTestSuite($testClass)

Adds the tests from the given class to the suite.

Parameters:
mixed - $testClass
Throws:
PHPUnit_Framework_Exception

public function count($preferCache = false)

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

Parameters:
boolean - $preferCache Indicates if cache is preferred.
Defaults:
preferCache = false
Returns:
integer

protected function createResult()

Creates a default TestResult object.

Returns:
PHPUnit_Framework_TestResult

public static function createTest(ReflectionClass $theClass, $name)

Parameters:
ReflectionClass - $theClass
string - $name
Returns:
PHPUnit_Framework_Test
Throws:
PHPUnit_Framework_Exception

public function getGroupDetails()


public function getGroups()

Returns the test groups of the suite.

Returns:
array

public function getIterator()

Returns an iterator for this test suite.

Returns:
RecursiveIteratorIterator

public function getName()

Returns the name of the suite.

Returns:
string

protected static function incompleteTest($class, $methodName, $message)

Parameters:
string - $message
Returns:
PHPUnit_Framework_IncompleteTestCase

public function injectFilter(PHPUnit_Runner_Filter_Factory $filter)


public static function isTestMethod(ReflectionMethod $method)

Parameters:
ReflectionMethod - $method
Returns:
boolean

public function markTestSuiteSkipped($message = "")

Mark the test suite as skipped.

Parameters:
string - $message
Defaults:
message = ""
Throws:
PHPUnit_Framework_SkippedTestSuiteError

public function run(PHPUnit_Framework_TestResult $result = null)

Runs the tests and collects their result in a TestResult.

Parameters:
PHPUnit_Framework_TestResult - $result
Defaults:
result = null
Returns:
PHPUnit_Framework_TestResult

public function runTest(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result)

Runs a test.

Parameters:
PHPUnit_Framework_Test - $test
PHPUnit_Framework_TestResult - $result

public function setBackupGlobals($backupGlobals)

Parameters:
boolean - $backupGlobals

public function setBackupStaticAttributes($backupStaticAttributes)

Parameters:
boolean - $backupStaticAttributes

public function setDisallowChangesToGlobalState($disallowChangesToGlobalState)

Parameters:
boolean - $disallowChangesToGlobalState

public function setGroupDetails(array $groups)

Set tests groups of the test case

Parameters:
array - $groups

public function setName($name)

Sets the name of the suite.

Parameters:
string -

public function setRunTestInSeparateProcess($runTestInSeparateProcess)

Parameters:
boolean - $runTestInSeparateProcess
Throws:
PHPUnit_Framework_Exception

public function setTests(array $tests)

Set tests of the test suite

Parameters:
array - $tests

protected function setUp()

Template Method that is called before the tests of this test suite are run.


protected static function skipTest($class, $methodName, $message)

Parameters:
string - $message
Returns:
PHPUnit_Framework_SkippedTestCase

protected function tearDown()

Template Method that is called after the tests of this test suite have finished running.


public function testAt($index)

Returns the test at the given index.

Parameters:
integer -
Returns:
PHPUnit_Framework_Test

public function tests()

Returns the tests as an enumeration.

Returns:
array

public function toString()

Returns a string representation of the test suite.

Returns:
string

protected static function warning($message)

Parameters:
string - $message
Returns:
PHPUnit_Framework_Warning