Source for file TestCase.php
Documentation is available at TestCase.php
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Copyright (c) 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
// $Id: TestCase.php,v 1.7.2.3 2004/08/24 07:59:53 sebastian Exp $
require_once 'PHPUnit2/Framework/Assert.php';
require_once 'PHPUnit2/Framework/Test.php';
require_once 'PHPUnit2/Framework/TestResult.php';
require_once 'PHPUnit2/Util/Filter.php';
* A TestCase defines the fixture to run multiple tests.
* 1) Implement a subclass of PHPUnit2_Framework_TestCase.
* 2) Define instance variables that store the state of the fixture.
* 3) Initialize the fixture state by overriding setUp().
* 4) Clean-up after a test by overriding tearDown().
* Each test runs in its own fixture so there can be no side effects
* require_once 'PHPUnit2/Framework/TestCase.php';
* class MathTest extends PHPUnit2_Framework_TestCase {
* public function __construct($name) {
* parent::__construct($name);
* public function setUp() {
* For each test implement a method which interacts with the fixture.
* Verify the expected results with assertions specified by calling
* public function testPass() {
* $this->assertTrue($this->value1 + $this->value2 == 5);
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright Copyright © 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
* The name of the test case.
// {{{ public function __construct($name = false)
* Constructs a test case with the given name.
// {{{ public function toString()
* Returns a string representation of the test case.
$class = new ReflectionClass ($this);
// {{{ public function countTestCases()
* Counts the number of test cases executed by run(TestResult result).
// {{{ public function getName()
* Gets the name of a TestCase.
// {{{ public function run(PHPUnit2_Framework_TestResult)
* Runs the test case and collects the results in a TestResult object.
* If no TestResult object is passed a new one will be created.
* @param PHPUnit2_Framework_TestResult $result
* @return PHPUnit2_Framework_TestResult
public function run($result = null ) {
// XXX: Workaround for missing optional class type hints.
'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.'
// {{{ public function runBare()
* Runs the bare test sequence.
$catchedException = null;
// Workaround for missing "finally".
if ($catchedException !== null ) {
// {{{ protected function runTest()
* Override to run the test and assert its state.
self ::assertNotNull ($this->name);
$class = new ReflectionClass ($this);
$method = $class->getMethod ($this->name);
catch (ReflectionException $e) {
$this->fail($e->getMessage ());
// {{{ public function setName($name)
* Sets the name of a TestCase.
// {{{ protected function createResult()
* Creates a default TestResult object.
* @return PHPUnit2_Framework_TestResult
// {{{ protected function setUp()
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
protected function setUp() {}
// {{{ protected function tearDown()
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
* vim600: et sw=2 ts=2 fdm=marker
Documentation generated on Mon, 11 Mar 2019 13:55:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|