r96336 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96335‎ | r96336 | r96337 >
Date:14:46, 6 September 2011
Author:demon
Status:ok
Tags:
Comment:
Merge ParserTestStaticParserHook into ParserTestParserHook since they practically do the same thing.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/tests/parser/parserTestsParserHook.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTestsStaticParserHook.php (deleted) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -315,7 +315,6 @@
316316 global $wgHooks;
317317
318318 $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
319 - $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup';
320319 $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
321320
322321 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 @@
2929 class ParserTestParserHook {
3030
3131 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' ) );
3434 return true;
3535 }
3636
37 - static function dumpHook( $in, $argv ) {
 37+ static function tagHook( $in, $argv ) {
3838 ob_start();
3939 var_dump(
4040 $in,
@@ -43,4 +43,28 @@
4444
4545 return "<pre>\n$ret</pre>";
4646 }
 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+ }
4771 }
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -688,7 +688,6 @@
689689 global $wgHooks;
690690
691691 $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
692 - $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup';
693692 $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
694693
695694 MagicWord::clearCache();
Index: trunk/phase3/includes/AutoLoader.php
@@ -866,7 +866,6 @@
867867 # tests/parser
868868 'ParserTest' => 'tests/parser/parserTest.inc',
869869 'ParserTestParserHook' => 'tests/parser/parserTestsParserHook.php',
870 - 'ParserTestStaticParserHook' => 'tests/parser/parserTestsStaticParserHook.php',
871870
872871 # tests/selenium
873872 'Selenium' => 'tests/selenium/Selenium.php',

Follow-up revisions

RevisionCommit summaryAuthorDate
r100983Change the name back to dumpHook (r96336). That makes obvious that the use of...platonides15:25, 27 October 2011

Status & tagging log