testunit.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 56 行

PHP
56
字号
<?php

/**
 * TestUnit runs a TestSuite and returns a TestResult object.
 * And more than PHPUnit attach a listener to TestResult. 
 *
 * @version    $Id: TestUnit.php,v 1.1 2003/11/15 18:27:11 thesaur Exp $
 * @author     Laurent Laville <pear@laurent-laville.org>
 * @package    HTML_Progress
 */

require_once 'PHPUnit.php';

class TestUnit extends PHPUnit {

    function &run(&$suite, $listener) {
        $result = new TestResult();
	$result->addListener($listener);
        $suite->run($result);

        return $result;
    }
}

class TestResult extends PHPUnit_TestResult {

    /* report result of test run */
    function report() {
	echo "</TABLE>";

	$nRun = $this->runCount();
	$nErrors = $this->errorCount();
	$nFailures = $this->failureCount();
	echo "<h2>Summary</h2>";

	printf("<p>%s test%s run.<br>", $nRun, ($nRun > 1) ? 's' : '');
	printf("%s error%s.<br>\n", $nErrors, ($nErrors > 1) ? 's' : '');
	printf("%s failure%s.<br>\n", $nFailures, ($nFailures > 1) ? 's' : '');
	if ($nFailures > 0) {
	    echo "<h2>Failure Details</h2>";
            print("<ol>\n");
            $failures = $this->failures();
            while (list($i, $failure) = each($failures)) {
                $failedTest = $failure->failedTest();
                printf("<li>%s\n", $failedTest->getName() );
                print("<ul>");
                printf("<li>%s\n", $failure->thrownException() );
                print("</ul>");
            }
            print("</ol>\n");
	}
    }

}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?