$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' );
};
$context = RequestContext::getMain();
$user = $context->getUser();
$options = ParserOptions::newFromContext( $context );
+ $options->setTimestamp( $this->getFakeTimestamp() );
if ( !isset( $opts['wrap'] ) ) {
$options->setWrapOutputClass( false );
}
/**
- * 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;
}
}
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>