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

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

Change subject: Clean up MockClientStore
......................................................................

Clean up MockClientStore

Again, I don't think it's a good idea to make these objects static.
I may be wrong.

Change-Id: I5313b4f774a6a99c8427a2ea4f783d09f0f39eb3
---
M client/tests/phpunit/MockClientStore.php
1 file changed, 103 insertions(+), 22 deletions(-)


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

diff --git a/client/tests/phpunit/MockClientStore.php 
b/client/tests/phpunit/MockClientStore.php
index 9b6d402..3609dca 100644
--- a/client/tests/phpunit/MockClientStore.php
+++ b/client/tests/phpunit/MockClientStore.php
@@ -2,11 +2,19 @@
 
 namespace Wikibase\Test;
 
+use Wikibase\ChangesTable;
+use Wikibase\Client\Store\EntityIdLookup;
 use Wikibase\Client\Usage\NullUsageTracker;
 use Wikibase\Client\Usage\SubscriptionManager;
+use Wikibase\Client\Usage\UsageLookup;
+use Wikibase\Client\Usage\UsageTracker;
 use Wikibase\ClientStore;
+use Wikibase\Lib\Store\EntityLookup;
+use Wikibase\Lib\Store\EntityRevisionLookup;
 use Wikibase\Lib\Store\SiteLinkLookup;
 use Wikibase\PropertyInfoStore;
+use Wikibase\PropertyLabelResolver;
+use Wikibase\TermIndex;
 
 /**
  * (Incomplete) ClientStore mock
@@ -15,48 +23,119 @@
  *
  * @license GNU GPL v2+
  * @author Marius Hoch < h...@online.de >
+ * @author Thiemo Mättig
  */
 class MockClientStore implements ClientStore {
 
+       /**
+        * @var MockRepository|null
+        */
+       private $mockRepository = null;
+
+       /**
+        * @var MockPropertyInfoStore|null
+        */
+       private $mockPropertyInfoStore = null;
+
+       /**
+        * @see ClientStore::getUsageLookup
+        *
+        * @return UsageLookup
+        */
        public function getUsageLookup() {
                return new NullUsageTracker();
        }
 
+       /**
+        * @see ClientStore::getUsageTracker
+        *
+        * @return UsageTracker
+        */
        public function getUsageTracker() {
                return new NullUsageTracker();
        }
 
+       /**
+        * @see ClientStore::getSubscriptionManager
+        *
+        * @return SubscriptionManager
+        */
        public function getSubscriptionManager() {
                return new SubscriptionManager();
        }
-       public function getPropertyLabelResolver() {}
-       public function getTermIndex() {}
-       public function getEntityIdLookup() {}
-       public function newChangesTable() {}
-       public function clear() {}
-       public function rebuild() {}
 
-       private function getMock() {
-               static $mockRepo = false;
-               if ( !$mockRepo ) {
-                       $mockRepo = new MockRepository();
-               }
-
-               return $mockRepo;
+       /**
+        * @see ClientStore::getPropertyLabelResolver
+        *
+        * @return PropertyLabelResolver
+        */
+       public function getPropertyLabelResolver() {
+               // FIXME: Incomplete
        }
 
-       /*
+       /**
+        * @see ClientStore::getTermIndex
+        *
+        * @return TermIndex
+        */
+       public function getTermIndex() {
+               // FIXME: Incomplete
+       }
+
+       /**
+        * @see ClientStore::getEntityIdLookup
+        *
+        * @return EntityIdLookup
+        */
+       public function getEntityIdLookup() {
+               // FIXME: Incomplete
+       }
+
+       /**
+        * @see ClientStore::newChangesTable
+        *
+        * @return ChangesTable
+        */
+       public function newChangesTable() {
+               // FIXME: Incomplete
+       }
+
+       /**
+        * @see ClientStore::clear
+        */
+       public function clear() {
+       }
+
+       /**
+        * @see ClientStore::rebuild
+        */
+       public function rebuild() {
+       }
+
+       private function getMockRepository() {
+               if ( $this->mockRepository === null ) {
+                       $this->mockRepository = new MockRepository();
+               }
+
+               return $this->mockRepository;
+       }
+
+       /**
+        * @see ClientStore::getEntityLookup
+        *
         * @return EntityLookup
         */
        public function getEntityLookup() {
-               return $this->getMock();
+               return $this->getMockRepository();
        }
 
-       /*
+       /**
+        * @see ClientStore::getEntityRevisionLookup
+        *
         * @return EntityRevisionLookup
         */
        public function getEntityRevisionLookup() {
-               return $this->getMock();
+               return $this->getMockRepository();
        }
 
        /**
@@ -65,18 +144,20 @@
         * @return SiteLinkLookup
         */
        public function getSiteLinkLookup() {
-               return $this->getMock();
+               return $this->getMockRepository();
        }
 
        /**
+        * @see ClientStore::getPropertyInfoStore
+        *
         * @return PropertyInfoStore
         */
        public function getPropertyInfoStore() {
-               static $mockPropertyInfoStore = false;
-               if ( !$mockPropertyInfoStore ) {
-                       $mockPropertyInfoStore = new MockPropertyInfoStore();
+               if ( $this->mockPropertyInfoStore === null ) {
+                       $this->mockPropertyInfoStore = new 
MockPropertyInfoStore();
                }
-               return $mockPropertyInfoStore;
+
+               return $this->mockPropertyInfoStore;
        }
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5313b4f774a6a99c8427a2ea4f783d09f0f39eb3
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