From: Tim Starling Date: Fri, 15 Aug 2008 16:03:38 +0000 (+0000) Subject: Added shortOutput option. X-Git-Tag: 1.31.0-rc.0~45888 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=bfe0d350900cbff5ca388da5a871632be09e26ab;p=lhc%2Fweb%2Fwiklou.git Added shortOutput option. --- diff --git a/includes/parser/Parser_DiffTest.php b/includes/parser/Parser_DiffTest.php index be3702cf82..2a677ea964 100644 --- a/includes/parser/Parser_DiffTest.php +++ b/includes/parser/Parser_DiffTest.php @@ -6,6 +6,7 @@ class Parser_DiffTest { var $parsers, $conf; + var $shortOutput = false; var $dfUniqPrefix; @@ -28,6 +29,9 @@ class Parser_DiffTest $doneHook = true; $wgHooks['ParserClearState'][] = array( $this, 'onClearState' ); } + if ( isset( $this->conf['shortOutput'] ) ) { + $this->shortOutput = $this->conf['shortOutput']; + } foreach ( $this->conf['parsers'] as $i => $parserConf ) { if ( !is_array( $parserConf ) ) { @@ -66,12 +70,23 @@ class Parser_DiffTest } if ( $mismatch ) { throw new MWException( "Parser_DiffTest: results mismatch on call to $name\n" . - 'Arguments: ' . var_export( $args, true ) . "\n" . - 'Results: ' . var_export( $results, true ) . "\n" ); + 'Arguments: ' . $this->formatArray( $args ) . "\n" . + 'Results: ' . $this->formatArray( $results ) . "\n" ); } return $lastResult; } + function formatArray( $array ) { + if ( $this->shortOutput ) { + foreach ( $array as $key => $value ) { + if ( $value instanceof ParserOutput ) { + $array[$key] = "ParserOutput: {$value->getText()}"; + } + } + } + return var_export( $array, true ); + } + function setFunctionHook( $id, $callback, $flags = 0 ) { $this->init(); foreach ( $this->parsers as $i => $parser ) {