From: Timo Tijhof Date: Fri, 7 Jul 2017 01:02:47 +0000 (-0700) Subject: parser: Add parser tests for 4 and 5 tildes in PST X-Git-Tag: 1.31.0-rc.0~2774^2 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=640d6ebb34122af7198c525d2c3e64be5125b9b0;p=lhc%2Fweb%2Fwiklou.git parser: Add parser tests for 4 and 5 tildes in PST Add logic in ParserTestRunner that sets the same fake timestamp used by the Parser magic word expansion, also in ParserOptions, which is used by preSaveTransform(). Change-Id: I5adacffccb1212651c3031ca2fc4c20f717ff24a --- diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index a373142d7e..77717f0161 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -266,7 +266,10 @@ class ParserTestRunner { $setup['wgSVGConverters'] = [ 'null' => 'echo "1">$output' ]; // Fake constant timestamp - Hooks::register( 'ParserGetVariableValueTs', 'ParserTestRunner::getFakeTimestamp' ); + Hooks::register( 'ParserGetVariableValueTs', function ( &$parser, &$ts ) { + $ts = $this->getFakeTimestamp(); + return true; + } ); $teardown[] = function () { Hooks::clear( 'ParserGetVariableValueTs' ); }; @@ -747,6 +750,7 @@ class ParserTestRunner { $context = RequestContext::getMain(); $user = $context->getUser(); $options = ParserOptions::newFromContext( $context ); + $options->setTimestamp( $this->getFakeTimestamp() ); if ( !isset( $opts['wrap'] ) ) { $options->setWrapOutputClass( false ); @@ -1598,11 +1602,14 @@ class ParserTestRunner { } /** - * The ParserGetVariableValueTs hook, used to make sure time-related parser + * Fake constant timestamp to make sure time-related parser * functions give a persistent value. + * + * - Parser::getVariableValue (via ParserGetVariableValueTs hook) + * - Parser::preSaveTransform (via ParserOptions) */ - static function getFakeTimestamp( &$parser, &$ts ) { - $ts = 123; // parsed as '1970-01-01T00:02:03Z' - return true; + private function getFakeTimestamp() { + // parsed as '1970-01-01T00:02:03Z' + return 123; } } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 44bcdffeb4..4c48ed53d6 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -13619,11 +13619,15 @@ pre-save transform: Signature expansion pst !! wikitext * ~~~ +* ~~~~ +* ~~~~~ * ~~~ * ~~~ * ~~~ !! html/php * [[Special:Contributions/127.0.0.1|127.0.0.1]] +* [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC) +* 00:02, 1 January 1970 (UTC) * [[Special:Contributions/127.0.0.1|127.0.0.1]] * [[Special:Contributions/127.0.0.1|127.0.0.1]] * [[Special:Contributions/127.0.0.1|127.0.0.1]]