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

Source for file PEAR.php

Documentation is available at PEAR.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit2                                                       |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2004 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: PEAR.php,v 1.1.2.1 2004/10/01 06:11:53 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit2/Framework/TestFailure.php';
  19. require_once 'PHPUnit2/Framework/TestListener.php';
  20. require_once 'PHPUnit2/Framework/TestResult.php';
  21.  
  22. @include_once 'Log.php';
  23.  
  24. /**
  25.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  26.  * @copyright   Copyright &copy; 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
  27.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  28.  * @category    Testing
  29.  * @package     PHPUnit2
  30.  * @subpackage  Extensions
  31.  * @since       2.1.0
  32.  */
  33. class PHPUnit2_Extensions_Log_PEAR implements PHPUnit2_Framework_TestListener {
  34.     // {{{ Members
  35.  
  36.     /**
  37.     * Log.
  38.     *
  39.     * @var    Log 
  40.     * @access private
  41.     */
  42.     private $log;
  43.  
  44.     // }}}
  45.     // {{{ public function __construct($type, $name = '', $ident = '', $conf = array(), $maxLevel = PEAR_LOG_DEBUG)
  46.  
  47.     /**
  48.     * @param string $type      The type of concrete Log subclass to use.
  49.     *                           Currently, valid values are 'console',
  50.     *                           'syslog', 'sql', 'file', and 'mcal'.
  51.     * @param string $name      The name of the actually log file, table, or
  52.     *                           other specific store to use. Defaults to an
  53.     *                           empty string, with which the subclass will
  54.     *                           attempt to do something intelligent.
  55.     * @param string $ident     The identity reported to the log system.
  56.     * @param array  $conf      A hash containing any additional configuration
  57.     *                           information that a subclass might need.
  58.     * @param int $maxLevel     Maximum priority level at which to log.
  59.     * @access public
  60.     */
  61.     public function __construct($type$name ''$ident ''$conf = array()$maxLevel = PEAR_LOG_DEBUG{
  62.         $this->log = Log::factory($type$name$ident$conf$maxLevel);
  63.     }
  64.  
  65.     // }}}
  66.     // {{{ public function addError(PHPUnit2_Framework_Test $test, Exception $e)
  67.  
  68.     /**
  69.     * An error occurred.
  70.     *
  71.     * @param  PHPUnit2_Framework_Test $test 
  72.     * @param  Exception               $e 
  73.     * @access public
  74.     */
  75.     public function addError(PHPUnit2_Framework_Test $testException $e{
  76.         $this->log->crit(
  77.           sprintf(
  78.             'Test "%s" failed: %s',
  79.  
  80.             $test->getName(),
  81.             $e->getMessage()
  82.           )
  83.         );
  84.     }
  85.  
  86.     // }}}
  87.     // {{{ public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e)
  88.  
  89.     /**
  90.     * A failure occurred.
  91.     *
  92.     * @param  PHPUnit2_Framework_Test                 $test 
  93.     * @param  PHPUnit2_Framework_AssertionFailedError $e 
  94.     * @access public
  95.     */
  96.     public function addFailure(PHPUnit2_Framework_Test $testPHPUnit2_Framework_AssertionFailedError $e{
  97.         $this->log->err(
  98.           sprintf(
  99.             'Test "%s" failed: %s',
  100.  
  101.             $test->getName(),
  102.             $e->getMessage()
  103.           )
  104.         );
  105.     }
  106.  
  107.     // }}}
  108.     // {{{ public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e)
  109.  
  110.     /**
  111.     * Incomplete test.
  112.     *
  113.     * @param  PHPUnit2_Framework_Test $test 
  114.     * @param  Exception               $e 
  115.     * @access public
  116.     */
  117.     public function addIncompleteTest(PHPUnit2_Framework_Test $testException $e{
  118.         $this->log->info(
  119.           sprintf(
  120.             'Test "%s" incomplete: %s',
  121.  
  122.             $test->getName(),
  123.             $e->getMessage()
  124.           )
  125.         );
  126.     }
  127.  
  128.     // }}}
  129.     // {{{ public function endTest(PHPUnit2_Framework_Test $test)
  130.  
  131.     /**
  132.     * A test ended.
  133.     *
  134.     * @param  PHPUnit2_Framework_Test $test 
  135.     * @access public
  136.     */
  137.     public function endTest(PHPUnit2_Framework_Test $test{
  138.         $this->log->info(
  139.           sprintf(
  140.             'Test "%s" ended.',
  141.  
  142.             $test->getName()
  143.           )
  144.         );
  145.     }
  146.  
  147.     // }}}
  148.     // {{{ public function startTest(PHPUnit2_Framework_Test $test)
  149.  
  150.     /**
  151.     * A test started.
  152.     *
  153.     * @param  PHPUnit2_Framework_Test $test 
  154.     * @access public
  155.     */
  156.     public function startTest(PHPUnit2_Framework_Test $test{
  157.         $this->log->info(
  158.           sprintf(
  159.             'Test "%s" started.',
  160.  
  161.             $test->getName()
  162.           )
  163.         );
  164.     }
  165.  
  166.     // }}}
  167. }
  168.  
  169. /*
  170.  * vim600:  et sw=2 ts=2 fdm=marker
  171.  * vim<600: et sw=2 ts=2
  172.  */
  173. ?>

Documentation generated on Mon, 11 Mar 2019 13:58:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.