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

Change subject: Make Scribunto tests more robust
......................................................................


Make Scribunto tests more robust

Fixes the Scribunto tests for set ups that have
'allowDataAccessInUserLanguage' set to true.
Also fixes the behaviour for languages that use
a comma separator other than the English one (eg.
Arabic).

Change-Id: Ib1e3ba53e2f51b3d4d5b6c9d017d47ececd9b897
---
M 
client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
M 
client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
2 files changed, 33 insertions(+), 4 deletions(-)

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



diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
index 4eb0ab4..4f2fa62 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
@@ -30,6 +30,20 @@
                );
        }
 
+       protected function setUp() {
+               parent::setUp();
+
+               $settings = WikibaseClient::getDefaultInstance()->getSettings();
+               $this->oldAllowDataAccessInUserLanguage = 
$settings->getSetting( 'allowDataAccessInUserLanguage' );
+               $this->setAllowDataAccessInUserLanguage( false );
+       }
+
+       protected function tearDown() {
+               parent::tearDown();
+
+               $this->setAllowDataAccessInUserLanguage( 
$this->oldAllowDataAccessInUserLanguage );
+       }
+
        public function testConstructor() {
                $engine = Scribunto::newDefaultEngine( array() );
                $luaWikibaseLibrary = new Scribunto_LuaWikibaseEntityLibrary( 
$engine );
@@ -102,4 +116,12 @@
                return new Scribunto_LuaWikibaseEntityLibrary( $engine );
        }
 
+       /**
+        * @param bool $value
+        */
+       private function setAllowDataAccessInUserLanguage( $value ) {
+               $settings = WikibaseClient::getDefaultInstance()->getSettings();
+               $settings->setSetting( 'allowDataAccessInUserLanguage', $value 
);
+       }
+
 }
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
index 9d3912f..3dd9c13 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
@@ -51,6 +51,7 @@
 
                $settings = WikibaseClient::getDefaultInstance()->getSettings();
                $this->oldAllowDataAccessInUserLanguage = 
$settings->getSetting( 'allowDataAccessInUserLanguage' );
+               $this->setAllowDataAccessInUserLanguage( false );
        }
 
        protected function tearDown() {
@@ -254,11 +255,17 @@
                $entityArr = $luaWikibaseLibrary->getEntity( 'Q32487' );
 
                $snaks = $entityArr[0]['claims']['P342'][1]['qualifiers'];
-               $this->assertSame(
-                       array( 'A qualifier Snak, Moar qualifiers' ),
-                       $luaWikibaseLibrary->renderSnaks( $snaks )
-               );
+               $expected = array( 'A qualifier Snak, Moar qualifiers' );
+               if ( $allowDataAccessInUserLanguage ) {
+                       global $wgUser;
 
+                       $lang = Language::factory( $wgUser->getOption( 
'language' ) );
+                       $expected = array(
+                               $lang->commaList( array( 'A qualifier Snak', 
'Moar qualifiers' ) )
+                       );
+               }
+
+               $this->assertSame( $expected, $luaWikibaseLibrary->renderSnaks( 
$snaks ) );
                $this->assertSame( $allowDataAccessInUserLanguage, $cacheSplit 
);
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1e3ba53e2f51b3d4d5b6c9d017d47ececd9b897
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <h...@online.de>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: JanZerebecki <jan.wikime...@zerebecki.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