Source for file Default.php
Documentation is available at Default.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* This file is part of the PEAR Testing_DocTest package.
* LICENSE: This source file is subject to the MIT license that is available
* through the world-wide-web at the following URI:
* http://opensource.org/licenses/mit-license.php
* @package Testing_DocTest
* @author David JEAN LOUIS <izimobil@gmail.com>
* @copyright 2008 David JEAN LOUIS
* @license http://opensource.org/licenses/mit-license.php MIT License
* @link http://pear.php.net/package/Testing_DocTest
* @since File available since release 0.1.0
require_once 'Testing/DocTest/ReporterInterface.php';
* DocTest Reporter default class.
* @package Testing_DocTest
* @author David JEAN LOUIS <izimobil@gmail.com>
* @copyright 2008 David JEAN LOUIS
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version Release: 0.6.0
* @link http://pear.php.net/package/Testing_DocTest
* @since Class available since release 0.1.0
* @var resource $_logfile
private $_logfile = false;
* @var resource $_returncode
private $_returncode = 0;
$this->_logfile = fopen($reg->logfile , 'wb');
$this->_time = $time[1 ] + $time[0 ];
* Will eventually close the opened logfile.
if (false !== $this->_logfile && is_resource($this->_logfile)) {
* Called when a doctest session begins.
* @param array $suites an array of Testing_DocTest_TestSuite instances
public function onBegin(array $suites)
$this->_output ("Nothing to process.\n");
// onTestSuiteBegin() {{{
* Called before the runner starts running a suite.
* @param object $suite an instance of Testing_DocTest_TestSuite
$this->_output (" Processing {$suite->name }" , '36');
* Called before the runner run a test case.
* @param object $case a test case instance
* Called when a test passed.
* @param object $case a test case instance
$this->_output ('[PASS] ', 32 );
$this->_output ("{ $case->name }\n" );
* Called when a test was skipped by the runner.
* @param object $case a test case instance
$this->_output ('[SKIP] ', 33 );
$this->_output ("{ $case->name }\n" );
* Called when a test failed.
* @param object $case a test case instance
$this->_output (" [FAIL] (Line number ~{$case->lineNumber })\n" , 31 , true );
$this->_output ("{ $case->name }\n" , true );
$this->_output (str_pad(" Expected ", 72 , "=", STR_PAD_BOTH ), 42 , true );
$this->_output ("\n" . trim($case->expectedValue ) . "\n", false , true );
$this->_output (str_pad(" Actual ", 72 , "=", STR_PAD_BOTH ), 41 , true );
$this->_output ("\n" . trim($case->actualValue ) . "\n", false , true );
$this->_output ("\n", false , true );
* Called when a test has errors.
* @param object $case a test case instance
$this->_output ("[ERROR] \n", 31 , true );
" [PARSING ERROR]: (Line number ~{$case->lineNumber })".
" {$case->parsingError }\n" ,
$this->_output ("{ $case->name } in file \"{$case->suite ->name }\"\n" , true );
$this->_output (str_pad(" Error ", 72 , "=", STR_PAD_BOTH ), 41 , true );
$this->_output ("\n" . trim($case->actualValue ) . "\n", false , true );
* Called when the runner finished a test case.
* @param object $case a test case instance
* Called when the runner finished running the suite.
* @param object $suite an instance of Testing_DocTest_TestSuite
* Called at the end of the DocTest session.
* @param array $suites an array of Testing_DocTest_TestSuite instances
public function onEnd(array $suites)
$t = ($time[1 ] + $time[0 ]) - $this->_time;
$passed = $skipped = $failed = $error = 0;
foreach ($suites as $suite) {
foreach ($suite as $tc) {
$this->_output (sprintf("\nTotal time : %.4f sec.\n", $t), 36 );
$this->_output (" Passed tests : $passed\n" , 32 );
$this->_output (" Passed tests : $passed\n" );
$this->_output (" Skipped tests : $skipped\n" , 33 );
$this->_output (" Skipped tests : $skipped\n" );
$this->_output (" Failed tests : $failed\n\n" , 31 );
$this->_output (" Failed tests : $failed\n\n" );
return $this->_returncode;
* Writes the message $msg to STDOUT or to the logfile.
* @param string $msg the message to output
* @param int $color the color code (optional)
* @param bool $force force output even if quiet mode
private function _output ($msg, $color=false , $force=false )
if ($reg->quiet && !$force) {
if ($color && !$reg->no_colors && !$this->_logfile ) {
echo " \033[{$color}m" . $msg . "\033[0;0m";
fwrite($this->_logfile , $msg);
Documentation generated on Mon, 11 Mar 2019 15:52:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|