PHPUnit
[ class tree: PHPUnit ] [ index: PHPUnit ] [ all elements ]

Class: PHPUnit_TestListener

Source Location: /PHPUnit-1.2.2/PHPUnit/TestListener.php

Class Overview


A Listener for test progress.


Author(s):

Copyright:

  • Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>

Methods


Inherited Variables

Inherited Methods


Class Details

[line 81]
A Listener for test progress.

Here is an example:

  1.  <?php
  2.  require_once 'PHPUnit.php';
  3.  require_once 'PHPUnit/TestListener.php';
  4.  
  5.  class MathTest extends PHPUnit_TestCase {
  6.      var $fValue1;
  7.      var $fValue2;
  8.  
  9.      function MathTest($name{
  10.          $this->PHPUnit_TestCase($name);
  11.      }
  12.  
  13.      function setUp({
  14.          $this->fValue1 = 2;
  15.          $this->fValue2 = 3;
  16.      }
  17.  
  18.      function testAdd({
  19.          $this->assertTrue($this->fValue1 $this->fValue2 == 4);
  20.      }
  21.  }
  22.  
  23.  class MyListener extends PHPUnit_TestListener {
  24.      function addError(&$test&$t{
  25.          print "MyListener::addError() called.\n";
  26.      }
  27.  
  28.      function addFailure(&$test&$t{
  29.          print "MyListener::addFailure() called.\n";
  30.      }
  31.  
  32.      function endTest(&$test{
  33.          print "MyListener::endTest() called.\n";
  34.      }
  35.  
  36.      function startTest(&$test{
  37.          print "MyListener::startTest() called.\n";
  38.      }
  39.  }
  40.  
  41.  $suite = new PHPUnit_TestSuite;
  42.  $suite->addTest(new MathTest('testAdd'));
  43.  
  44.  $result = new PHPUnit_TestResult;
  45.  $result->addListener(new MyListener);
  46.  
  47.  $suite->run($result);
  48.  print $result->toString();
  49.  ?>



[ Top ]


Method Detail

addError   [line 90]

void addError( object &$test, object &$t)

An error occurred.
  • Abstract:
  • Access: public

Parameters:

object   &$test   — 
object   &$t   — 

[ Top ]

addFailure   [line 100]

void addFailure( object &$test, object &$t)

A failure occurred.
  • Abstract:
  • Access: public

Parameters:

object   &$test   — 
object   &$t   — 

[ Top ]

endTest   [line 109]

void endTest( object &$test)

A test ended.
  • Abstract:
  • Access: public

Parameters:

object   &$test   — 

[ Top ]

startTest   [line 118]

void startTest( object &$test)

A test started.
  • Abstract:
  • Access: public

Parameters:

object   &$test   — 

[ Top ]


Documentation generated on Thu, 10 Dec 2015 05:37:23 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.