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

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

Change subject: More descriptive names for $repo variables and methods
......................................................................

More descriptive names for $repo variables and methods

This is split from If6c96e0 to make it easier to review and find
out what makes jenkins fail.

Change-Id: I85e183b51cdc3d3f4870704de19e5f3242ff86fe
---
M client/includes/UpdateRepo/UpdateRepoOnMove.php
M client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
M repo/tests/phpunit/includes/EntityViewTest.php
M repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
M repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
M repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
6 files changed, 38 insertions(+), 33 deletions(-)


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

diff --git a/client/includes/UpdateRepo/UpdateRepoOnMove.php 
b/client/includes/UpdateRepo/UpdateRepoOnMove.php
index 319f249..272ca41 100644
--- a/client/includes/UpdateRepo/UpdateRepoOnMove.php
+++ b/client/includes/UpdateRepo/UpdateRepoOnMove.php
@@ -63,4 +63,5 @@
                        'user' => $this->user->getName()
                );
        }
+
 }
diff --git a/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php 
b/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
index 46fb334..0b58453 100644
--- a/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
+++ b/client/tests/phpunit/includes/hooks/SidebarHookHandlersTest.php
@@ -105,16 +105,16 @@
        }
 
        /**
-        * @param array[] $links
+        * @param array[] $siteLinksPerItem
         *
         * @return MockRepository
         */
-       private function getMockRepo( $links ) {
+       private function getMockRepository( $siteLinksPerItem ) {
                $repo = new MockRepository();
 
-               foreach ( $links as $itemKey => $itemLinks ) {
-                       $itemId = new ItemId( $itemKey );
-                       $item = $this->newItem( $itemId, $itemLinks );
+               foreach ( $siteLinksPerItem as $idString => $siteLinks ) {
+                       $itemId = new ItemId( $idString );
+                       $item = $this->newItem( $itemId, $siteLinks );
                        $repo->putEntity( $item );
                }
 
@@ -165,7 +165,7 @@
        private function newSidebarHookHandlers( array $settings = array() ) {
                $badgeId = $this->getBadgeItem()->getId();
 
-               $links = array(
+               $siteLinksPerItem = array(
                        'Q1' => array(
                                new SiteLink( 'dewiki', 'Sauerstoff', array( 
$badgeId ) ),
                                new SiteLink( 'enwiki', 'Oxygen' ),
@@ -189,7 +189,7 @@
                $namespaceChecker = new NamespaceChecker( array(), $namespaces 
);
                $siteStore = $this->getSiteStore();
 
-               $mockRepo = $this->getMockRepo( $links );
+               $mockRepo = $this->getMockRepository( $siteLinksPerItem );
                $mockRepo->putEntity( $this->getBadgeItem() );
 
                $otherProjectsSidebarGenerator = new 
OtherProjectsSidebarGenerator(
diff --git a/repo/tests/phpunit/includes/EntityViewTest.php 
b/repo/tests/phpunit/includes/EntityViewTest.php
index 8030900..65917c9 100644
--- a/repo/tests/phpunit/includes/EntityViewTest.php
+++ b/repo/tests/phpunit/includes/EntityViewTest.php
@@ -48,7 +48,10 @@
  */
 abstract class EntityViewTest extends \MediaWikiLangTestCase {
 
-       protected static $mockRepo;
+       /**
+        * @var MockRepository
+        */
+       private $mockRepository;
 
        protected function newEntityIdParser() {
                // The data provides use P123 and Q123 IDs, so the parser needs 
to understand these.
@@ -123,10 +126,10 @@
                        $languageFallbackChain = $factory->newFromLanguage( 
Language::factory( $langCode ) );
                }
 
-               $mockRepo = $this->getMockRepo();
+               $mockRepository = $this->getMockRepository();
 
                if ( !$entityInfoBuilderFactory ) {
-                       $entityInfoBuilderFactory = $mockRepo;
+                       $entityInfoBuilderFactory = $mockRepository;
                }
 
                if ( !$entityTitleLookup ) {
@@ -158,7 +161,7 @@
                $entityView = new $class(
                        $context,
                        $snakFormatter,
-                       $mockRepo,
+                       $mockRepository,
                        $entityInfoBuilderFactory,
                        $entityTitleLookup,
                        $options,
@@ -179,25 +182,25 @@
                return $options;
        }
 
-       protected function getMockRepo() {
-               if ( !isset( self::$mockRepo ) ) {
-                       $mockRepo = new MockRepository();
+       private function getMockRepository() {
+               if ( $this->mockRepository === null ) {
+                       $mockRepository = new MockRepository();
 
-                       $mockRepo->putEntity( $this->makeItem( 'Q33' ) );
-                       $mockRepo->putEntity( $this->makeItem( 'Q22' ) );
-                       $mockRepo->putEntity( $this->makeItem( 'Q23' ) );
-                       $mockRepo->putEntity( $this->makeItem( 'Q24' ) );
+                       $mockRepository->putEntity( $this->makeItem( 'Q33' ) );
+                       $mockRepository->putEntity( $this->makeItem( 'Q22' ) );
+                       $mockRepository->putEntity( $this->makeItem( 'Q23' ) );
+                       $mockRepository->putEntity( $this->makeItem( 'Q24' ) );
 
-                       $mockRepo->putEntity( $this->makeProperty( 'P11', 
'wikibase-item' ) );
-                       $mockRepo->putEntity( $this->makeProperty( 'P23', 
'string' ) );
-                       $mockRepo->putEntity( $this->makeProperty( 'P42', 'url' 
) );
-                       $mockRepo->putEntity( $this->makeProperty( 'P43', 
'commonsMedia' ) );
-                       $mockRepo->putEntity( $this->makeProperty( 'P44', 
'wikibase-item' ) );
+                       $mockRepository->putEntity( $this->makeProperty( 'P11', 
'wikibase-item' ) );
+                       $mockRepository->putEntity( $this->makeProperty( 'P23', 
'string' ) );
+                       $mockRepository->putEntity( $this->makeProperty( 'P42', 
'url' ) );
+                       $mockRepository->putEntity( $this->makeProperty( 'P43', 
'commonsMedia' ) );
+                       $mockRepository->putEntity( $this->makeProperty( 'P44', 
'wikibase-item' ) );
 
-                       self::$mockRepo = $mockRepo;
+                       $this->mockRepository = $mockRepository;
                }
 
-               return self::$mockRepo;
+               return $this->mockRepository;
        }
 
        /**
diff --git 
a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
index 15f976b..23d53c6 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataRequestHandlerTest.php
@@ -68,7 +68,7 @@
         * @return EntityDataRequestHandler
         */
        protected function newHandler() {
-               $entityLookup = EntityDataTestProvider::getMockRepo();
+               $entityLookup = EntityDataTestProvider::getMockRepository();
 
                $idParser = new BasicEntityIdParser(); // we only test for 
items and properties here.
 
diff --git a/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
index 1eb2dff..0b548a2 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
@@ -2,9 +2,9 @@
 
 namespace Wikibase\Test;
 
+use Wikibase\DataModel\Entity\Item;
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\EntityRevision;
-use Wikibase\DataModel\Entity\Item;
 use Wikibase\Lib\Store\EntityRedirect;
 
 /**
@@ -39,18 +39,18 @@
                return array( $redirect );
        }
 
-       public static function getMockRepo() {
-               $repo = new MockRepository();
+       public static function getMockRepository() {
+               $mockRepository = new MockRepository();
 
                foreach ( self::getEntityRevisions() as $entityRev ) {
-                       $repo->putEntity( $entityRev->getEntity(), 
$entityRev->getRevision(), $entityRev->getTimestamp() );
+                       $mockRepository->putEntity( $entityRev->getEntity(), 
$entityRev->getRevision(), $entityRev->getTimestamp() );
                }
 
                foreach ( self::getEntityRedirects() as $entityRedir ) {
-                       $repo->putRedirect( $entityRedir );
+                       $mockRepository->putRedirect( $entityRedir );
                }
 
-               return $repo;
+               return $mockRepository;
        }
 
        public static function provideHandleRequest() {
@@ -445,4 +445,5 @@
 
                return $cases;
        }
+
 }
diff --git a/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php 
b/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
index 3e617c4..c43d7bf 100644
--- a/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialEntityDataTest.php
@@ -74,7 +74,7 @@
        }
 
        protected function newRequestHandler() {
-               $mockRepo = EntityDataTestProvider::getMockRepo();
+               $mockRepo = EntityDataTestProvider::getMockRepository();
 
                $entityRevisionLookup = $mockRepo;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85e183b51cdc3d3f4870704de19e5f3242ff86fe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to