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

Class: PHPUnit2_Framework_TestSuite

Source Location: /PHPUnit2-2.3.6/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 92]
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 131]

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: Exception
  • Access: public

Parameters:

mixed   $theClass   — 
string   $name   — 

[ Top ]

addTest   [line 217]

void addTest( PHPUnit2_Framework_Test $test)

Adds a test to the suite.
  • Access: public

Parameters:

PHPUnit2_Framework_Test   $test   — 

[ Top ]

addTestFile   [line 253]

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: Exception
  • Access: public

Parameters:

string   $filename   — 

[ Top ]

addTestFiles   [line 299]

void addTestFiles( Array $filenames)

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

Parameters:

Array   $filenames   — 

[ Top ]

addTestSuite   [line 227]

void addTestSuite( mixed $testClass)

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

Parameters:

mixed   $testClass   — 

[ Top ]

countTestCases   [line 311]

integer countTestCases( )

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

[ Top ]

createResult   [line 375]

PHPUnit2_Framework_TestResult createResult( )

Creates a default TestResult object.
  • Access: protected

[ Top ]

createTest   [line 328]

PHPUnit2_Framework_Test createTest( ReflectionClass $theClass, string $name)

  • Access: public

Parameters:

ReflectionClass   $theClass   — 
string   $name   — 

[ Top ]

getName   [line 385]

string getName( )

Returns the name of the suite.
  • Access: public

[ Top ]

run   [line 397]

PHPUnit2_Framework_TestResult run( [PHPUnit2_Framework_TestResult $result = NULL])

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

Parameters:

PHPUnit2_Framework_TestResult   $result   — 

[ Top ]

runTest   [line 431]

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 441]

void setName( string $name)

Sets the name of the suite.
  • Access: public

Parameters:

string   $name   — 

[ Top ]

testAt   [line 452]

PHPUnit2_Framework_Test testAt( integer $index)

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

Parameters:

integer   $index   — 

[ Top ]

testCount   [line 466]

integer testCount( )

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

[ Top ]

tests   [line 476]

array tests( )

Returns the tests as an enumeration.
  • Access: public

[ Top ]

toString   [line 207]

string toString( )

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

[ Top ]


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