Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php |
— | — | @@ -315,7 +315,6 @@ |
316 | 316 | global $wgHooks; |
317 | 317 | |
318 | 318 | $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; |
319 | | - $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup'; |
320 | 319 | $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; |
321 | 320 | |
322 | 321 | MagicWord::clearCache(); |
Index: trunk/phase3/tests/parser/parserTestsStaticParserHook.php |
— | — | @@ -1,58 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * A basic extension that's used by the parser tests to test whether the parser |
5 | | - * calls extensions when they're called inside comments, it shouldn't do that |
6 | | - * |
7 | | - * Copyright © 2005, 2006 Ævar Arnfjörð Bjarmason |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - * |
24 | | - * @file |
25 | | - * @ingroup Testing |
26 | | - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
27 | | - */ |
28 | | - |
29 | | -class ParserTestStaticParserHook { |
30 | | - static function setup( &$parser ) { |
31 | | - $parser->setHook( 'statictag', array( __CLASS__, 'hook' ) ); |
32 | | - |
33 | | - return true; |
34 | | - } |
35 | | - |
36 | | - static function hook( $in, $argv, $parser ) { |
37 | | - if ( ! count( $argv ) ) { |
38 | | - $parser->static_tag_buf = $in; |
39 | | - return ''; |
40 | | - } elseif ( count( $argv ) === 1 && isset( $argv['action'] ) |
41 | | - && $argv['action'] === 'flush' && $in === null ) |
42 | | - { |
43 | | - // Clear the buffer, we probably don't need to |
44 | | - if ( isset( $parser->static_tag_buf ) ) { |
45 | | - $tmp = $parser->static_tag_buf; |
46 | | - } else { |
47 | | - $tmp = ''; |
48 | | - } |
49 | | - $parser->static_tag_buf = null; |
50 | | - return $tmp; |
51 | | - } else |
52 | | - // wtf? |
53 | | - return |
54 | | - "\nCall this extension as <statictag>string</statictag> or as" . |
55 | | - " <statictag action=flush/>, not in any other way.\n" . |
56 | | - "text: " . var_export( $in, true ) . "\n" . |
57 | | - "argv: " . var_export( $argv, true ) . "\n"; |
58 | | - } |
59 | | -} |
Index: trunk/phase3/tests/parser/parserTestsParserHook.php |
— | — | @@ -28,12 +28,12 @@ |
29 | 29 | class ParserTestParserHook { |
30 | 30 | |
31 | 31 | static function setup( &$parser ) { |
32 | | - $parser->setHook( 'tag', array( __CLASS__, 'dumpHook' ) ); |
33 | | - |
| 32 | + $parser->setHook( 'tag', array( __CLASS__, 'tagHook' ) ); |
| 33 | + $parser->setHook( 'statictag', array( __CLASS__, 'staticTagHook' ) ); |
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | | - static function dumpHook( $in, $argv ) { |
| 37 | + static function tagHook( $in, $argv ) { |
38 | 38 | ob_start(); |
39 | 39 | var_dump( |
40 | 40 | $in, |
— | — | @@ -43,4 +43,28 @@ |
44 | 44 | |
45 | 45 | return "<pre>\n$ret</pre>"; |
46 | 46 | } |
| 47 | + |
| 48 | + static function staticTagHook( $in, $argv, $parser ) { |
| 49 | + if ( ! count( $argv ) ) { |
| 50 | + $parser->static_tag_buf = $in; |
| 51 | + return ''; |
| 52 | + } elseif ( count( $argv ) === 1 && isset( $argv['action'] ) |
| 53 | + && $argv['action'] === 'flush' && $in === null ) |
| 54 | + { |
| 55 | + // Clear the buffer, we probably don't need to |
| 56 | + if ( isset( $parser->static_tag_buf ) ) { |
| 57 | + $tmp = $parser->static_tag_buf; |
| 58 | + } else { |
| 59 | + $tmp = ''; |
| 60 | + } |
| 61 | + $parser->static_tag_buf = null; |
| 62 | + return $tmp; |
| 63 | + } else |
| 64 | + // wtf? |
| 65 | + return |
| 66 | + "\nCall this extension as <statictag>string</statictag> or as" . |
| 67 | + " <statictag action=flush/>, not in any other way.\n" . |
| 68 | + "text: " . var_export( $in, true ) . "\n" . |
| 69 | + "argv: " . var_export( $argv, true ) . "\n"; |
| 70 | + } |
47 | 71 | } |
Index: trunk/phase3/tests/parser/parserTest.inc |
— | — | @@ -688,7 +688,6 @@ |
689 | 689 | global $wgHooks; |
690 | 690 | |
691 | 691 | $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; |
692 | | - $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup'; |
693 | 692 | $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; |
694 | 693 | |
695 | 694 | MagicWord::clearCache(); |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -866,7 +866,6 @@ |
867 | 867 | # tests/parser |
868 | 868 | 'ParserTest' => 'tests/parser/parserTest.inc', |
869 | 869 | 'ParserTestParserHook' => 'tests/parser/parserTestsParserHook.php', |
870 | | - 'ParserTestStaticParserHook' => 'tests/parser/parserTestsStaticParserHook.php', |
871 | 870 | |
872 | 871 | # tests/selenium |
873 | 872 | 'Selenium' => 'tests/selenium/Selenium.php', |