Bene has uploaded a new change for review.

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

Change subject: Don't rely on global state in unit tests
......................................................................

Don't rely on global state in unit tests

This refactors some tests to not rely on global state and configuration
but inject the configuration directly. We may also want to have
integration tests that check if the code works with the current
configuration.

Change-Id: Id807d6a9f2a9c8a37935d95fde4800b47ead22a0
---
M repo/tests/phpunit/includes/Content/EntityContentFactoryTest.php
M repo/tests/phpunit/includes/Hooks/LinkBeginHookHandlerTest.php
M repo/tests/phpunit/includes/Store/Sql/WikiPageEntityStoreTest.php
3 files changed, 17 insertions(+), 6 deletions(-)


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

diff --git a/repo/tests/phpunit/includes/Content/EntityContentFactoryTest.php 
b/repo/tests/phpunit/includes/Content/EntityContentFactoryTest.php
index 3829957..9851e12 100644
--- a/repo/tests/phpunit/includes/Content/EntityContentFactoryTest.php
+++ b/repo/tests/phpunit/includes/Content/EntityContentFactoryTest.php
@@ -88,7 +88,10 @@
                $wikibaseRepo = WikibaseRepo::getDefaultInstance();
 
                return new EntityContentFactory(
-                       $wikibaseRepo->getContentModelMappings(),
+                       array(
+                               'item' => CONTENT_MODEL_WIKIBASE_ITEM,
+                               'property' => CONTENT_MODEL_WIKIBASE_PROPERTY
+                       ),
                        array(
                                'item' => function() use ( $wikibaseRepo ) {
                                        return $wikibaseRepo->newItemHandler();
diff --git a/repo/tests/phpunit/includes/Hooks/LinkBeginHookHandlerTest.php 
b/repo/tests/phpunit/includes/Hooks/LinkBeginHookHandlerTest.php
index 32f9ecb..5504f42 100644
--- a/repo/tests/phpunit/includes/Hooks/LinkBeginHookHandlerTest.php
+++ b/repo/tests/phpunit/includes/Hooks/LinkBeginHookHandlerTest.php
@@ -131,11 +131,16 @@
        }
 
        public function overrideSpecialNewEntityLinkProvider() {
-               $entityTypes = array_keys( 
WikibaseRepo::getDefaultInstance()->getContentModelMappings() );
-
+               $entityContentFactory = 
WikibaseRepo::getDefaultInstance()->getEntityContentFactory();
                $linkTitles = array();
-               foreach ( $entityTypes as $entityType ) {
-                       $linkTitles[] = array( 'New' . ucfirst( $entityType ) );
+
+               foreach ( $entityContentFactory->getEntityTypes() as 
$entityType ) {
+                       $entityHandler = 
$entityContentFactory->getContentHandlerForType( $entityType );
+                       $specialPage = 
$entityHandler->getSpecialPageForCreation();
+
+                       if ( $specialPage !== null ) {
+                               $linkTitles[] = array( $specialPage );
+                       }
                }
 
                return $linkTitles;
diff --git a/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityStoreTest.php 
b/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityStoreTest.php
index 32f242e..37288a5 100644
--- a/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityStoreTest.php
+++ b/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityStoreTest.php
@@ -63,7 +63,10 @@
 
                $store = new WikiPageEntityStore(
                        new EntityContentFactory(
-                               $wikibaseRepo->getContentModelMappings(),
+                               array(
+                                       'item' => CONTENT_MODEL_WIKIBASE_ITEM,
+                                       'property' => 
CONTENT_MODEL_WIKIBASE_PROPERTY
+                               ),
                                array(
                                        'item' => function() use ( 
$wikibaseRepo ) {
                                                return 
$wikibaseRepo->newItemHandler();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id807d6a9f2a9c8a37935d95fde4800b47ead22a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>

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

Reply via email to