本文整理汇总了PHP中SimpleReporter::inCli方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleReporter::inCli方法的具体用法?PHP SimpleReporter::inCli怎么用?PHP SimpleReporter::inCli使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleReporter
的用法示例。
在下文中一共展示了SimpleReporter::inCli方法的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: paintHeader
/**
* Paints the title only.
* @param string $test_name Name class of test.
* @access public
*/
function paintHeader($test_name)
{
if (!SimpleReporter::inCli()) {
header('Content-type: text/plain');
}
print "{$test_name}\n";
flush();
}
示例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: 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);
}
}
示例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: 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);
}
}
示例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()
{
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);
}
}
示例8: __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);
}
示例9: runTestCase
/**
* Run a single test case with the given name, using the provided output format.
* @param string $testName
* @param string $format (xml, text or html)
* @return int
*/
public function runTestCase($testName, $format = Sweety_Runner::REPORT_TEXT)
{
foreach ($this->_testLocators as $locator) {
if ($locator->includeTest($testName)) {
break;
}
}
$testClass = new ReflectionClass($testName);
if ($testClass->getConstructor()) {
//We don't want test output to be cached
if (!SimpleReporter::inCli()) {
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
switch ($format) {
case Sweety_Runner::REPORT_HTML:
$reporter = new HtmlReporter();
break;
case Sweety_Runner::REPORT_XML:
if (!SimpleReporter::inCli()) {
header("Content-Type: text/xml");
//Sigh! SimpleTest (skip() issues).
}
$reporter = new XmlReporter();
break;
case Sweety_Runner::REPORT_TEXT:
default:
$reporter = new TextReporter();
break;
}
$test = $testClass->newInstance();
return $test->run($reporter) ? 0 : 1;
}
return 1;
}
示例10: __construct
/**
* Assembles the appropriate reporter for the environment.
*/
public function __construct()
{
if (SimpleReporter::inCli()) {
$parser = new SimpleCommandLineParser($_SERVER['argv']);
$this->doCodeCoverage = $parser->doCodeCoverage();
$this->excludes = $parser->getExcludes();
if ($parser->isXml()) {
$interfaces = array('XmlReporter');
} else {
if ($parser->isJUnit()) {
$interfaces = array('JUnitXmlReporter');
} else {
$interfaces = array('TextReporter');
}
}
if ($parser->help()) {
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);
}
示例11: __construct
/**
* Assembles the appopriate reporter for the environment.
*/
function __construct()
{
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());
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);
}
示例12: paintHeader
/**
* Paints the test document header.
*
* @param string $test_name First test top level to start.
*
* @abstract
*/
public function paintHeader($test_name)
{
if (!SimpleReporter::inCli()) {
header('Content-type: text/xml');
}
print '<?xml version="1.0"';
if ($this->namespace) {
print ' xmlns:' . $this->namespace . '="www.lastcraft.com/SimpleTest/Beta3/Report"';
}
print "?>\n";
print '<' . $this->namespace . "run>\n";
}
示例13: paintDocumentStart
/**
* Sets the text/plain header if the test is not a CLI test.
*
* @return void
*/
function paintDocumentStart()
{
if (!SimpleReporter::inCli()) {
header('Content-type: text/plain');
}
}
示例14: _createDefaultReporter
/**
* @return SimpleReporter
*/
function _createDefaultReporter()
{
if (SimpleReporter::inCli()) {
$reporter = new TextReporter();
} else {
$reporter = new TracHtmlReporter();
}
return $reporter;
}
示例15: paintHeader
/**
* Paints the test document header.
* @param string $test_name First test top level
* to start.
* @access public
* @abstract
*/
function paintHeader($test_name)
{
if (!SimpleReporter::inCli()) {
header('Content-type: text/xml');
}
print "<?xml version=\"1.0\"";
if ($this->_namespace) {
print " xmlns:" . $this->_namespace . "=\"www.lastcraft.com/SimpleTest/Beta3/Report\"";
}
print "?>\n";
print "<" . $this->_namespace . "run>\n";
}