jenkins-bot has submitted this change and it was merged.

Change subject: Make tests pass with $wgBabelUseDatabase = true
......................................................................


Make tests pass with $wgBabelUseDatabase = true

Change-Id: I6227ee45e4ada7ce49f6bbc04b00f254969503da
---
M tests/phpunit/BabelTest.php
1 file changed, 29 insertions(+), 3 deletions(-)

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/BabelTest.php b/tests/phpunit/BabelTest.php
index f73b7fb..aeb3d52 100644
--- a/tests/phpunit/BabelTest.php
+++ b/tests/phpunit/BabelTest.php
@@ -3,6 +3,7 @@
 namespace Babel\Tests;
 
 use Babel;
+use DeferredUpdates;
 use Language;
 use MediaWikiTestCase;
 use Parser;
@@ -10,6 +11,7 @@
 use ParserOutput;
 use Title;
 use User;
+use WikiPage;
 
 /**
  * @covers Babel
@@ -27,8 +29,19 @@
 
                $this->setMwGlobals( [
                        'wgContLang' => Language::factory( 'qqx' ),
+                       // Note that individual tests will change this
+                       'wgBabelUseDatabase' => true,
                ] );
-               $this->insertPage( 'User:User-1', '[[Category:en]]' );
+               $user = User::newFromName( 'User-1' );
+               $user->addToDatabase();
+               $title = $user->getUserPage();
+               $this->insertPage( $title->getPrefixedText(), '{{#babel:en-1}}' 
);
+               $page = WikiPage::factory( $title );
+               // Force a run of LinksUpdate
+               $updates = $page->getContent()->getSecondaryDataUpdates( $title 
);
+               foreach ( $updates as $update ) {
+                       $update->doUpdate();
+               }
        }
 
        /**
@@ -190,12 +203,25 @@
                );
        }
 
-       public function testGetUserLanguages() {
+       /**
+        * Data provider to run a test with both db enabled and disabled
+        */
+       public static function provideSettings() {
+               return [
+                       [ [ 'wgBabelUseDatabase' => true ] ],
+                       [ [ 'wgBabelUseDatabase' => false ] ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideSettings
+        */
+       public function testGetUserLanguages( $settings ) {
+               $this->setMwGlobals( $settings );
                $user = User::newFromName( 'User-1' );
                $languages = Babel::getUserLanguages( $user );
                $this->assertSame( [
                        'en',
                ], $languages );
        }
-
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/310169
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6227ee45e4ada7ce49f6bbc04b00f254969503da
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Babel
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Thiemo M├Ąttig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to