home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / TestFailure.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.3 KB  |  87 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: TestFailure.php,v 1.4 2003/03/26 18:04:32 sebastian Exp $
  16. //
  17.  
  18. /**
  19.  * A TestFailure collects a failed test together with the caught exception.
  20.  *
  21.  * @package PHPUnit
  22.  * @author  Sebastian Bergmann <sb@sebastian-bergmann.de>
  23.  *          Based upon JUnit, see http://www.junit.org/ for details.
  24.  */
  25. class PHPUnit_TestFailure {
  26.     /**
  27.     * @var    object
  28.     * @access private
  29.     */
  30.     var $_failedTest;
  31.  
  32.     /**
  33.     * @var    string
  34.     * @access private
  35.     */
  36.     var $_thrownException;
  37.  
  38.     /**
  39.     * Constructs a TestFailure with the given test and exception.
  40.     *
  41.     * @param  object
  42.     * @param  string
  43.     * @access public
  44.     */
  45.     function PHPUnit_TestFailure(&$failedTest, &$thrownException) {
  46.         $this->_failedTest      = $failedTest;
  47.         $this->_thrownException = $thrownException;
  48.     }
  49.  
  50.     /**
  51.     * Gets the failed test.
  52.     *
  53.     * @return object
  54.     * @access public
  55.     */
  56.     function &failedTest() {
  57.         return $this->_failedTest;
  58.     }
  59.  
  60.     /**
  61.     * Gets the thrown exception.
  62.     *
  63.     * @return object
  64.     * @access public
  65.     */
  66.     function &thrownException() {
  67.         return $this->_thrownException;
  68.     }
  69.  
  70.     /**
  71.     * Returns a short description of the failure.
  72.     *
  73.     * @return string
  74.     * @access public
  75.     */
  76.     function toString() {
  77.         return sprintf(
  78.           "TestCase %s->%s() failed: %s\n",
  79.  
  80.           get_class($this->_failedTest),
  81.           $this->_failedTest->getName(),
  82.           $this->_thrownException
  83.         );
  84.     }
  85. }
  86. ?>
  87.