parser: Add unit tests for parser output flags ('showflags' option)
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 7 Jul 2017 01:06:43 +0000 (18:06 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 7 Jul 2017 01:06:43 +0000 (18:06 -0700)
Add logic to ParserTestRunner to allow testing of ParserOutput flags,
and use it in the existing {{REVISIONID}} test, and for the added
flag for user-signature from I77de05849c (T84843).

Change-Id: I96e3d050e17a2d7e3d0478c702ecd53310259f56

tests/parser/ParserTestRunner.php
tests/parser/parserTests.txt

index 77717f0..9dce73f 100644 (file)
@@ -778,6 +778,7 @@ class ParserTestRunner {
 
                if ( isset( $opts['pst'] ) ) {
                        $out = $parser->preSaveTransform( $test['input'], $title, $user, $options );
+                       $output = $parser->getOutput();
                } elseif ( isset( $opts['msg'] ) ) {
                        $out = $parser->transformMsg( $test['input'], $options, $title );
                } elseif ( isset( $opts['section'] ) ) {
@@ -828,6 +829,12 @@ class ParserTestRunner {
                        }
                }
 
+               if ( isset( $output ) && isset( $opts['showflags'] ) ) {
+                       $actualFlags = array_keys( TestingAccessWrapper::newFromObject( $output )->mFlags );
+                       sort( $actualFlags );
+                       $out .= "\nflags=" . join( ', ', $actualFlags );
+               }
+
                ScopedCallback::consume( $teardownGuard );
 
                $expected = $test['result'];
index 4c48ed5..041b40f 100644 (file)
@@ -10421,11 +10421,13 @@ parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 Magic Word: {{REVISIONID}}
 !! options
 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
+showflags
 !! wikitext
 {{REVISIONID}}
 !! html/*
 <p>1337
 </p>
+flags=vary-revision-id
 !! end
 
 !! test
@@ -13634,6 +13636,19 @@ pst
 !! end
 
 
+!! test
+ParserOutput flags from signature expansion (T84843)
+!! options
+pst
+showflags
+!! wikitext
+~~~~
+!! html/php
+[[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
+flags=user-signature
+!! end
+
+
 !! test
 pre-save transform: Signature expansion in nowiki tags (T2093)
 !! options