cvs: pear /PHPUnit2 package.xml /PHPUnit2/Extensions/Logger Log.php XML.php /PHPUnit2/Framework TestListener.php TestResult.php /PHPUnit2/Runner
BaseTestRunner.php TestRunListener.php /PHPUnit2/Tests/Framework TestListenerTest.php /PHPUnit2/TextUI ResultPrinter.php

From: Date: Sat, 24 Apr 2004 06:23:58 +0000
Subject: cvs: pear /PHPUnit2 package.xml /PHPUnit2/Extensions/Logger Log.php XML.php /PHPUnit2/Framework TestListener.php TestResult.php /PHPUnit2/Runner
BaseTestRunner.php TestRunListener.php /PHPUnit2/Tests/Framework TestListenerTest.php /PHPUnit2/TextUI ResultPrinter.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-18669@lists.php.net to get a copy of this message
sebastian Sat Apr 24 02:23:58 2004 EDT Modified files: /pear/PHPUnit2 package.xml /pear/PHPUnit2/Extensions/Logger Log.php XML.php /pear/PHPUnit2/Framework TestListener.php TestResult.php /pear/PHPUnit2/Runner BaseTestRunner.php TestRunListener.php /pear/PHPUnit2/Tests/Framework TestListenerTest.php /pear/PHPUnit2/TextUI ResultPrinter.php Log: Implement the features of junitour (http://junitour.sourceforge.net/).

http://cvs.php.net/diff.php/pear/PHPUnit2/package.xml?r1=1.10&r2=1.11&ty=u Index: pear/PHPUnit2/package.xml diff -u pear/PHPUnit2/package.xml:1.10 pear/PHPUnit2/package.xml:1.11 --- pear/PHPUnit2/package.xml:1.10 Fri Apr 23 03:17:12 2004 +++ pear/PHPUnit2/package.xml Sat Apr 24 02:23:57 2004 @@ -24,6 +24,8 @@ <date>2004-MM-DD</date> <notes> <![CDATA[ ++ Implemented the features of junitour (http://junitour.sourceforge.net/). + + Added scripts for convenient CLI invocation of the PHPUnit_TextUI. * PHPUnit_Framework_Assert::assertType() can now be used with @@ -58,6 +60,8 @@ <file role="php" name="Assert.php"/> <file role="php" name="AssertionFailedError.php"/> <file role="php" name="ComparisonFailure.php"/> + <file role="php" name="IncompleteTest.php"/> + <file role="php" name="IncompleteTestError.php"/> <file role="php" name="Test.php"/> <file role="php" name="TestCase.php"/> <file role="php" name="TestFailure.php"/> http://cvs.php.net/diff.php/pear/PHPUnit2/Extensions/Logger/Log.php?r1=1.3&r2=1.4&ty=u Index: pear/PHPUnit2/Extensions/Logger/Log.php diff -u pear/PHPUnit2/Extensions/Logger/Log.php:1.3 pear/PHPUnit2/Extensions/Logger/Log.php:1.4 --- pear/PHPUnit2/Extensions/Logger/Log.php:1.3 Thu Apr 15 12:59:39 2004 +++ pear/PHPUnit2/Extensions/Logger/Log.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: Log.php,v 1.3 2004/04/15 16:59:39 sebastian Exp $ +// $Id: Log.php,v 1.4 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/TestFailure.php'; @@ -104,6 +104,20 @@ } // }}} + // {{{ public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + * @todo Implement addIncompleteTest() method. + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + } + + // }}} // {{{ public function endTest(PHPUnit2_Framework_Test $test) /** http://cvs.php.net/diff.php/pear/PHPUnit2/Extensions/Logger/XML.php?r1=1.2&r2=1.3&ty=u Index: pear/PHPUnit2/Extensions/Logger/XML.php diff -u pear/PHPUnit2/Extensions/Logger/XML.php:1.2 pear/PHPUnit2/Extensions/Logger/XML.php:1.3 --- pear/PHPUnit2/Extensions/Logger/XML.php:1.2 Thu Apr 15 11:02:32 2004 +++ pear/PHPUnit2/Extensions/Logger/XML.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: XML.php,v 1.2 2004/04/15 15:02:32 sebastian Exp $ +// $Id: XML.php,v 1.3 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/TestFailure.php'; @@ -73,6 +73,20 @@ } // }}} + // {{{ public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + * @todo Implement addIncompleteTest() method. + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + } + + // }}} // {{{ public function endTest(PHPUnit2_Framework_Test $test) /** http://cvs.php.net/diff.php/pear/PHPUnit2/Framework/TestListener.php?r1=1.3&r2=1.4&ty=u Index: pear/PHPUnit2/Framework/TestListener.php diff -u pear/PHPUnit2/Framework/TestListener.php:1.3 pear/PHPUnit2/Framework/TestListener.php:1.4 --- pear/PHPUnit2/Framework/TestListener.php:1.3 Thu Apr 15 12:59:40 2004 +++ pear/PHPUnit2/Framework/TestListener.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: TestListener.php,v 1.3 2004/04/15 16:59:40 sebastian Exp $ +// $Id: TestListener.php,v 1.4 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/AssertionFailedError.php'; @@ -53,6 +53,18 @@ public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e); // }}} + // {{{ public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e); + + // }}} // {{{ public function endTest(PHPUnit2_Framework_Test $test) /** http://cvs.php.net/diff.php/pear/PHPUnit2/Framework/TestResult.php?r1=1.4&r2=1.5&ty=u Index: pear/PHPUnit2/Framework/TestResult.php diff -u pear/PHPUnit2/Framework/TestResult.php:1.4 pear/PHPUnit2/Framework/TestResult.php:1.5 --- pear/PHPUnit2/Framework/TestResult.php:1.4 Sun Apr 18 04:24:29 2004 +++ pear/PHPUnit2/Framework/TestResult.php Sat Apr 24 02:23:57 2004 @@ -12,10 +12,11 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: TestResult.php,v 1.4 2004/04/18 08:24:29 sebastian Exp $ +// $Id: TestResult.php,v 1.5 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/AssertionFailedError.php'; +require_once 'PHPUnit2/Framework/IncompleteTest.php'; require_once 'PHPUnit2/Framework/Test.php'; require_once 'PHPUnit2/Framework/TestFailure.php'; require_once 'PHPUnit2/Framework/TestListener.php'; @@ -49,6 +50,12 @@ * @var array * @access protected */ + protected $notImplemented = array(); + + /** + * @var array + * @access protected + */ protected $listeners = array(); /** @@ -83,10 +90,18 @@ * @access public */ public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $this->errors[] = new PHPUnit2_Framework_TestFailure($test, $e); + if ($e instanceof PHPUnit2_Framework_IncompleteTest) { + $this->notImplemented[] = new PHPUnit2_Framework_TestFailure($test, $e); - foreach ($this->listeners as $listener) { - $listener->addError($test, $e); + foreach ($this->listeners as $listener) { + $listener->addIncompleteTest($test, $e); + } + } else { + $this->errors[] = new PHPUnit2_Framework_TestFailure($test, $e); + + foreach ($this->listeners as $listener) { + $listener->addError($test, $e); + } } } @@ -102,10 +117,18 @@ * @access public */ public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $this->failures[] = new PHPUnit2_Framework_TestFailure($test, $e); + if ($e instanceof PHPUnit2_Framework_IncompleteTest) { + $this->notImplemented[] = new PHPUnit2_Framework_TestFailure($test, $e); - foreach ($this->listeners as $listener) { - $listener->addFailure($test, $e); + foreach ($this->listeners as $listener) { + $listener->addIncompleteTest($test, $e); + } + } else { + $this->failures[] = new PHPUnit2_Framework_TestFailure($test, $e); + + foreach ($this->listeners as $listener) { + $listener->addFailure($test, $e); + } } } @@ -142,6 +165,45 @@ } // }}} + // {{{ public function allCompletlyImplemented() + + /** + * Returns true if no incomplete test occured. + * + * @return boolean + * @access public + */ + public function allCompletlyImplemented() { + return $this->notImplementedCount() == 0; + } + + // }}} + // {{{ public function notImplementedCount() + + /** + * Gets the number of incomplete tests. + * + * @return integer + * @access public + */ + public function notImplementedCount() { + return sizeof($this->notImplemented); + } + + // }}} + // {{{ public function notImplemented) + + /** + * Returns an Enumeration for the incomplete tests. + * + * @return array + * @access public + */ + public function notImplemented() { + return $this->notImplemented; + } + + // }}} // {{{ public function errorCount() /** http://cvs.php.net/diff.php/pear/PHPUnit2/Runner/BaseTestRunner.php?r1=1.3&r2=1.4&ty=u Index: pear/PHPUnit2/Runner/BaseTestRunner.php diff -u pear/PHPUnit2/Runner/BaseTestRunner.php:1.3 pear/PHPUnit2/Runner/BaseTestRunner.php:1.4 --- pear/PHPUnit2/Runner/BaseTestRunner.php:1.3 Thu Apr 15 12:59:40 2004 +++ pear/PHPUnit2/Runner/BaseTestRunner.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: BaseTestRunner.php,v 1.3 2004/04/15 16:59:40 sebastian Exp $ +// $Id: BaseTestRunner.php,v 1.4 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/AssertionFailedError.php'; @@ -38,7 +38,6 @@ const SUITE_METHODNAME = 'suite'; // }}} - // {{{ public function addError(PHPUnit2_Framework_Test $test, Exception $e) /** @@ -67,6 +66,20 @@ } // }}} + // {{{ public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->testFailed(PHPUnit2_Runner_TestRunListener::STATUS_INCOMPLETE, $test, $e); + } + + // }}} // {{{ public function endTest(PHPUnit2_Framework_Test $test) /** http://cvs.php.net/diff.php/pear/PHPUnit2/Runner/TestRunListener.php?r1=1.2&r2=1.3&ty=u Index: pear/PHPUnit2/Runner/TestRunListener.php diff -u pear/PHPUnit2/Runner/TestRunListener.php:1.2 pear/PHPUnit2/Runner/TestRunListener.php:1.3 --- pear/PHPUnit2/Runner/TestRunListener.php:1.2 Thu Apr 15 11:02:33 2004 +++ pear/PHPUnit2/Runner/TestRunListener.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: TestRunListener.php,v 1.2 2004/04/15 15:02:33 sebastian Exp $ +// $Id: TestRunListener.php,v 1.3 2004/04/24 06:23:57 sebastian Exp $ // /** @@ -29,9 +29,13 @@ * @subpackage Runner */ interface PHPUnit2_Runner_TestRunListener { - const STATUS_ERROR = 1; - const STATUS_FAILURE = 2; + // {{{ Constants + const STATUS_ERROR = 1; + const STATUS_FAILURE = 2; + const STATUS_INCOMPLETE = 3; + + // }}} // {{{ public function testRunStarted($testSuiteName, $testCount) /** http://cvs.php.net/diff.php/pear/PHPUnit2/Tests/Framework/TestListenerTest.php?r1=1.4&r2=1.5&ty=u Index: pear/PHPUnit2/Tests/Framework/TestListenerTest.php diff -u pear/PHPUnit2/Tests/Framework/TestListenerTest.php:1.4 pear/PHPUnit2/Tests/Framework/TestListenerTest.php:1.5 --- pear/PHPUnit2/Tests/Framework/TestListenerTest.php:1.4 Thu Apr 22 02:06:09 2004 +++ pear/PHPUnit2/Tests/Framework/TestListenerTest.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: TestListenerTest.php,v 1.4 2004/04/22 06:06:09 sebastian Exp $ +// $Id: TestListenerTest.php,v 1.5 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/TestCase.php'; @@ -32,11 +32,12 @@ * @subpackage Tests */ class PHPUnit2_Tests_Framework_TestListenerTest extends PHPUnit2_Framework_TestCase implements PHPUnit2_Framework_TestListener { - private $result; - private $startCount; private $endCount; - private $failureCount; private $errorCount; + private $failureCount; + private $notImplementedCount; + private $result; + private $startCount; public function addError(PHPUnit2_Framework_Test $test, Exception $e) { $this->errorCount++; @@ -46,6 +47,10 @@ $this->failureCount++; } + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->notImplementedCount++; + } + public function endTest(PHPUnit2_Framework_Test $test) { $this->endCount++; } @@ -58,9 +63,10 @@ $this->result = new PHPUnit2_Framework_TestResult; $this->result->addListener($this); - $this->failureCount = 0; - $this->endCount = 0; - $this->startCount = 0; + $this->endCount = 0; + $this->failureCount = 0; + $this->notImplementedCount = 0; + $this->startCount = 0; } public function testError() { http://cvs.php.net/diff.php/pear/PHPUnit2/TextUI/ResultPrinter.php?r1=1.4&r2=1.5&ty=u Index: pear/PHPUnit2/TextUI/ResultPrinter.php diff -u pear/PHPUnit2/TextUI/ResultPrinter.php:1.4 pear/PHPUnit2/TextUI/ResultPrinter.php:1.5 --- pear/PHPUnit2/TextUI/ResultPrinter.php:1.4 Sun Apr 18 03:31:15 2004 +++ pear/PHPUnit2/TextUI/ResultPrinter.php Sat Apr 24 02:23:57 2004 @@ -12,7 +12,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: ResultPrinter.php,v 1.4 2004/04/18 07:31:15 sebastian Exp $ +// $Id: ResultPrinter.php,v 1.5 2004/04/24 06:23:57 sebastian Exp $ // require_once 'PHPUnit2/Framework/TestFailure.php'; @@ -50,6 +50,7 @@ $this->printHeader($timeElapsed); $this->printErrors($result); $this->printFailures($result); + $this->printIncompletes($result); $this->printFooter($result); } @@ -167,6 +168,17 @@ } // }}} + // {{{ protected function printIncompletes(PHPUnit2_Framework_TestResult $result) + + /** + * @param PHPUnit2_Framework_TestResult $result + * @access protected + */ + protected function printIncompletes(PHPUnit2_Framework_TestResult $result) { + $this->printDefects($result->notImplemented(), $result->notImplementedCount(), 'incomplete testcase'); + } + + // }}} // {{{ protected function printHeader($timeElapsed) /** @@ -193,7 +205,8 @@ * @access protected */ protected function printFooter(PHPUnit2_Framework_TestResult $result) { - if ($result->wasSuccessful()) { + if ($result->allCompletlyImplemented() && + $result->wasSuccessful()) { $this->write( sprintf( "\nOK (%d test%s)\n", @@ -202,14 +215,29 @@ ($result->runCount() == 1) ? '' : 's' ) ); - } else { + } + + else if (!$result->allCompletlyImplemented() && + $result->wasSuccessful()) { + $this->write( + sprintf( + "\nOK, but incomplete test cases!!!\nTests run: %d, incomplete test cases: %d.\n", + + $result->runCount(), + $result->notImplementedCount() + ) + ); + } + + else { $this->write( sprintf( - "\nFAILURES!!!\nTests run: %d, Failures: %d, Errors: %d.\n", + "\nFAILURES!!!\nTests run: %d, Failures: %d, Errors: %d, Incomplete Tests: %d.\n", $result->runCount(), $result->failureCount(), - $result->errorCount() + $result->errorCount(), + $result->notImplementedCount() ) ); } @@ -236,7 +264,11 @@ * @access public */ public function addError(PHPUnit2_Framework_Test $test, Exception $e) { - $this->write('E'); + if ($e instanceof PHPUnit2_Framework_IncompleteTest) { + $this->addIncompleteTest($test, $e); + } else { + $this->write('E'); + } } // }}} @@ -250,7 +282,25 @@ * @access public */ public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) { - $this->write('F'); + if ($e instanceof PHPUnit2_Framework_IncompleteTest) { + $this->addIncompleteTest($test, $e); + } else { + $this->write('F'); + } + } + + // }}} + // {{{ public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) + + /** + * Incomplete test. + * + * @param PHPUnit2_Framework_Test $test + * @param Exception $e + * @access public + */ + public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) { + $this->write('I'); } // }}}
« previous php.pear.cvs (#18669) next »