Aude has uploaded a new change for review.

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


Change subject: Inject settings into api client info function
......................................................................

Inject settings into api client info function

Change-Id: Iba2a88813d177504fb71e47df2f8defc12d0abc8
---
M client/includes/api/ApiClientInfo.php
M client/tests/phpunit/includes/api/ApiClientInfoTest.php
2 files changed, 31 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/37/64037/1

diff --git a/client/includes/api/ApiClientInfo.php 
b/client/includes/api/ApiClientInfo.php
index 9e201e1..50aaea1 100644
--- a/client/includes/api/ApiClientInfo.php
+++ b/client/includes/api/ApiClientInfo.php
@@ -51,12 +51,15 @@
        public function execute() {
                $params = $this->extractRequestParams();
 
+               // @todo inject settings into entire api module
+               $settings = Settings::singleton();
+
                $data = array( 'repo' => array() );
 
                foreach ( $params['prop'] as $p ) {
                        switch ( $p ) {
                                case 'url':
-                                       $data['repo']['url'] = $this->urlInfo();
+                                       $data['repo']['url'] = $this->urlInfo( 
$settings );
                                        break;
                                default;
                                        break;
@@ -73,11 +76,11 @@
         *
         * @return array
         */
-       public function urlInfo() {
+       public function urlInfo( SettingsArray $settings ) {
                return array(
-                       'base' => Settings::get( 'repoUrl' ),
-                       'scriptpath' => Settings::get( 'repoScriptPath' ),
-                       'articlepath' => Settings::get( 'repoArticlePath' ),
+                       'base' => $settings->getSetting( 'repoUrl' ),
+                       'scriptpath' => $settings->getSetting( 'repoScriptPath' 
),
+                       'articlepath' => $settings->getSetting( 
'repoArticlePath' ),
                );
        }
 
diff --git a/client/tests/phpunit/includes/api/ApiClientInfoTest.php 
b/client/tests/phpunit/includes/api/ApiClientInfoTest.php
index c61c6c8..186db9e 100644
--- a/client/tests/phpunit/includes/api/ApiClientInfoTest.php
+++ b/client/tests/phpunit/includes/api/ApiClientInfoTest.php
@@ -1,6 +1,7 @@
 <?php
-
 namespace Wikibase\Test;
+
+use Wikibase\SettingsArray;
 
 /**
  * Tests for ApiClientInfo module.
@@ -39,7 +40,10 @@
  */
 class ApiClientInfoTest extends \ApiTestCase {
 
-       public function testGetUrlInfo() {
+       /**
+        * @dataProvider settingsProvider
+        */
+       public function testGetUrlInfo( SettingsArray $settings ) {
                $data = $this->doApiRequest(
                        array(
                                'action' => 'query',
@@ -63,8 +67,22 @@
                $this->assertTrue( is_string( $urlInfo['scriptpath'] ) );
                $this->assertTrue( is_string( $urlInfo['articlepath'] ) );
 
-               $this->assertEquals( \Wikibase\Settings::get( 'repoUrl' ), 
$urlInfo['base'] );
-               $this->assertEquals( \Wikibase\Settings::get( 'repoScriptPath' 
), $urlInfo['scriptpath'] );
-               $this->assertEquals( \Wikibase\Settings::get( 'repoArticlePath' 
), $urlInfo['articlepath'] );
+               $this->assertEquals( $settings->getSetting( 'repoUrl' ), 
$urlInfo['base'] );
+               $this->assertEquals( $settings->getSetting( 'repoScriptPath' ), 
$urlInfo['scriptpath'] );
+               $this->assertEquals( $settings->getSetting( 'repoArticlePath' 
), $urlInfo['articlepath'] );
+
        }
+
+       public function settingsProvider() {
+               $settings = array(
+                       'repoUrl' => 'http://www.example.org',
+                       'repoScriptPath' => '/w',
+                       'repoArticlePath' => '/wiki/$1'
+               );
+
+               return array(
+                       array( new SettingsArray( $settings ) )
+               );
+       }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba2a88813d177504fb71e47df2f8defc12d0abc8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to