$wrap->defaults = null;
$wrap->lazyOptions = [
'dateformat' => [ ParserOptions::class, 'initDateFormat' ],
+ 'speculativeRevId' => [ ParserOptions::class, 'initSpeculativeRevId' ],
];
$wrap->inCacheKey = [
'dateformat' => true,
public function testNewCanonical() {
$wgUser = $this->getMutableTestUser()->getUser();
$wgLang = Language::factory( 'fr' );
- $wgContLang = Language::factory( 'qqx' );
+ $contLang = Language::factory( 'qqx' );
+ $this->setContentLang( $contLang );
$this->setMwGlobals( [
'wgUser' => $wgUser,
'wgLang' => $wgLang,
- 'wgContLang' => $wgContLang,
] );
$user = $this->getMutableTestUser()->getUser();
$this->assertSame( $user, $popt->getUser() );
$this->assertSame( $lang, $popt->getUserLangObj() );
- // Passing 'canonical' uses an anon and $wgContLang, and ignores
- // any passed $userLang
+ // Passing 'canonical' uses an anon and $contLang, and ignores any passed $userLang
$popt = ParserOptions::newCanonical( 'canonical' );
$this->assertTrue( $popt->getUser()->isAnon() );
- $this->assertSame( $wgContLang, $popt->getUserLangObj() );
+ $this->assertSame( $contLang, $popt->getUserLangObj() );
$popt = ParserOptions::newCanonical( 'canonical', $lang2 );
- $this->assertSame( $wgContLang, $popt->getUserLangObj() );
+ $this->assertSame( $contLang, $popt->getUserLangObj() );
// Passing an IContextSource uses the user and lang from it, and ignores
// any passed $userLang
], ParserOptions::allCacheVaryingOptions() );
}
+ public function testGetSpeculativeRevid() {
+ $options = new ParserOptions();
+
+ $this->assertFalse( $options->getSpeculativeRevId() );
+
+ $counter = 0;
+ $options->setSpeculativeRevIdCallback( function () use( &$counter ) {
+ return ++$counter;
+ } );
+
+ // make sure the same value is re-used once it is determined
+ $this->assertSame( 1, $options->getSpeculativeRevId() );
+ $this->assertSame( 1, $options->getSpeculativeRevId() );
+ }
+
}