Hoo man has uploaded a new change for review.

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


Change subject: Make Wikibase Client tests pass if no ClientStore can be 
constructed
......................................................................

Make Wikibase Client tests pass if no ClientStore can be constructed

Change-Id: I45f1b7d4ecf147b96aeaa32dabd25a7e2ae6088a
---
M client/includes/parserhooks/PropertyParserFunction.php
M client/tests/phpunit/includes/WikibaseClientTest.php
M client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
3 files changed, 29 insertions(+), 0 deletions(-)


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

diff --git a/client/includes/parserhooks/PropertyParserFunction.php 
b/client/includes/parserhooks/PropertyParserFunction.php
index 4e9214b..c3dfef8 100644
--- a/client/includes/parserhooks/PropertyParserFunction.php
+++ b/client/includes/parserhooks/PropertyParserFunction.php
@@ -100,6 +100,7 @@
        public function getRenderer( Language $language ) {
                wfProfileIn( __METHOD__ );
 
+               // @TODO: Inject depedencies
                $wikibaseClient = WikibaseClient::getDefaultInstance();
                $errorFormatter = new ParserErrorMessageFormatter( $language );
 
diff --git a/client/tests/phpunit/includes/WikibaseClientTest.php 
b/client/tests/phpunit/includes/WikibaseClientTest.php
index f22f54f..3f70aef 100644
--- a/client/tests/phpunit/includes/WikibaseClientTest.php
+++ b/client/tests/phpunit/includes/WikibaseClientTest.php
@@ -27,6 +27,19 @@
  */
 class WikibaseClientTest extends \PHPUnit_Framework_TestCase {
 
+       public function setUp() {
+               // If WikibaseClient can't find a ClientStore it will throw an 
exception
+               // in WikibaseClient::getStore
+               if (
+                       !Settings::get( 'defaultClientStore' ) &&
+                       Settings::get( 'repoDatabase' ) === null
+               ) {
+                       $this->markTestSkipped(
+                               'WikibaseClientTest needs WikibaseClient to be 
able to construct a ClientStore'
+                       );
+               }
+       }
+
        public function testGetDataTypeFactoryReturnType() {
                $returnValue = 
$this->getDefaultInstance()->getDataTypeFactory();
                $this->assertInstanceOf( 'DataTypes\DataTypeFactory', 
$returnValue );
diff --git 
a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php 
b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
index 495e5b8..d0b00ee 100644
--- a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
+++ b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
@@ -4,6 +4,7 @@
 
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\PropertyParserFunction;
+use Wikibase\Settings;
 
 /**
  * @covers Wikibase\PropertyParserFunction
@@ -19,6 +20,20 @@
  */
 class PropertyParserFunctionTest extends \PHPUnit_Framework_TestCase {
 
+       public function setUp() {
+               // If WikibaseClient can't find a ClientStore it will throw an 
exception
+               // in WikibaseClient::getStore.
+               // Needed as PropertyParserFunction::getRenderer uses global 
state.
+               if (
+                       !Settings::get( 'defaultClientStore' ) &&
+                       Settings::get( 'repoDatabase' ) === null
+               ) {
+                       $this->markTestSkipped(
+                               'PropertyParserFunctionTest needs 
WikibaseClient to be able to construct a ClientStore'
+                       );
+               }
+       }
+
        public function getPropertyParserFunction( $parser, $entityId ) {
                $entityLookup = new MockRepository();
                $propertyLabelResolver = new MockPropertyLabelResolver( 
$parser->getTargetLanguage(), $entityLookup );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45f1b7d4ecf147b96aeaa32dabd25a7e2ae6088a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <h...@online.de>

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

Reply via email to