PHP Class PHPUnit_Framework_TestSuite, phpunit

Show file Open project: sebastianbergmann/phpunit Class Usage Examples

Protected Properties

Property Type Description
$backupGlobals boolean Enable or disable the backup and restoration of the $GLOBALS array.
$backupStaticAttributes boolean Enable or disable the backup and restoration of static attributes.
$foundClasses array
$groups array The test groups of the test suite.
$name string The name of the test suite.
$numTests integer The number of tests in the test suite.
$runTestInSeparateProcess boolean
$testCase boolean
$tests array The tests in the test suite.

Public Methods

Method Description
__construct ( mixed $theClass = '', string $name = '' ) Constructs a new TestSuite:
addTest ( PHPUnit_Framework_Test $test, array $groups = [] ) Adds a test to the suite.
addTestFile ( string $filename ) Wraps both addTest() and addTestSuite as well as the separate import statements for the user's convenience.
addTestFiles ( array | Iterator $filenames ) Wrapper for addTestFile() that adds multiple test files.
addTestSuite ( mixed $testClass ) Adds the tests from the given class to the suite.
count ( boolean $preferCache = false ) : integer Counts the number of test cases that will be run by this test.
createTest ( ReflectionClass $theClass, string $name ) : PHPUnit_Framework_Test
getGroupDetails ( )
getGroups ( ) : array Returns the test groups of the suite.
getIterator ( ) : RecursiveIteratorIterator Returns an iterator for this test suite.
getName ( ) : string Returns the name of the suite.
injectFilter ( PHPUnit_Runner_Filter_Factory $filter )
isTestMethod ( ReflectionMethod $method ) : boolean
markTestSuiteSkipped ( string $message = '' ) Mark the test suite as skipped.
run ( PHPUnit_Framework_TestResult $result = null ) : PHPUnit_Framework_TestResult Runs the tests and collects their result in a TestResult.
runTest ( PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result ) Runs a test.
setBackupGlobals ( boolean $backupGlobals )
setBackupStaticAttributes ( boolean $backupStaticAttributes )
setGroupDetails ( array $groups ) Set tests groups of the test case
setName ( $name ) Sets the name of the suite.
setRunTestInSeparateProcess ( boolean $runTestInSeparateProcess )
setTests ( array $tests ) Set tests of the test suite
setbeStrictAboutChangesToGlobalState ( boolean $beStrictAboutChangesToGlobalState )
testAt ( $index ) : PHPUnit_Framework_Test Returns the test at the given index.
tests ( ) : array Returns the tests as an enumeration.
toString ( ) : string Returns a string representation of the test suite.

Protected Methods

Method Description
addTestMethod ( ReflectionClass $class, ReflectionMethod $method )
createResult ( ) : PHPUnit_Framework_TestResult Creates a default TestResult object.
incompleteTest ( string $class, string $methodName, string $message ) : PHPUnit_Framework_IncompleteTestCase
setUp ( ) Template Method that is called before the tests of this test suite are run.
skipTest ( string $class, string $methodName, string $message ) : PHPUnit_Framework_SkippedTestCase
tearDown ( ) Template Method that is called after the tests of this test suite have finished running.
warning ( string $message ) : PHPUnit_Framework_WarningTestCase

Method Details

__construct() public method

- 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.
public __construct ( mixed $theClass = '', string $name = '' )
$theClass mixed
$name string

addTest() public method

Adds a test to the suite.
public addTest ( PHPUnit_Framework_Test $test, array $groups = [] )
$test PHPUnit_Framework_Test
$groups array

addTestFile() public method

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.
public addTestFile ( string $filename )
$filename string

addTestFiles() public method

Wrapper for addTestFile() that adds multiple test files.
public addTestFiles ( array | Iterator $filenames )
$filenames array | Iterator

addTestMethod() protected method

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

addTestSuite() public method

Adds the tests from the given class to the suite.
public addTestSuite ( mixed $testClass )
$testClass mixed

count() public method

Counts the number of test cases that will be run by this test.
public count ( boolean $preferCache = false ) : integer
$preferCache boolean Indicates if cache is preferred.
return integer

createResult() protected method

Creates a default TestResult object.
protected createResult ( ) : PHPUnit_Framework_TestResult
return PHPUnit_Framework_TestResult

createTest() public static method

public static createTest ( ReflectionClass $theClass, string $name ) : PHPUnit_Framework_Test
$theClass ReflectionClass
$name string
return PHPUnit_Framework_Test

getGroupDetails() public method

public getGroupDetails ( )

getGroups() public method

Returns the test groups of the suite.
public getGroups ( ) : array
return array

getIterator() public method

Returns an iterator for this test suite.

getName() public method

Returns the name of the suite.
public getName ( ) : string
return string

incompleteTest() protected static method

protected static incompleteTest ( string $class, string $methodName, string $message ) : PHPUnit_Framework_IncompleteTestCase
$class string
$methodName string
$message string
return PHPUnit_Framework_IncompleteTestCase

injectFilter() public method

public injectFilter ( PHPUnit_Runner_Filter_Factory $filter )
$filter PHPUnit_Runner_Filter_Factory

isTestMethod() public static method

public static isTestMethod ( ReflectionMethod $method ) : boolean
$method ReflectionMethod
return boolean

markTestSuiteSkipped() public method

Mark the test suite as skipped.
public markTestSuiteSkipped ( string $message = '' )
$message string

run() public method

Runs the tests and collects their result in a TestResult.
public run ( PHPUnit_Framework_TestResult $result = null ) : PHPUnit_Framework_TestResult
$result PHPUnit_Framework_TestResult
return PHPUnit_Framework_TestResult

runTest() public method

Runs a test.
Deprecation:
public runTest ( PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result )
$test PHPUnit_Framework_Test
$result PHPUnit_Framework_TestResult

setBackupGlobals() public method

public setBackupGlobals ( boolean $backupGlobals )
$backupGlobals boolean

setBackupStaticAttributes() public method

public setBackupStaticAttributes ( boolean $backupStaticAttributes )
$backupStaticAttributes boolean

setGroupDetails() public method

Set tests groups of the test case
public setGroupDetails ( array $groups )
$groups array

setName() public method

Sets the name of the suite.
public setName ( $name )

setRunTestInSeparateProcess() public method

public setRunTestInSeparateProcess ( boolean $runTestInSeparateProcess )
$runTestInSeparateProcess boolean

setTests() public method

Set tests of the test suite
public setTests ( array $tests )
$tests array

setUp() protected method

Template Method that is called before the tests of this test suite are run.
protected setUp ( )

setbeStrictAboutChangesToGlobalState() public method

public setbeStrictAboutChangesToGlobalState ( boolean $beStrictAboutChangesToGlobalState )
$beStrictAboutChangesToGlobalState boolean

skipTest() protected static method

protected static skipTest ( string $class, string $methodName, string $message ) : PHPUnit_Framework_SkippedTestCase
$class string
$methodName string
$message string
return PHPUnit_Framework_SkippedTestCase

tearDown() protected method

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

testAt() public method

Returns the test at the given index.
public testAt ( $index ) : PHPUnit_Framework_Test
return PHPUnit_Framework_Test

tests() public method

Returns the tests as an enumeration.
public tests ( ) : array
return array

toString() public method

Returns a string representation of the test suite.
public toString ( ) : string
return string

warning() protected static method

protected static warning ( string $message ) : PHPUnit_Framework_WarningTestCase
$message string
return PHPUnit_Framework_WarningTestCase

Property Details

$backupGlobals protected property

Enable or disable the backup and restoration of the $GLOBALS array.
protected bool $backupGlobals
return boolean

$backupStaticAttributes protected property

Enable or disable the backup and restoration of static attributes.
protected bool $backupStaticAttributes
return boolean

$foundClasses protected property

protected array $foundClasses
return array

$groups protected property

The test groups of the test suite.
protected array $groups
return array

$name protected property

The name of the test suite.
protected string $name
return string

$numTests protected property

The number of tests in the test suite.
protected int $numTests
return integer

$runTestInSeparateProcess protected property

protected bool $runTestInSeparateProcess
return boolean

$testCase protected property

protected bool $testCase
return boolean

$tests protected property

The tests in the test suite.
protected array $tests
return array