33 if ( !isset(
$conf[
'parsers'] ) ) {
34 throw new MWException( __METHOD__ .
': no parsers specified' );
40 if ( !is_null( $this->parsers ) ) {
45 if ( isset( $this->conf[
'shortOutput'] ) ) {
46 $this->shortOutput = $this->conf[
'shortOutput'];
49 foreach ( $this->conf[
'parsers'] as $i => $parserConf ) {
50 if ( !is_array( $parserConf ) ) {
52 $parserConf = [
'class' => $parserConf ];
54 $class = $parserConf[
'class'];
56 $this->parsers[$i] =
new $class( $parserConf );
65 foreach ( $this->parsers as $parser ) {
66 $currentResult = $parser->$name( ...
$args );
67 if ( count( $results ) > 0 ) {
68 if ( is_object( $lastResult ) ) {
69 if ( $lastResult != $currentResult ) {
73 if ( $lastResult !== $currentResult ) {
78 $results[] = $currentResult;
79 $lastResult = $currentResult;
82 if ( count( $results ) == 2 ) {
84 foreach ( $this->parsers as $i => $parser ) {
85 $resultsList[] = var_export( $results[$i],
true );
87 $diff =
wfDiff( $resultsList[0], $resultsList[1] );
89 $diff =
'[too many parsers]';
91 $msg =
"ParserDiffTest: results mismatch on call to $name\n";
92 if ( !$this->shortOutput ) {
95 $msg .=
'Results: ' . $this->
formatArray( $results ) .
"\n" .
103 if ( $this->shortOutput ) {
104 foreach ( $array as $key => $value ) {
106 $array[$key] =
"ParserOutput: {$value->getText()}";
110 return var_export( $array,
true );
115 foreach ( $this->parsers as $parser ) {
116 $parser->setFunctionHook( $id, $callback, $flags );