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

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, 53 insertions(+), 40 deletions(-)

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



diff --git a/repo/tests/phpunit/includes/RepoHooksTest.php 
b/repo/tests/phpunit/includes/RepoHooksTest.php
index ddac41e..bcc2502 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,49 @@
                        ->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->assertInternalType( 'string', 
$actual['wikibase-conceptbaseuri'] );
+
+               if ( array_key_exists( 'wikibase-sparql', $actual ) ) {
+                       $this->assertInternalType( 'string', 
$actual['wikibase-sparql'] );
+               }
        }
 
        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 +116,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 +148,8 @@
 XML
                                ,
                                false
-                       ),
-                       'item' => array( <<<XML
+                       ],
+                       'item' => [ <<<XML
 <mediawiki>
   <siteinfo>
     <sitename>TestWiki</sitename>
@@ -157,8 +170,8 @@
                                ,
                                false,
                                MWException::class
-                       ),
-                       'item (allow)' => array( <<<XML
+                       ],
+                       'item (allow)' => [ <<<XML
 <mediawiki>
   <siteinfo>
     <sitename>TestWiki</sitename>
@@ -178,8 +191,8 @@
 XML
                        ,
                                true
-                       ),
-               );
+                       ],
+               ];
        }
 
        /**
@@ -191,7 +204,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 +224,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: merged
Gerrit-Change-Id: Ife12bad4876a15fd8d20db7cb0c115b2b2d89488
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>
Gerrit-Reviewer: Lokal Profil <lokal.pro...@gmail.com>
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