本文整理汇总了PHP中SimpleReporter类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleReporter类的具体用法?PHP SimpleReporter怎么用?PHP SimpleReporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$test = new GroupTest("Piwik - running '{$this->testGroupType}' tests...");
$intro = '';
if (!$this->databaseRequired) {
$intro .= $this->getTestDatabaseInfoMessage();
}
$intro .= self::$testsHelpLinks . "<hr/>";
$intro .= $this->introAppend;
$toInclude = array();
foreach ($this->dirsToGlob as $dir) {
$toInclude = array_merge($toInclude, Piwik::globr(PIWIK_INCLUDE_PATH . $dir, '*.test.php'));
}
// if present, make sure Database.test.php is first
$idx = array_search(PIWIK_INCLUDE_PATH . '/tests/core/Database.test.php', $toInclude);
if ($idx !== FALSE) {
unset($toInclude[$idx]);
array_unshift($toInclude, PIWIK_INCLUDE_PATH . '/tests/core/Database.test.php');
}
foreach ($toInclude as $file) {
$test->addFile($file);
}
$result = $test->run(new HtmlTimerReporter($intro));
if (SimpleReporter::inCli()) {
exit($result ? 0 : 1);
}
}
示例2: simpletest_autorun
/**
* Exit handler to run all recent test cases and exit system if in CLI
*/
function simpletest_autorun()
{
if (tests_have_run()) {
return;
}
$result = run_local_tests();
if (SimpleReporter::inCli()) {
exit($result ? 0 : 1);
}
}
示例3: simpletest_autorun
/**
* Exit handler to run all recent test cases and exit system if in CLI
*/
function simpletest_autorun() {
chdir($GLOBALS['SIMPLETEST_AUTORUNNER_INITIAL_PATH']);
if (tests_have_run()) {
return;
}
$result = run_local_tests();
if (SimpleReporter::inCli()) {
exit($result ? 0 : 1);
}
}
示例4: paintFail
function paintFail($message)
{
SimpleReporter::paintFail($message);
if ($this->getFailCount() <= 10) {
print $this->test_name . ": {$message}\n";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
print "\n";
}
}
示例5: DefaultReporter
/**
* Assembles the appopriate reporter for the environment.
*/
function DefaultReporter()
{
if (SimpleReporter::inCli()) {
global $argv;
$parser = new SimpleCommandLineParser($argv);
$interfaces = $parser->isXml() ? array('XmlReporter') : array('TextReporter');
$reporter =& new SelectiveReporter(SimpleTest::preferred($interfaces), $parser->getTestCase(), $parser->getTest());
} else {
$reporter =& new SelectiveReporter(SimpleTest::preferred('HtmlReporter'), @$_GET['c'], @$_GET['t']);
}
$this->SimpleReporterDecorator($reporter);
}
示例6: run
/**
* Invokes run() on all of the held test cases, instantiating
* them if necessary.
* @param SimpleReporter $reporter Current test reporter.
* @param int $port Port to report test results on
* @access public
*/
function run(&$reporter, $port)
{
$count = count($this->_test_cases);
for ($i = 0; $i < $count; $i++) {
if (is_string($this->_test_cases[$i])) {
$class = $this->_test_cases[$i];
$test =& new $class();
ob_start();
$reporter->paintGroupStart($this->getLabel(), $this->getSize());
$reporter->paintCaseStart($test->getLabel());
$start = ob_get_contents();
ob_end_clean();
ob_start();
$reporter->paintCaseEnd($test->getLabel());
$reporter->paintGroupEnd($this->getLabel());
$end = ob_get_contents();
ob_end_clean();
//the guts from SimpleTestCase::run($reporter) where
$test->_runner = new EclipseRunner($test, $reporter, $start, $end, $port);
$test->_runner->run();
$output = $start;
if ($i + 1 == $count) {
$output .= "<done/>";
}
$output .= $end;
$sock = new SimpleSocket("127.0.0.1", $port, 5);
$sock->write($output);
$sock->close();
echo $sock->getError();
} else {
$this->_test_cases[$i]->run($reporter, $port);
}
}
return $reporter->getStatus();
}
示例7: simpletest_autorun
/**
* Exit handler to run all recent test cases if no test has
* so far been run. Uses the DefaultReporter which can have
* it's output controlled with SimpleTest::prefer().
*/
function simpletest_autorun()
{
if (tests_have_run()) {
return;
}
$candidates = array_intersect(capture_new_classes(), classes_defined_in_initial_file());
$loader = new SimpleFileLoader();
$suite = $loader->createSuiteFromClasses(basename(initial_file()), $loader->selectRunnableTests($candidates));
$result = $suite->run(new DefaultReporter());
if (SimpleReporter::inCli()) {
exit($result ? 0 : 1);
}
}
示例8: simpletest_autorun
/**
* Exit handler to run all recent test cases if no test has
* so far been run. Uses the DefaultReporter which can have
* it's output controlled with SimpleTest::prefer().
*/
function simpletest_autorun()
{
try {
if (tests_have_run()) {
return;
}
$candidates = array_intersect(capture_new_classes(), classes_defined_in_initial_file());
$loader = new SimpleFileLoader();
$suite = $loader->createSuiteFromClasses(basename(initial_file()), $loader->selectRunnableTests($candidates));
$result = $suite->run(new DefaultReporter());
} catch (Exception $e) {
// This is here, because under normal circumstances shutdown
// functions don't have a stack frame, leading to obscure errors.
echo $e->__toString();
$result = false;
}
if (SimpleReporter::inCli()) {
exit($result ? 0 : 1);
}
}
示例9: __construct
/**
* Assembles the appropriate reporter for the environment.
*/
function __construct()
{
if (SimpleReporter::inCli()) {
$parser = new SimpleCommandLineParser($_SERVER['argv']);
$interfaces = $parser->isXml() ? array('XmlReporter') : array('TextReporter');
if ($parser->help()) {
// I'm not sure if we should do the echo'ing here -- ezyang
echo $parser->getHelpText();
exit(1);
}
$reporter = new SelectiveReporter(SimpleTest::preferred($interfaces), $parser->getTestCase(), $parser->getTest());
if ($parser->noSkips()) {
$reporter = new NoSkipsReporter($reporter);
}
} else {
$reporter = new SelectiveReporter(SimpleTest::preferred('HtmlReporter'), @$_GET['c'], @$_GET['t']);
if (@$_GET['skips'] == 'no' || @$_GET['show-skips'] == 'no') {
$reporter = new NoSkipsReporter($reporter);
}
}
parent::__construct($reporter);
}
示例10: UnitTests
{
function UnitTests()
{
$this->GroupTest("Unit tests");
$this->addTestFile("errors_test.php");
$this->addTestFile("options_test.php");
$this->addTestFile("dumper_test.php");
$this->addTestFile("expectation_test.php");
$this->addTestFile("simple_mock_test.php");
$this->addTestFile("adapter_test.php");
$this->addTestFile("socket_test.php");
$this->addTestFile("query_string_test.php");
$this->addTestFile("http_test.php");
$this->addTestFile("user_agent_test.php");
$this->addTestFile("browser_test.php");
$this->addTestFile("parser_test.php");
$this->addTestFile("tag_test.php");
$this->addTestFile("page_test.php");
$this->addTestFile("frames_test.php");
$this->addTestFile("shell_tester_test.php");
$this->addTestFile("xml_test.php");
}
}
if (!defined("TEST_RUNNING")) {
define("TEST_RUNNING", true);
$test =& new UnitTests();
if (SimpleReporter::inCli()) {
exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
}
示例11: paintSignal
/**
* Handle failinfo message
*/
function paintSignal($type, $message)
{
parent::paintSignal($type, $message);
if ($type = 'failinfo') {
$this->_failinfo = $message;
}
}
示例12: paintError
function paintError($message)
{
parent::paintError($message);
$this->_response->addContent("Error !!\n");
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$this->_response->addContent("\tin " . implode("\n\tin ", array_reverse($breadcrumb)));
$this->_response->addContent("\n\t " . $message . "\n");
}
示例13: paintSkip
function paintSkip($message)
{
parent::paintSkip($message);
$str = "<span class=\"pass\">Skipped</span>: ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$str .= implode(" -> ", $breadcrumb);
$str .= " -> " . $this->_htmlEntities($message) . "<br />\n";
$this->_response->body->append('MAIN', $str);
}
示例14: paintError
function paintError($message)
{
parent::paintError($message);
$str = "<span class=\"fail\">Exception</span>: ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$str .= implode(" -> ", $breadcrumb);
$str .= " -> <strong>" . $this->_htmlEntities($message) . "</strong><br />\n";
$this->_response->body->append('MAIN', $str);
}
示例15: paintFail
function paintFail($message)
{
parent::paintFail($message);
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
$test = implode("->", $breadcrumb);
$result["time"] = time();
$result["status"] = "Failed";
$result["test"] = $test;
$result["message"] = $message;
$this->results[] = $result;
}