Krinkle has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/363757 )
Change subject: parser: Add parser tests for 4 and 5 tildes in PST
......................................................................
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
---
M tests/parser/ParserTestRunner.php
M tests/parser/parserTests.txt
2 files changed, 16 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/57/363757/1
diff --git a/tests/parser/ParserTestRunner.php
b/tests/parser/ParserTestRunner.php
index a373142..77717f0 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -266,7 +266,10 @@
$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 @@
$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 @@
}
/**
- * 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 44bcdff..4c48ed5 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -13619,11 +13619,15 @@
pst
!! wikitext
* ~~~
+* ~~~~
+* ~~~~~
* <noinclude>~~~</noinclude>
* <includeonly>~~~</includeonly>
* <onlyinclude>~~~</onlyinclude>
!! 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)
* <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
* <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
* <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
--
To view, visit https://gerrit.wikimedia.org/r/363757
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5adacffccb1212651c3031ca2fc4c20f717ff24a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits