Merge "Selenium: record video of every test"
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / ParserOptionsTest.php
index 29f1c8c..6413ddd 100644 (file)
@@ -13,6 +13,7 @@ class ParserOptionsTest extends MediaWikiTestCase {
                $wrap->defaults = null;
                $wrap->lazyOptions = [
                        'dateformat' => [ ParserOptions::class, 'initDateFormat' ],
+                       'speculativeRevId' => [ ParserOptions::class, 'initSpeculativeRevId' ],
                ];
                $wrap->inCacheKey = [
                        'dateformat' => true,
@@ -45,9 +46,9 @@ class ParserOptionsTest extends MediaWikiTestCase {
        public function testNewCanonical() {
                $wgUser = $this->getMutableTestUser()->getUser();
                $wgLang = Language::factory( 'fr' );
-               $wgContLang = Language::factory( 'qqx' );
+               $contLang = Language::factory( 'qqx' );
 
-               $this->setContentLang( $wgContLang );
+               $this->setContentLang( $contLang );
                $this->setMwGlobals( [
                        'wgUser' => $wgUser,
                        'wgLang' => $wgLang,
@@ -80,13 +81,12 @@ class ParserOptionsTest extends MediaWikiTestCase {
                $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
@@ -310,4 +310,19 @@ class ParserOptionsTest extends MediaWikiTestCase {
                ], 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() );
+       }
+
 }