Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/310169

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, 36 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Babel 
refs/changes/69/310169/1

diff --git a/tests/phpunit/BabelTest.php b/tests/phpunit/BabelTest.php
index feff942..9195dd1 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,21 @@
 
                $this->setMwGlobals( [
                        'wgContLang' => Language::factory( 'qqx' ),
+                       // Note that individual tests will change this
+                       'wgBabelUseDatabase' => true,
+                       'wgBabelCentralApi' => false,
+                       'wgBabelCentralDb' => false,
                ] );
-               $this->insertPage( 'User:User-1', '{{#babel:en-1}}' );
+               $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,7 +205,21 @@
                );
        }
 
-       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( [
@@ -198,7 +227,11 @@
                ], $languages );
        }
 
-       public function testGetUserLanguageInfo() {
+       /**
+        * @dataProvider provideSettings
+        */
+       public function testGetUserLanguageInfo( $settings ) {
+               $this->setMwGlobals( $settings );
                $user = User::newFromName( 'User-1' );
                $languages = Babel::getUserLanguageInfo( $user );
                $this->assertSame( [

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6227ee45e4ada7ce49f6bbc04b00f254969503da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Babel
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

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

Reply via email to