From df19f6cdeae1505b775af861542e0d42b15cfbfe Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 6 Sep 2011 14:46:58 +0000 Subject: [PATCH] Merge ParserTestStaticParserHook into ParserTestParserHook since they practically do the same thing. --- includes/AutoLoader.php | 1 - tests/parser/parserTest.inc | 1 - tests/parser/parserTestsParserHook.php | 30 +++++++++- tests/parser/parserTestsStaticParserHook.php | 58 ------------------- .../phpunit/includes/parser/NewParserTest.php | 1 - 5 files changed, 27 insertions(+), 64 deletions(-) delete mode 100644 tests/parser/parserTestsStaticParserHook.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index d244bcdb4b..2d0cc8c5cc 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -866,7 +866,6 @@ $wgAutoloadLocalClasses = array( # tests/parser 'ParserTest' => 'tests/parser/parserTest.inc', 'ParserTestParserHook' => 'tests/parser/parserTestsParserHook.php', - 'ParserTestStaticParserHook' => 'tests/parser/parserTestsStaticParserHook.php', # tests/selenium 'Selenium' => 'tests/selenium/Selenium.php', diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 216dbf099e..4782bdac7d 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -688,7 +688,6 @@ class ParserTest { global $wgHooks; $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; - $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup'; $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; MagicWord::clearCache(); diff --git a/tests/parser/parserTestsParserHook.php b/tests/parser/parserTestsParserHook.php index 324b8e5c06..f93ef3566d 100644 --- a/tests/parser/parserTestsParserHook.php +++ b/tests/parser/parserTestsParserHook.php @@ -28,12 +28,12 @@ class ParserTestParserHook { static function setup( &$parser ) { - $parser->setHook( 'tag', array( __CLASS__, 'dumpHook' ) ); - + $parser->setHook( 'tag', array( __CLASS__, 'tagHook' ) ); + $parser->setHook( 'statictag', array( __CLASS__, 'staticTagHook' ) ); return true; } - static function dumpHook( $in, $argv ) { + static function tagHook( $in, $argv ) { ob_start(); var_dump( $in, @@ -43,4 +43,28 @@ class ParserTestParserHook { return "
\n$ret
"; } + + static function staticTagHook( $in, $argv, $parser ) { + if ( ! count( $argv ) ) { + $parser->static_tag_buf = $in; + return ''; + } elseif ( count( $argv ) === 1 && isset( $argv['action'] ) + && $argv['action'] === 'flush' && $in === null ) + { + // Clear the buffer, we probably don't need to + if ( isset( $parser->static_tag_buf ) ) { + $tmp = $parser->static_tag_buf; + } else { + $tmp = ''; + } + $parser->static_tag_buf = null; + return $tmp; + } else + // wtf? + return + "\nCall this extension as string or as" . + " , not in any other way.\n" . + "text: " . var_export( $in, true ) . "\n" . + "argv: " . var_export( $argv, true ) . "\n"; + } } diff --git a/tests/parser/parserTestsStaticParserHook.php b/tests/parser/parserTestsStaticParserHook.php deleted file mode 100644 index e82f7f3fd2..0000000000 --- a/tests/parser/parserTestsStaticParserHook.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ - -class ParserTestStaticParserHook { - static function setup( &$parser ) { - $parser->setHook( 'statictag', array( __CLASS__, 'hook' ) ); - - return true; - } - - static function hook( $in, $argv, $parser ) { - if ( ! count( $argv ) ) { - $parser->static_tag_buf = $in; - return ''; - } elseif ( count( $argv ) === 1 && isset( $argv['action'] ) - && $argv['action'] === 'flush' && $in === null ) - { - // Clear the buffer, we probably don't need to - if ( isset( $parser->static_tag_buf ) ) { - $tmp = $parser->static_tag_buf; - } else { - $tmp = ''; - } - $parser->static_tag_buf = null; - return $tmp; - } else - // wtf? - return - "\nCall this extension as string or as" . - " , not in any other way.\n" . - "text: " . var_export( $in, true ) . "\n" . - "argv: " . var_export( $argv, true ) . "\n"; - } -} diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index afe8cf430f..edef61bf6d 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -315,7 +315,6 @@ class NewParserTest extends MediaWikiTestCase { global $wgHooks; $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; - $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup'; $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; MagicWord::clearCache(); -- 2.20.1