r39413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39412‎ | r39413 | r39414 >
Date:16:03, 15 August 2008
Author:tstarling
Status:old
Tags:
Comment:
Added shortOutput option.
Modified paths:
  • /trunk/phase3/includes/parser/Parser_DiffTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser_DiffTest.php
@@ -6,6 +6,7 @@
77 class Parser_DiffTest
88 {
99 var $parsers, $conf;
 10+ var $shortOutput = false;
1011
1112 var $dfUniqPrefix;
1213
@@ -28,6 +29,9 @@
2930 $doneHook = true;
3031 $wgHooks['ParserClearState'][] = array( $this, 'onClearState' );
3132 }
 33+ if ( isset( $this->conf['shortOutput'] ) ) {
 34+ $this->shortOutput = $this->conf['shortOutput'];
 35+ }
3236
3337 foreach ( $this->conf['parsers'] as $i => $parserConf ) {
3438 if ( !is_array( $parserConf ) ) {
@@ -66,12 +70,23 @@
6771 }
6872 if ( $mismatch ) {
6973 throw new MWException( "Parser_DiffTest: results mismatch on call to $name\n" .
70 - 'Arguments: ' . var_export( $args, true ) . "\n" .
71 - 'Results: ' . var_export( $results, true ) . "\n" );
 74+ 'Arguments: ' . $this->formatArray( $args ) . "\n" .
 75+ 'Results: ' . $this->formatArray( $results ) . "\n" );
7276 }
7377 return $lastResult;
7478 }
7579
 80+ function formatArray( $array ) {
 81+ if ( $this->shortOutput ) {
 82+ foreach ( $array as $key => $value ) {
 83+ if ( $value instanceof ParserOutput ) {
 84+ $array[$key] = "ParserOutput: {$value->getText()}";
 85+ }
 86+ }
 87+ }
 88+ return var_export( $array, true );
 89+ }
 90+
7691 function setFunctionHook( $id, $callback, $flags = 0 ) {
7792 $this->init();
7893 foreach ( $this->parsers as $i => $parser ) {

Status & tagging log