cvs: pear(ZEND_ENGINE_2) /PHPUnit/Framework TestCase.php TestResult.php
| From: | Sebastian Bergmann | Date: | Sun, 08 Jun 2003 10:10:47 +0000 |
| Subject: | cvs: pear(ZEND_ENGINE_2) /PHPUnit/Framework TestCase.php TestResult.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-10764@lists.php.net to get a copy of this message | ||
sebastian Sun Jun 8 06:10:47 2003 EDT
Modified files: (Branch: ZEND_ENGINE_2)
/pear/PHPUnit/Framework TestCase.php TestResult.php
Log:
Move logic to right place. Remove obsolete code.
Index: pear/PHPUnit/Framework/TestCase.php
diff -u pear/PHPUnit/Framework/TestCase.php:1.1.2.2 pear/PHPUnit/Framework/TestCase.php:1.1.2.3
--- pear/PHPUnit/Framework/TestCase.php:1.1.2.2 Sat Jun 7 02:25:59 2003
+++ pear/PHPUnit/Framework/TestCase.php Sun Jun 8 06:10:47 2003
@@ -12,7 +12,7 @@
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
//
-// $Id: TestCase.php,v 1.1.2.2 2003/06/07 06:25:59 sebastian Exp $
+// $Id: TestCase.php,v 1.1.2.3 2003/06/08 10:10:47 sebastian Exp $
//
require_once 'PHPUnit/Framework/Assert.php';
@@ -146,29 +146,9 @@
* @access public
*/
public function runBare() {
- $failed = false;
-
$this->setUp();
-
- try {
- $this->runTest();
- }
-
- catch (PHPUnit_Framework_AssertionFailedError $e) {
- $this->result->addFailure($this, $e);
- $failed = true;
- }
-
- catch (Exception $e) {
- $this->result->addError($this, $e);
- $failed = true;
- }
-
+ $this->runTest();
$this->tearDown();
-
- if (!$failed) {
- $this->pass();
- }
}
// }}}
@@ -228,18 +208,6 @@
*/
protected function createResult() {
return new PHPUnit_Framework_TestResult;
- }
-
- // }}}
- // {{{ protected function pass()
-
- /**
- * Passes a test.
- *
- * @access protected
- */
- protected function pass() {
- $this->result->addPassedTest($this);
}
// }}}
Index: pear/PHPUnit/Framework/TestResult.php
diff -u pear/PHPUnit/Framework/TestResult.php:1.1.2.2 pear/PHPUnit/Framework/TestResult.php:1.1.2.3
--- pear/PHPUnit/Framework/TestResult.php:1.1.2.2 Sat Jun 7 02:25:59 2003
+++ pear/PHPUnit/Framework/TestResult.php Sun Jun 8 06:10:47 2003
@@ -12,7 +12,7 @@
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
//
-// $Id: TestResult.php,v 1.1.2.2 2003/06/07 06:25:59 sebastian Exp $
+// $Id: TestResult.php,v 1.1.2.3 2003/06/08 10:10:47 sebastian Exp $
//
require_once 'PHPUnit/Framework/AssertionFailedError.php';
@@ -49,12 +49,6 @@
protected $listeners = array();
/**
- * @var array
- * @access protected
- */
- protected $passedTests = array();
-
- /**
* @var integer
* @access protected
*/
@@ -118,19 +112,6 @@
}
// }}}
- // {{{ public function addPassedTest(PHPUnit_Framework_Test $test)
-
- /**
- * Adds a passed test to the list of passed tests.
- *
- * @param PHPUnit_Framework_Test
- * @access public
- */
- public function addPassedTest(PHPUnit_Framework_Test $test) {
- $this->passedTests[] = $test;
- }
-
- // }}}
// {{{ public function endTest(PHPUnit_Framework_Test $test)
/**
@@ -238,8 +219,19 @@
*/
public function run(PHPUnit_Framework_Test $test) {
$this->startTest($test);
- $this->runTests++;
- $test->runBare();
+
+ try {
+ $test->runBare();
+ }
+
+ catch (PHPUnit_Framework_AssertionFailedError $e) {
+ $this->addFailure($test, $e);
+ }
+
+ catch (Exception $e) {
+ $this->addError($test, $e);
+ }
+
$this->endTest($test);
}
@@ -278,6 +270,8 @@
* @access public
*/
public function startTest(PHPUnit_Framework_Test $test) {
+ $this->runTests += $test->countTestCases();
+
for ($i = 0; $i < sizeof($this->listeners); $i++) {
$this->listeners[$i]->startTest($test);
}
@@ -293,47 +287,6 @@
*/
public function stop() {
$this->stop = true;
- }
-
- // }}}
- // {{{ public function toHTML()
-
- /**
- * Returns a HTML representation of the test result.
- *
- * @return string
- * @access public
- */
- public function toHTML() {
- return '<pre>' . htmlspecialchars($this->toString()) .
'</pre>';
- }
-
- // }}}
- // {{{ public function toString()
-
- /**
- * Returns a text representation of the test result.
- *
- * @return string
- * @access public
- */
- public function toString() {
- $result = '';
-
- foreach ($this->passedTests as $passedTest) {
- $result .= sprintf(
- "TestCase %s->%s() passed\n",
-
- get_class($passedTest),
- $passedTest->getName()
- );
- }
-
- foreach ($this->failures as $failedTest) {
- $result .= $failedTest->toString();
- }
-
- return $result;
}
// }}}