Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Add missing test cases for onAPIQuerySiteInfoGeneralInfo hook
......................................................................

Add missing test cases for onAPIQuerySiteInfoGeneralInfo hook

Bug: T143910
Change-Id: Ife12bad4876a15fd8d20db7cb0c115b2b2d89488
---
M repo/tests/phpunit/includes/RepoHooksTest.php
1 file changed, 50 insertions(+), 40 deletions(-)


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

diff --git a/repo/tests/phpunit/includes/RepoHooksTest.php 
b/repo/tests/phpunit/includes/RepoHooksTest.php
index ddac41e..5c66013 100644
--- a/repo/tests/phpunit/includes/RepoHooksTest.php
+++ b/repo/tests/phpunit/includes/RepoHooksTest.php
@@ -1,11 +1,12 @@
 <?php
 
-namespace Wikibase\Tests;
+namespace Wikibase\Repo\Tests;
 
 use ApiQuerySiteinfo;
 use ConfigFactory;
 use DerivativeContext;
 use ImportStringSource;
+use MediaWikiTestCase;
 use MWException;
 use OutputPage;
 use ParserOutput;
@@ -13,6 +14,7 @@
 use Title;
 use Wikibase\Repo\WikibaseRepo;
 use Wikibase\RepoHooks;
+use Wikibase\SettingsArray;
 use WikiImporter;
 
 /**
@@ -27,21 +29,28 @@
  * @author Daniel Kinzler
  * @author Thiemo Mättig
  */
-class RepoHooksTest extends \MediaWikiTestCase {
+class RepoHooksTest extends MediaWikiTestCase {
 
        private $saveAllowImport = false;
 
        protected function setUp() {
                parent::setUp();
 
-               $this->saveAllowImport = 
WikibaseRepo::getDefaultInstance()->getSettings()->getSetting( 
'allowEntityImport' );
+               $this->saveAllowImport = $this->getSettings()->getSetting( 
'allowEntityImport' );
        }
 
        protected function tearDown() {
-               WikibaseRepo::getDefaultInstance()->getSettings()->setSetting( 
'allowEntityImport', $this->saveAllowImport );
+               $this->getSettings()->setSetting( 'allowEntityImport', 
$this->saveAllowImport );
                Title::clearCaches();
 
                parent::tearDown();
+       }
+
+       /**
+        * @return SettingsArray
+        */
+       private function getSettings() {
+               return WikibaseRepo::getDefaultInstance()->getSettings();
        }
 
        public function testOnAPIQuerySiteInfoGeneralInfo() {
@@ -49,42 +58,46 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $actual = array();
+               $actual = [];
                RepoHooks::onAPIQuerySiteInfoGeneralInfo( $api, $actual );
+
                foreach ( $actual['wikibase-propertytypes'] as $key => $value ) 
{
                        $this->assertInternalType( 'string', $key );
                        $this->assertInternalType( 'string', 
$value['valuetype'] );
                }
+               $this->assertArrayNotHasKey( 'wikibase-sparql', $actual );
+               $this->assertStringStartsWith( 'http://', 
$actual['wikibase-conceptbaseuri'] );
+               $this->assertStringEndsWith( '/entity/', 
$actual['wikibase-conceptbaseuri'] );
        }
 
        public function revisionInfoProvider() {
-               return array(
-                       'empty_allowimport' => array(
-                               array(),
+               return [
+                       'empty_allowimport' => [
+                               [],
                                true
-                       ),
-                       'empty_noimport' => array(
-                               array(),
+                       ],
+                       'empty_noimport' => [
+                               [],
                                true
-                       ),
-                       'wikitext_allowimport' => array(
-                               array( 'model' => CONTENT_MODEL_WIKITEXT ),
+                       ],
+                       'wikitext_allowimport' => [
+                               [ 'model' => CONTENT_MODEL_WIKITEXT ],
                                true
-                       ),
-                       'wikitext_noimport' => array(
-                               array( 'model' => CONTENT_MODEL_WIKITEXT ),
+                       ],
+                       'wikitext_noimport' => [
+                               [ 'model' => CONTENT_MODEL_WIKITEXT ],
                                false
-                       ),
-                       'item_allowimport' => array(
-                               array( 'model' => CONTENT_MODEL_WIKIBASE_ITEM ),
+                       ],
+                       'item_allowimport' => [
+                               [ 'model' => CONTENT_MODEL_WIKIBASE_ITEM ],
                                false,
                                MWException::class
-                       ),
-                       'item_noimport' => array(
-                               array( 'model' => CONTENT_MODEL_WIKIBASE_ITEM ),
+                       ],
+                       'item_noimport' => [
+                               [ 'model' => CONTENT_MODEL_WIKIBASE_ITEM ],
                                true
-                       )
-               );
+                       ]
+               ];
        }
 
        /**
@@ -100,22 +113,19 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               WikibaseRepo::getDefaultInstance()->getSettings()->setSetting(
-                       'allowEntityImport',
-                       $allowEntityImport
-               );
+               $this->getSettings()->setSetting( 'allowEntityImport', 
$allowEntityImport );
 
                if ( $expectedException !== null ) {
                        $this->setExpectedException( $expectedException );
                }
 
-               RepoHooks::onImportHandleRevisionXMLTag( $importer, array(), 
$revisionInfo );
+               RepoHooks::onImportHandleRevisionXMLTag( $importer, [], 
$revisionInfo );
                $this->assertTrue( true ); // make PHPUnit happy
        }
 
        public function importProvider() {
-               return array(
-                       'wikitext' => array( <<<XML
+               return [
+                       'wikitext' => [ <<<XML
 <mediawiki>
   <siteinfo>
     <sitename>TestWiki</sitename>
@@ -135,8 +145,8 @@
 XML
                                ,
                                false
-                       ),
-                       'item' => array( <<<XML
+                       ],
+                       'item' => [ <<<XML
 <mediawiki>
   <siteinfo>
     <sitename>TestWiki</sitename>
@@ -157,8 +167,8 @@
                                ,
                                false,
                                MWException::class
-                       ),
-                       'item (allow)' => array( <<<XML
+                       ],
+                       'item (allow)' => [ <<<XML
 <mediawiki>
   <siteinfo>
     <sitename>TestWiki</sitename>
@@ -178,8 +188,8 @@
 XML
                        ,
                                true
-                       ),
-               );
+                       ],
+               ];
        }
 
        /**
@@ -191,7 +201,7 @@
                stream_wrapper_unregister( 'uploadsource' );
                \MediaWiki\restoreWarnings();
 
-               WikibaseRepo::getDefaultInstance()->getSettings()->setSetting( 
'allowEntityImport', $allowImport );
+               $this->getSettings()->setSetting( 'allowEntityImport', 
$allowImport );
 
                $source = new ImportStringSource( $xml );
                $importer = new WikiImporter( $source, 
ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
@@ -211,7 +221,7 @@
        }
 
        public function testOnOutputPageParserOutput() {
-               $altLinks = array( array( 'a' => 'b' ), array( 'c', 'd' ) );
+               $altLinks = [ [ 'a' => 'b' ], [ 'c', 'd' ] ];
 
                $context = new DerivativeContext( RequestContext::getMain() );
                $out = new OutputPage( $context );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife12bad4876a15fd8d20db7cb0c115b2b2d89488
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

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

Reply via email to