[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/phing/tasks/ext/phpunit2/ -> PlainPHPUnit2ResultFormatter.php (source)

   1  <?php
   2  /**
   3   * $Id: PlainPHPUnit2ResultFormatter.php 3076 2006-12-18 08:52:12Z fabien $
   4   *
   5   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   6   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   7   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   8   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   9   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16   *
  17   * This software consists of voluntary contributions made by many individuals
  18   * and is licensed under the LGPL. For more information please see
  19   * <http://phing.info>.
  20   */
  21  
  22  require_once 'PHPUnit2/Framework/Test.php';
  23  require_once 'PHPUnit2/Util/Filter.php';
  24  
  25  require_once 'phing/tasks/ext/phpunit2/PHPUnit2ResultFormatter.php';
  26  
  27  /**
  28   * Prints plain text output of the test to a specified Writer.
  29   *
  30   * @author Michiel Rook <michiel.rook@gmail.com>
  31   * @version $Id: PlainPHPUnit2ResultFormatter.php 3076 2006-12-18 08:52:12Z fabien $
  32   * @package phing.tasks.ext.phpunit2
  33   * @since 2.1.0
  34   */
  35  class PlainPHPUnit2ResultFormatter extends PHPUnit2ResultFormatter
  36  {
  37      private $inner = "";
  38      
  39  	function getExtension()
  40      {
  41          return ".txt";
  42      }
  43      
  44  	function getPreferredOutfile()
  45      {
  46          return "testresults";
  47      }
  48  
  49  	function startTestSuite(PHPUnit2_Framework_TestSuite $suite)
  50      {
  51          parent::startTestSuite($suite);
  52          
  53          $this->inner = "";
  54      }
  55      
  56  	function endTestSuite(PHPUnit2_Framework_TestSuite $suite)
  57      {
  58          parent::endTestSuite($suite);
  59          
  60          $sb = "Testsuite: " . $suite->getName() . "\n";
  61          $sb.= "Tests run: " . $this->getRunCount();
  62          $sb.= ", Failures: " . $this->getFailureCount();
  63          $sb.= ", Errors: " . $this->getErrorCount();
  64          $sb.= ", Time elapsed: " . $this->getElapsedTime();
  65          $sb.= " sec\n";
  66  
  67          if ($this->out != NULL)
  68          {
  69              $this->out->write($sb);
  70              $this->out->write($this->inner);
  71          }
  72      }
  73  
  74  	function addError(PHPUnit2_Framework_Test $test, Exception $e)
  75      {
  76          parent::addError($test, $e);
  77          
  78          $this->formatError("ERROR", $test, $e);
  79      }
  80  
  81  	function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $t)
  82      {
  83          parent::addFailure($test, $t);
  84          
  85          $this->formatError("FAILED", $test, $t);
  86      }
  87  
  88  	function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e)
  89      {
  90          parent::addIncompleteTest($test, $e);
  91          
  92          $this->formatError("INCOMPLETE", $test, $e);
  93      }
  94  
  95  	private function formatError($type, PHPUnit2_Framework_Test $test, Exception $e)
  96      {
  97          if ($test != null)
  98          {
  99              $this->endTest($test);
 100          }
 101  
 102          $this->inner.= $test->getName() . " " . $type . "\n";
 103          $this->inner.= $e->getMessage() . "\n";
 104          $this->inner.= PHPUnit2_Util_Filter::getFilteredStackTrace($e) . "\n";
 105      }
 106      
 107  	function endTestRun()
 108      {
 109          parent::endTestRun();
 110          
 111          if ($this->out != NULL)
 112          {
 113              $this->out->close();
 114          }
 115      }
 116  }
 117  ?>


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7