home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / TestListener.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  3.0 KB  |  117 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit                                                        |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2003 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
  7. // +------------------------------------------------------------------------+
  8. // | This source file is subject to version 3.00 of the PHP License,        |
  9. // | that is available at http://www.php.net/license/3_0.txt.               |
  10. // | If you did not receive a copy of the PHP license and are unable to     |
  11. // | obtain it through the world-wide-web, please send a note to            |
  12. // | license@php.net so we can mail you a copy immediately.                 |
  13. // +------------------------------------------------------------------------+
  14. //
  15. // $Id: TestListener.php,v 1.4 2003/03/26 18:04:32 sebastian Exp $
  16. //
  17.  
  18. /**
  19.  * A Listener for test progress.
  20.  *
  21.  * Here is an example:
  22.  *
  23.  *   <?php
  24.  *   require_once 'PHPUnit.php';
  25.  *   require_once 'PHPUnit/TestListener.php';
  26.  *
  27.  *   class MathTest extends PHPUnit_TestCase {
  28.  *     var $fValue1;
  29.  *     var $fValue2;
  30.  *
  31.  *     function MathTest($name) {
  32.  *       $this->PHPUnit_TestCase($name);
  33.  *     }
  34.  *
  35.  *     function setUp() {
  36.  *       $this->fValue1 = 2;
  37.  *       $this->fValue2 = 3;
  38.  *     }
  39.  *
  40.  *     function testAdd() {
  41.  *       $this->assertTrue($this->fValue1 + $this->fValue2 == 4);
  42.  *     }
  43.  *   }
  44.  *
  45.  *   class MyListener extends PHPUnit_TestListener {
  46.  *     function addError(&$test, &$t) {
  47.  *       echo "MyListener::addError() called.\n";
  48.  *     }
  49.  *
  50.  *     function addFailure(&$test, &$t) {
  51.  *       echo "MyListener::addFailure() called.\n";
  52.  *     }
  53.  *
  54.  *     function endTest(&$test) {
  55.  *       echo "MyListener::endTest() called.\n";
  56.  *     }
  57.  *
  58.  *     function startTest(&$test) {
  59.  *       echo "MyListener::startTest() called.\n";
  60.  *     }
  61.  *   }
  62.  *
  63.  *   $suite = new PHPUnit_TestSuite;
  64.  *   $suite->addTest(new MathTest('testAdd'));
  65.  *
  66.  *   $result = new PHPUnit_TestResult;
  67.  *   $result->addListener(new MyListener);
  68.  *
  69.  *   $suite->run($result);
  70.  *   echo $result->toString();
  71.  *   ?>
  72.  *
  73.  * @package PHPUnit
  74.  * @author  Sebastian Bergmann <sb@sebastian-bergmann.de>
  75.  *          Based upon JUnit, see http://www.junit.org/ for details.
  76.  */
  77. class PHPUnit_TestListener {
  78.     /**
  79.     * An error occurred.
  80.     *
  81.     * @param  object
  82.     * @param  object
  83.     * @access public
  84.     * @abstract
  85.     */
  86.     function addError(&$test, &$t) { /*abstract */ }
  87.  
  88.     /**
  89.     * A failure occurred.
  90.     *
  91.     * @param  object
  92.     * @param  object
  93.     * @access public
  94.     * @abstract
  95.     */
  96.     function addFailure(&$test, &$t) { /*abstract */ }
  97.  
  98.     /**
  99.     * A test ended.
  100.     *
  101.     * @param  object
  102.     * @access public
  103.     * @abstract
  104.     */
  105.     function endTest(&$test) { /*abstract */ }
  106.  
  107.     /**
  108.     * A test started.
  109.     *
  110.     * @param  object
  111.     * @access public
  112.     * @abstract
  113.     */
  114.     function startTest(&$test) { /*abstract */ }
  115. }
  116. ?>
  117.