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

Source for file TestFailure.php

Documentation is available at TestFailure.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: TestFailure.php,v 1.5.2.2 2005/02/04 10:01:56 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit2/Framework/AssertionFailedError.php';
  19. require_once 'PHPUnit2/Framework/Test.php';
  20.  
  21. /**
  22.  * A TestFailure collects a failed test together with the caught exception.
  23.  *
  24.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  25.  * @copyright   Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
  26.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  27.  * @category    Testing
  28.  * @package     PHPUnit2
  29.  * @subpackage  Framework
  30.  */
  31.     // {{{ Instance Variables
  32.  
  33.     /**
  34.     * @var    PHPUnit2_Framework_Test 
  35.     * @access protected
  36.     */
  37.     protected $failedTest;
  38.  
  39.     /**
  40.     * @var    Exception 
  41.     * @access protected
  42.     */
  43.     protected $thrownException;
  44.  
  45.     // }}}
  46.     // {{{ public function __construct(PHPUnit2_Framework_Test $failedTest, Exception $thrownException)
  47.  
  48.     /**
  49.     * Constructs a TestFailure with the given test and exception.
  50.     *
  51.     * @param  PHPUnit2_Framework_Test $failedTest 
  52.     * @param  Exception               $thrownException 
  53.     * @access public
  54.     */
  55.     public function __construct(PHPUnit2_Framework_Test $failedTestException $thrownException{
  56.         $this->failedTest      = $failedTest;
  57.         $this->thrownException = $thrownException;
  58.     }
  59.  
  60.     // }}}
  61.     // {{{ public function toString()
  62.  
  63.     /**
  64.     * Returns a short description of the failure.
  65.     *
  66.     * @return string 
  67.     * @access public
  68.     */
  69.     public function toString({
  70.         return sprintf(
  71.           '%s: %s',
  72.  
  73.           $this->failedTest,
  74.           $this->thrownException->getMessage()
  75.         );
  76.     }
  77.  
  78.     // }}}
  79.     // {{{ public function failedTest()
  80.  
  81.     /**
  82.     * Gets the failed test.
  83.     *
  84.     * @return Test 
  85.     * @access public
  86.     */
  87.     public function failedTest({
  88.         return $this->failedTest;
  89.     }
  90.  
  91.     // }}}
  92.     // {{{ public function thrownException()
  93.  
  94.     /**
  95.     * Gets the thrown exception.
  96.     *
  97.     * @return Exception 
  98.     * @access public
  99.     */
  100.     public function thrownException({
  101.         return $this->thrownException;
  102.     }
  103.  
  104.     // }}}
  105.     // {{{ public function exceptionMessage()
  106.  
  107.     /**
  108.     * Returns the exception's message.
  109.     *
  110.     * @return string 
  111.     * @access public
  112.     */
  113.     public function exceptionMessage({
  114.         return $this->thrownException()->getMessage();
  115.     }
  116.  
  117.     // }}}
  118.     // {{{ public function isFailure()
  119.  
  120.     /**
  121.     * Returns TRUE if the thrown exception
  122.     * is of type AssertionFailedError.
  123.     *
  124.     * @return boolean 
  125.     * @access public
  126.     */
  127.     public function isFailure({
  128.         return ($this->thrownException(instanceof PHPUnit2_Framework_AssertionFailedError);
  129.     }
  130.  
  131.     // }}}
  132. }
  133.  
  134. /*
  135.  * vim600:  et sw=2 ts=2 fdm=marker
  136.  * vim<600: et sw=2 ts=2
  137.  */
  138. ?>

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