Source for file DocTest.php
Documentation is available at DocTest.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
* Required unconditionally.
require_once 'Testing/DocTest/Registry.php';
require_once 'Testing/DocTest/Exception.php';
require_once 'Testing/DocTest/Finder/Default.php';
require_once 'Testing/DocTest/Reporter/Default.php';
require_once 'Testing/DocTest/Parser/Default.php';
require_once 'Testing/DocTest/Runner/Default.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
* @version Release: @package_version@
* @link http://pear.php.net/package/Testing_DocTest
* @since Class available since release 0.1.0
* Tell the runner to ignore *all* whitespace differences when comparing
* expected and actual results.
const FLAG_NORMALIZE_WHITESPACE = 0x01;
* Tell the runner to compare expected and actual results in case
const FLAG_CASE_INSENSITIVE = 0x02;
* Tell the parser to skip the test.
* Allow to pass a wildcard pattern: [...] that will match any string in
const FLAG_ELLIPSIS = 0x08;
* The $options array can have the following elements
* - quiet: tells the reporter to turn on quiet mode, only errors will
* be printed out (the default value is false);
* - no_colors: tells the reporter to not use colors when outputting
* results (the default value is false);
* - logfile: tells the reporter to write the results in a logfile
* @param array $options an optional array of options
foreach ($options as $name => $value) {
$reg->parser ->setShellOptions ($options);
* Method to allow DocTest to accept a custom finder, reporter, parser or
* class MyRunner implements Testing_DocTest_RunnerInterface {
* function run(Testing_DocTest_TestCase $tb) {
* // do something here...
* $goodRunner = new MyRunner();
* $badRunner = new stdclass();
* $doctest = new Testing_DocTest();
* $doctest->accept($goodRunner);
* $doctest->accept($badRunner);
* } catch (Testing_DocTest_Exception $exc) {
* @param mixed $instance an instance implementing the finder, reporter,
* parser or runner interface.
* @throws Testing_DocTest_Exception if wrong argument passed
public function accept($instance)
$reg->finder = $instance;
$reg->reporter = $instance;
$reg->parser = $instance;
$reg->runner = $instance;
. 'DocTest::accept must implement the finder, reporter, '
. 'parser or runner interface.'
* Run the tests contained in the given pathes.
* @param array $pathes an array of files and/or directories
public function run(array $pathes)
$reg = Testing_DocTest_Registry ::singleton ();
$suites = $reg->parser ->parse ($reg->finder ->find ($pathes));
$reg->reporter ->onBegin ($suites);
foreach ($suites as $suite) {
$reg->reporter ->onTestSuiteBegin ($suite);
foreach ($suite as $case) {
$reg->reporter ->onTestCaseBegin ($case);
if (!isset ($reg->tests ) || in_array ($case->name , $reg->tests )) {
$reg->runner ->run ($case);
$reg->reporter ->onTestCasePass ($case);
$reg->reporter ->onTestCaseSkip ($case);
$reg->reporter ->onTestCaseFail ($case);
$reg->reporter ->onTestCaseError ($case);
$reg->reporter ->onTestCaseEnd ($case);
$reg->reporter ->onTestSuiteEnd ($suite);
return $reg->reporter ->onEnd ($suites);
Documentation generated on Mon, 11 Mar 2019 15:52:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|