PHPUnit2
[ class tree: PHPUnit2 ] [ index: PHPUnit2 ] [ all elements ]

Class: PHPUnit2_Framework_TestSuite

Source Location: /PHPUnit2-3.0.0alpha11/Framework/TestSuite.php

Class Overview


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


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>

Methods


Inherited Variables

Inherited Methods


Class Details

[line 95]
A TestSuite is a composite of Tests. It runs a collection of test cases.

Here is an example using the dynamic test definition.

  1.  <?php
  2.  $suite = new PHPUnit2_Framework_TestSuite;
  3.  $suite->addTest(new MathTest('testPass'));
  4.  ?>

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

  1.  <?php
  2.  $suite = new PHPUnit2_Framework_TestSuite(
  3.    new ReflectionClass('MathTest')
  4.  );
  5.  ?>

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



[ Top ]


Method Detail

__construct (Constructor)   [line 135]

PHPUnit2_Framework_TestSuite __construct( [mixed $theClass = ''], [string $name = ''])

Constructs a new TestSuite:

  • PHPUnit2_Framework_TestSuite() constructs an empty TestSuite.
  • PHPUnit2_Framework_TestSuite(ReflectionClass) constructs a TestSuite from the given class.
  • PHPUnit2_Framework_TestSuite(ReflectionClass, String) constructs a TestSuite from the given class with the given name.
  • PHPUnit2_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.

  • Throws: InvalidArgumentException
  • Access: public

Parameters:

mixed   $theClass   — 
string   $name   — 

[ Top ]

addTest   [line 227]

void addTest( PHPUnit2_Framework_Test $test)

Adds a test to the suite.
  • Access: public

Parameters:

PHPUnit2_Framework_Test   $test   — 

[ Top ]

addTestFile   [line 265]

void addTestFile( string $filename)

Wraps both
  1. addTest()
and
  1. 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

will be created instead, leaving the current test run untouched.

  • Author: Stefano F. Rausch <stefano@rausch-e.net>
  • Since: Method available since Release 2.3.0
  • Throws: InvalidArgumentException
  • Access: public

Parameters:

string   $filename   — 

[ Top ]

addTestFiles   [line 325]

void addTestFiles( Array $filenames)

Wrapper for addTestFile() that adds multiple test files.
  • Throws: InvalidArgumentException
  • Since: Method available since Release 2.3.0
  • Access: public

Parameters:

Array   $filenames   — 

[ Top ]

addTestSuite   [line 238]

void addTestSuite( mixed $testClass)

Adds the tests from the given class to the suite.
  • Access: public

Parameters:

mixed   $testClass   — 

[ Top ]

count   [line 338]

integer count( )

Counts the number of test cases that will be run by this test.
  • Access: public

[ Top ]

createResult   [line 404]

PHPUnit2_Framework_TestResult createResult( )

Creates a default TestResult object.
  • Access: protected

[ Top ]

createTest   [line 356]

PHPUnit2_Framework_Test createTest( ReflectionClass $theClass, string $name)

  • Access: public

Parameters:

ReflectionClass   $theClass   — 
string   $name   — 

[ Top ]

getIterator   [line 518]

RecursiveIteratorIterator getIterator( )

Returns an RecursiveIteratorIterator object for this PHPUnit2_Framework_TestSuite object.
  • Since: Method available since Release 3.0.0
  • Access: public

[ Top ]

getName   [line 415]

string getName( )

Returns the name of the suite.
  • Access: public

[ Top ]

run   [line 428]

PHPUnit2_Framework_TestResult run( [PHPUnit2_Framework_TestResult $result = NULL])

Runs the tests and collects their result in a TestResult.
  • Throws: InvalidArgumentException
  • Access: public

Parameters:

PHPUnit2_Framework_TestResult   $result   — 

[ Top ]

runTest   [line 456]

void runTest( PHPUnit2_Framework_Test $test, PHPUnit2_Framework_TestResult $result, PHPUnit2_Framework_TestResult $testResult)

Runs a test.
  • Access: public

Parameters:

PHPUnit2_Framework_Test   $test   — 
PHPUnit2_Framework_TestResult   $testResult   — 
PHPUnit2_Framework_TestResult   $result   — 

[ Top ]

setName   [line 467]

void setName( string $name)

Sets the name of the suite.
  • Access: public

Parameters:

string   $name   — 

[ Top ]

testAt   [line 479]

PHPUnit2_Framework_Test testAt( integer $index)

Returns the test at the given index.
  • Access: public

Parameters:

integer   $index   — 

[ Top ]

testCount   [line 494]

integer testCount( )

Returns the number of tests in this suite.
  • Access: public

[ Top ]

tests   [line 505]

array tests( )

Returns the tests as an enumeration.
  • Access: public

[ Top ]

toString   [line 216]

string toString( )

Returns a string representation of the test suite.
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:40:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.