示例#1
0
 function setUp()
 {
     ParserTest::setUp();
     //reuse setup from parser tests
     global $wgContLang, $wgUser, $wgLanguageCode;
     $wgContLang = Language::factory($wgLanguageCode);
     $this->popts = new ParserOptions($wgUser);
     $this->pcache = ParserCache::singleton();
 }
示例#2
0
/**
 * Smarty {wiki}{/wiki} block plugin
 * 
 * @param string $content contents of the block
 * @param object $template template object
 * @param boolean $ &$repeat repeat flag
 * @return string content re-formatted
 */
function smarty_block_wiki2($params, $content, $template, &$repeat)
{
    global $smarty, $config_q;
    define('MEDIAWIKI', true);
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/Exception.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/User.php";
    //require_once($config_q["code_path"]."/externals/mediawiki/includes/StubUserLang.php");
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/StubObject.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/WebRequest.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/GlobalFunctions.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/includes/ObjectCache.php";
    require_once $config_q["code_path"] . "/externals/mediawiki/maintenance/tests/testHelpers.inc";
    require_once $config_q["code_path"] . "/externals/mediawiki/maintenance/tests/parser/parserTest.inc";
    $test = new ParserTest();
    $parser = $test->fuzzTest('foo.php');
    /*$parser->setupGlobals();
    	$p = $parser->getParser();
             * 
             */
    /*define('MEDIAWIKI', true);
            require_once($config_q["code_path"]."/externals/mediawiki/includes/Exception.php");
            require_once($config_q["code_path"]."/externals/mediawiki/includes/User.php");
            require_once($config_q["code_path"]."/externals/mediawiki/includes/StubUserLang.php");
            
    
            require_once($config_q["code_path"]."/externals/mediawiki/includes/GlobalFunctions.php");
            require_once($config_q["code_path"]."/externals/mediawiki/includes/ProfilerStub.php");
    	require_once($config_q["code_path"]."/externals/mediawiki/includes/parser/Parser.php");
    
    arr('f');
            $wgUser = new User;
            $wgLang = new StubUserLang;
            $wgOut = new StubObject( 'wgOut', 'OutputPage' );
            $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
    
            arr('f');
    
            /*$parser = new Parser();
    	return $parser->recursiveTagParse( $content );
             *
             */
}
示例#3
0
                           [--help]
Options:
  --quick          Suppress diff output of failed tests
  --quiet          Suppress notification of passed tests (shows only failed tests)
  --show-output    Show expected and actual output
  --color          Override terminal detection and force color output on or off
                   'light' option is similar to 'yes' but with color for dark backgrounds
  --regex          Only run tests whose descriptions which match given regex
  --file           Run test cases from a custom file instead of parserTests.txt
  --help           Show this help message


ENDS;
    exit(0);
}
# There is a convention that the parser should never
# refer to $wgTitle directly, but instead use the title
# passed to it.
$wgTitle = Title::newFromText('Parser test script do not use');
$tester = new ParserTest();
if (isset($options['file'])) {
    $files = array($options['file']);
} else {
    // Default parser tests and any set from extensions or local config
    $files = $wgParserTestFiles;
}
# Print out software version to assist with locating regressions
$version = SpecialVersion::getVersion();
echo "This is MediaWiki version {$version}.\n";
$ok = $tester->runTestsFromFiles($files);
exit($ok ? 0 : -1);
示例#4
0
 public function publishTestArticles()
 {
     if (empty(self::$articles)) {
         return;
     }
     foreach (self::$articles as $name => $info) {
         list($text, $line) = $info;
         ParserTest::addArticle($name, $text, $line, 'ignoreduplicate');
     }
 }
示例#5
0
}
function func_trace($len = 1)
{
    static $traces = array();
    $debug = debug_backtrace();
    array_shift($debug);
    for ($i = 0; $i < $len; $i++) {
        $trace = $debug[$i]['file'] . ' @' . $debug[$i]['line'];
        if (!in_array($trace, $traces)) {
            msg($trace);
            $traces[] = $trace;
        }
    }
}
ob_start();
$test_obj = new ParserTest();
$content = ob_get_clean();
?>
<!DOCTYPE html>
<html><head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>Less.php Tests</title>
	<link rel="stylesheet" href="php-diff/styles.css" type="text/css" />
	<?php 
echo $test_obj->head;
?>
	<link rel="stylesheet" type="text/css" href="assets/style.css" />
	<link rel="stylesheet" type="text/css" href="assets/jsdiff.css" />

	<script src="assets/jquery-1.10.2.min.js"></script>
	<script src="assets/diffview.js"></script>
    exit(0);
}
# Cases of weird db corruption were encountered when running tests on earlyish
# versions of SQLite
if ($wgDBtype == 'sqlite') {
    $db = wfGetDB(DB_MASTER);
    $version = $db->getServerVersion();
    if (version_compare($version, '3.6') < 0) {
        die("Parser tests require SQLite version 3.6 or later, you have {$version}\n");
    }
}
# There is a convention that the parser should never
# refer to $wgTitle directly, but instead use the title
# passed to it.
$wgTitle = Title::newFromText('Parser test script do not use');
$tester = new ParserTest($options);
if (isset($options['file'])) {
    $files = array($options['file']);
} else {
    // Default parser tests and any set from extensions or local config
    $files = $wgParserTestFiles;
}
# Print out software version to assist with locating regressions
$version = SpecialVersion::getVersion();
echo "This is MediaWiki version {$version}.\n\n";
if (isset($options['fuzz'])) {
    $tester->fuzzTest($files);
} else {
    $ok = $tester->runTestsFromFiles($files);
    exit($ok ? 0 : 1);
}
示例#7
0
        // we assume the external file contain an array of messages for the
        // lang we are testing
        $referenceMessages = getExternalMessages($args[1], $lang);
        $referenceLanguage = $lang;
        $referenceFilename = $args[1];
        $externalRef = true;
    }
    // Load datas from MediaWiki
    $testMessages = getMediawikiMessages($lang);
    $testLanguage = $lang;
} else {
    usage();
    wfDie();
}
/** parsertest is used to do differences */
$myParserTest = new ParserTest();
# Get all references messages and check if they exist in the tested language
$i = 0;
$msg = "MW Language{$testLanguage}.php against ";
if ($externalRef) {
    $msg .= 'external file ';
} else {
    $msg .= 'internal file ';
}
$msg .= $referenceFilename . ' (' . $referenceLanguage . "):\n----\n";
echo $msg;
// process messages
foreach ($referenceMessages as $index => $ref) {
    // message is not localized
    if (!isset($testMessages[$index])) {
        $i++;
示例#8
0
 public function publishTestArticles()
 {
     if (empty(self::$articles)) {
         return;
     }
     foreach (self::$articles as $name => $text) {
         $title = Title::newFromText($name);
         if ($title->getArticleID(Title::GAID_FOR_UPDATE) == 0) {
             ParserTest::addArticle($name, $text);
         }
     }
 }
示例#9
0
 /**
  * Test-wide setup
  */
 public static function setUpBeforeClass()
 {
     self::$climate = new \League\CLImate\CLImate();
     self::$command = new \NHL\Command(self::$climate);
 }
示例#10
0
MediaWiki {$wgVersion} parser test suite
Usage: php parserTests.php [--quick] [--quiet] [--color[=(yes|no|light)]]
                           [--regex=<expression>] [--file=<testfile>]
                           [--help]
Options:
  --quick  Suppress diff output of failed tests
  --quiet  Suppress notification of passed tests (shows only failed tests)
  --color  Override terminal detection and force color output on or off
           'light' option is similar to 'yes' but with color for dark backgrounds
  --regex  Only run tests whose descriptions which match given regex
  --file   Run test cases from a custom file instead of parserTests.txt
  --help   Show this help message


END;
    exit(0);
}
# There is a convention that the parser should never
# refer to $wgTitle directly, but instead use the title
# passed to it.
$wgTitle = Title::newFromText('Parser test script do not use');
$tester = new ParserTest();
if (isset($options['file'])) {
    $file = $options['file'];
} else {
    # Note: the command line setup changes the current working directory
    # to the parent, which is why we have to put the subdir here:
    $file = $IP . '/maintenance/parserTests.txt';
}
$ok = $tester->runTestsFromFile($file);
exit($ok ? 0 : -1);
        OutputWriter::Object()->setOutputTarget($tgt);
        $p->parseRecursive($this->recursive_base);
    }
    function testRecursiveInputClassOutput(&$output)
    {
        echo "\n\ttestRecursiveInputClassOutput\n";
        $p = new CodeParser();
        $tgt = $this->mybase . '/testRecursiveInputClassOutput';
        mkdir($tgt);
        OutputWriter::Object()->setOutputGran(OutputWriter::OUTPUT_GRAN_CLASS);
        OutputWriter::Object()->setOutputTarget($tgt);
        $p->parseRecursive($this->recursive_base);
    }
    private function deltree($f)
    {
        if (is_dir($f)) {
            foreach (scandir($f) as $item) {
                if (!strcmp($item, '.') || !strcmp($item, '..')) {
                    continue;
                }
                $this->deltree($f . "/" . $item);
            }
            rmdir($f);
        } else {
            unlink($f);
        }
    }
}
$t = new ParserTest();
$t->runTests();
var_dump($t->getFailures());