* parserTests.php accepts a --file parameter to run an alternate test sutie
[lhc/web/wiklou.git] / maintenance / parserTestsStaticParserHook.php
1 <?php
2 if ( ! defined( 'MEDIAWIKI' ) )
3 die( -1 );
4 /**
5 * A basic extension that's used by the parser tests to test whether the parser
6 * calls extensions when they're called inside comments, it shouldn't do that
7 *
8 * @package MediaWiki
9 * @subpackage Maintenance
10 *
11 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
12 * @copyright Copyright © 2005, 2006 Ævar Arnfjörð Bjarmason
13 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
14 */
15
16 $wgHooks['ParserTestParser'][] = 'wfParserTestStaticParserHookSetup';
17
18 function wfParserTestStaticParserHookSetup( &$parser ) {
19 $parser->setHook( 'statictag', 'wfParserTestStaticParserHookHook' );
20
21 return true;
22 }
23
24 function wfParserTestStaticParserHookHook( $in, $argv ) {
25 static $buf = null;
26
27 if ( ! count( $argv ) ) {
28 $buf = $in;
29 return '';
30 } else if ( count( $argv ) === 1 && $argv['action'] === 'flush' && $in === null ) {
31 // Clear the buffer, we probably don't need to
32 $tmp = $buf;
33 $buf = null;
34 return $tmp;
35 } else
36 // wtf?
37 die(
38 "\nCall this extension as <statictag>string</statictag> or as" .
39 " <statictag action=flush/>, not in any other way.\n" .
40 "text: " . var_export( $in, true ) . "\n" .
41 "argv: " . var_export( $argv, true ) . "\n"
42 );
43 }
44 ?>