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

Source for file Filter.php

Documentation is available at Filter.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: Filter.php,v 1.6.2.2 2004/08/24 07:59:53 sebastian Exp $
  16. //
  17.  
  18. /**
  19.  * Utility class for code filtering.
  20.  *
  21.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  22.  * @copyright   Copyright &copy; 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
  23.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  24.  * @category    PHP
  25.  * @package     PHPUnit2
  26.  * @subpackage  Util
  27.  */
  28.     // {{{ Members
  29.  
  30.     /**
  31.     * Source files that are to be filtered.
  32.     *
  33.     * @var    array 
  34.     * @access protected
  35.     * @static
  36.     */
  37.     protected static $filteredFiles = array(
  38.       'PHPUnit2/Extensions/ExceptionTestCase.php',
  39.       'PHPUnit2/Extensions/RepeatedTest.php',
  40.       'PHPUnit2/Extensions/TestDecorator.php',
  41.       'PHPUnit2/Extensions/TestSetup.php',
  42.       'PHPUnit2/Framework/Assert.php',
  43.       'PHPUnit2/Framework/AssertionFailedError.php',
  44.       'PHPUnit2/Framework/ComparisonFailure.php',
  45.       'PHPUnit2/Framework/IncompleteTest.php',
  46.       'PHPUnit2/Framework/IncompleteTestError.php',
  47.       'PHPUnit2/Framework/Test.php',
  48.       'PHPUnit2/Framework/TestCase.php',
  49.       'PHPUnit2/Framework/TestFailure.php',
  50.       'PHPUnit2/Framework/TestListener.php',
  51.       'PHPUnit2/Framework/TestResult.php',
  52.       'PHPUnit2/Framework/TestSuite.php',
  53.       'PHPUnit2/Framework/Warning.php',
  54.       'PHPUnit2/Runner/BaseTestRunner.php',
  55.       'PHPUnit2/Runner/StandardTestSuiteLoader.php',
  56.       'PHPUnit2/Runner/TestCollector.php',
  57.       'PHPUnit2/Runner/TestRunListener.php',
  58.       'PHPUnit2/Runner/TestSuiteLoader.php',
  59.       'PHPUnit2/Runner/Version.php',
  60.       'PHPUnit2/TextUI/ResultPrinter.php',
  61.       'PHPUnit2/TextUI/TestRunner.php',
  62.       'PHPUnit2/Util/Filter.php',
  63.       'PHPUnit2/Util/Printer.php'
  64.     );
  65.  
  66.     // }}}
  67.     // {{{ public static function getFilteredStacktrace(Exception $e)
  68.  
  69.     /**
  70.     * Filters stack frames from PHPUnit classes.
  71.     *
  72.     * @param  Exception $e 
  73.     * @return string 
  74.     * @access public
  75.     * @static
  76.     */
  77.     public static function getFilteredStacktrace(Exception $e{
  78.         $filteredStacktrace '';
  79.         $stacktrace         $e->getTrace();
  80.  
  81.         foreach ($stacktrace as $frame{
  82.             $filtered = false;
  83.  
  84.             if (isset($frame['file']&&
  85.                 !in_array(self::getCanonicalFilename($frame['file'])self::$filteredFiles)) {
  86.                 $filteredStacktrace .= sprintf(
  87.                   "%s:%s\n",
  88.  
  89.                   $frame['file'],
  90.                   isset($frame['line']$frame['line''?'
  91.                 );
  92.             }
  93.         }
  94.  
  95.         return $filteredStacktrace;
  96.     }
  97.  
  98.     // }}}
  99.     // {{{ protected static function getCanonicalFilename($filename)
  100.  
  101.     /**
  102.     * Canonicalizes a source file name.
  103.     *
  104.     * @param  string 
  105.     * @return string 
  106.     * @access public
  107.     * @static
  108.     */
  109.     protected static function getCanonicalFilename($filename{
  110.         return str_replace(
  111.           '\\',
  112.           '/',
  113.           substr($filenamestrpos($filename'PHPUnit2'))
  114.         );
  115.     }
  116.  
  117.     // }}}
  118. }
  119.  
  120. /*
  121.  * vim600:  et sw=2 ts=2 fdm=marker
  122.  * vim<600: et sw=2 ts=2
  123.  */
  124. ?>

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