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

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