cvs: pear /PHPUnit PHPUnit_TestListener.php PHPUnit_TestResult.php package.xml

From: Date: Thu, 11 Jul 2002 17:19:11 +0000
Subject: cvs: pear /PHPUnit PHPUnit_TestListener.php PHPUnit_TestResult.php package.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5049@lists.php.net to get a copy of this message
sebastian Thu Jul 11 13:19:11 2002 EDT Added files: /pear/PHPUnit PHPUnit_TestListener.php Modified files: /pear/PHPUnit PHPUnit_TestResult.php package.xml Log: Add PHPUnit_TestListener. Index: pear/PHPUnit/PHPUnit_TestResult.php diff -u pear/PHPUnit/PHPUnit_TestResult.php:1.6 pear/PHPUnit/PHPUnit_TestResult.php:1.7 --- pear/PHPUnit/PHPUnit_TestResult.php:1.6 Thu Jul 11 12:08:33 2002 +++ pear/PHPUnit/PHPUnit_TestResult.php Thu Jul 11 13:19:11 2002 @@ -16,7 +16,7 @@ // | Author: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // -// $Id: PHPUnit_TestResult.php,v 1.6 2002/07/11 16:08:33 sebastian Exp $ +// $Id: PHPUnit_TestResult.php,v 1.7 2002/07/11 17:19:11 sebastian Exp $ // require_once 'PHPUnit/PHPUnit_TestFailure.php'; @@ -74,8 +74,9 @@ * @access public */ function addError(&$test, &$t) { - // not implemented - $this->_notifyTestListeners(); + for ($i = 0; $i < sizeof($this->_listeners); $i++) { + $this->_listeners[$i]->addError(&$test, &$t); + } } /** @@ -88,7 +89,10 @@ */ function addFailure(&$test, &$t) { $this->_failures[] = new PHPUnit_TestFailure($test, $t); - $this->_notifyTestListeners(); + + for ($i = 0; $i < sizeof($this->_listeners); $i++) { + $this->_listeners[$i]->addFailure(&$test, &$t); + } } /** @@ -98,7 +102,10 @@ * @access public */ function addListener(&$listener) { - $this->_listeners[] = $listener; + if (is_object($listener) && + is_a($listener, 'PHPUnit_TestListener')) { + $this->_listeners[] = $listener; + } } /** @@ -109,7 +116,6 @@ */ function addPassedTest(&$test) { $this->_passedTests[] = $test; - $this->_notifyTestListeners(); } /** @@ -119,6 +125,9 @@ * @access public */ function endTest(&$test) { + for ($i = 0; $i < sizeof($this->_listeners); $i++) { + $this->_listeners[$i]->endTest(&$test); + } } /** @@ -162,17 +171,6 @@ } /** - * Notifies the TestListeners. - * - * @access private - */ - function _notifyTestListeners() { - for ($i = 0; $i < sizeof($this->_listeners); $i++) { - $this->_listeners[$i]->update(); - } - } - - /** * Unregisters a TestListener. * * @param object @@ -199,7 +197,6 @@ $this->_runTests++; $test->runBare(); $this->endTest($test); - $this->_notifyTestListeners(); } /** @@ -228,6 +225,9 @@ * @access public */ function startTest(&$test) { + for ($i = 0; $i < sizeof($this->_listeners); $i++) { + $this->_listeners[$i]->startTest(&$test); + } } /** @@ -237,7 +237,6 @@ */ function stop() { $this->_stop = true; - $this->_notifyTestListeners(); } /** Index: pear/PHPUnit/package.xml diff -u pear/PHPUnit/package.xml:1.16 pear/PHPUnit/package.xml:1.17 --- pear/PHPUnit/package.xml:1.16 Thu Jul 11 12:00:28 2002 +++ pear/PHPUnit/package.xml Thu Jul 11 13:19:11 2002 @@ -42,6 +42,7 @@ <file role="php" name="PHPUnit_TestCase.php"/> <file role="php" name="PHPUnit_TestDecorator.php"/> <file role="php" name="PHPUnit_TestFailure.php"/> + <file role="php" name="PHPUnit_TestListener.php"/> <file role="php" name="PHPUnit_TestResult.php"/> <file role="php" name="PHPUnit_TestSuite.php"/> <dir name="GUI" baseinstalldir="PHPUnit"> Index: pear/PHPUnit/PHPUnit_TestListener.php +++ pear/PHPUnit/PHPUnit_TestListener.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.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. | // +----------------------------------------------------------------------+ // | Author: Sebastian Bergmann <sb@sebastian-bergmann.de> | // +----------------------------------------------------------------------+ // // $Id: PHPUnit_TestListener.php,v 1.1 2002/07/11 17:19:11 sebastian Exp $ // /** * A Listener for test progress. * * @package PHPUnit * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * Based upon JUnit, see http://www.junit.org/ for details. */ class PHPUnit_TestListener { /** * An error occurred. * * @param object * @param object * @access public * @abstract */ function addError(&$test, &$t) { /*abstract */ } /** * A failure occurred. * * @param object * @param object * @access public * @abstract */ function addFailure(&$test, &$t) { /*abstract */ } /** * A test ended. * * @param object * @access public * @abstract */ function endTest(&$test) { /*abstract */ } /** * A test started. * * @param object * @access public * @abstract */ function startTest(&$test) { /*abstract */ } } ?>

« previous php.pear.cvs (#5049) next »