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

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

Change subject: Drop unused code from EntityViewTest
......................................................................

Drop unused code from EntityViewTest

If all tests succeed this can not be wrong, right?

This is split from I04767f2 to make it easier to review.

Change-Id: I4a30f59d62b662e1a32db865acacf401ec619300
---
M repo/tests/phpunit/includes/EntityViewTest.php
1 file changed, 0 insertions(+), 230 deletions(-)


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

diff --git a/repo/tests/phpunit/includes/EntityViewTest.php 
b/repo/tests/phpunit/includes/EntityViewTest.php
index 65917c9..fa4d544 100644
--- a/repo/tests/phpunit/includes/EntityViewTest.php
+++ b/repo/tests/phpunit/includes/EntityViewTest.php
@@ -2,35 +2,14 @@
 
 namespace Wikibase\Test;
 
-use IContextSource;
-use InvalidArgumentException;
-use Language;
-use RequestContext;
-use Title;
 use ValueFormatters\FormatterOptions;
-use Wikibase\DataModel\Claim\Claim;
-use Wikibase\DataModel\Entity\BasicEntityIdParser;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
-use Wikibase\DataModel\Entity\EntityIdValue;
 use Wikibase\DataModel\Entity\Item;
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\Entity\Property;
 use Wikibase\DataModel\Entity\PropertyId;
-use Wikibase\DataModel\Snak\PropertyValueSnak;
-use Wikibase\DataModel\Snak\Snak;
 use Wikibase\DataModel\Statement\Statement;
-use Wikibase\EntityRevision;
-use Wikibase\EntityView;
-use Wikibase\LanguageFallbackChain;
-use Wikibase\Lib\Serializers\SerializationOptions;
-use Wikibase\Lib\SnakFormatter;
-use Wikibase\Lib\Store\EntityInfoBuilderFactory;
-use Wikibase\Lib\Store\EntityTitleLookup;
-use Wikibase\ParserOutputJsConfigBuilder;
-use Wikibase\ReferencedEntitiesFinder;
-use Wikibase\Repo\WikibaseRepo;
-use Wikibase\Utils;
 
 /**
  * @covers Wikibase\EntityView
@@ -47,161 +26,6 @@
  * @author Daniel Kinzler
  */
 abstract class EntityViewTest extends \MediaWikiLangTestCase {
-
-       /**
-        * @var MockRepository
-        */
-       private $mockRepository;
-
-       protected function newEntityIdParser() {
-               // The data provides use P123 and Q123 IDs, so the parser needs 
to understand these.
-               return new BasicEntityIdParser();
-       }
-
-       public function getTitleForId( EntityId $id ) {
-               $name = $id->getEntityType() . ':' . $id->getSerialization();
-               return Title::makeTitle( NS_MAIN, $name );
-       }
-
-       /**
-        * @return EntityTitleLookup
-        */
-       protected function getEntityTitleLookupMock() {
-               $lookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
-               $lookup->expects( $this->any() )
-                       ->method( 'getTitleForId' )
-                       ->will( $this->returnCallback( array( $this, 
'getTitleForId' ) ) );
-
-               return $lookup;
-       }
-
-       /**
-        * @return SnakFormatter
-        */
-       protected function newSnakFormatterMock() {
-               $snakFormatter = $this->getMock( 'Wikibase\Lib\SnakFormatter' );
-
-               $snakFormatter->expects( $this->any() )->method( 'formatSnak' )
-                       ->will( $this->returnValue( '(value)' ) );
-
-               $snakFormatter->expects( $this->any() )->method( 'getFormat' )
-                       ->will( $this->returnValue( 
SnakFormatter::FORMAT_HTML_WIDGET ) );
-
-               $snakFormatter->expects( $this->any() )->method( 
'canFormatSnak' )
-                       ->will( $this->returnValue( true ) );
-
-               return $snakFormatter;
-       }
-
-       /**
-        * @param string $entityType
-        * @param EntityInfoBuilderFactory $entityInfoBuilderFactory
-        * @param EntityTitleLookup $entityTitleLookup
-        * @param IContextSource $context
-        * @param LanguageFallbackChain $languageFallbackChain
-        *
-        * @throws InvalidArgumentException
-        * @return EntityView
-        */
-       protected function newEntityView(
-               $entityType,
-               EntityInfoBuilderFactory $entityInfoBuilderFactory = null,
-               EntityTitleLookup $entityTitleLookup = null,
-               IContextSource $context = null,
-               LanguageFallbackChain $languageFallbackChain = null
-       ) {
-               if ( !is_string( $entityType ) ) {
-                       throw new InvalidArgumentException( '$entityType must 
be a string!' );
-               }
-
-               $langCode = 'en';
-
-               if ( $context === null ) {
-                       $context = new RequestContext();
-                       $context->setLanguage( $langCode );
-               }
-
-               if ( $languageFallbackChain === null ) {
-                       $factory = 
WikibaseRepo::getDefaultInstance()->getLanguageFallbackChainFactory();
-                       $languageFallbackChain = $factory->newFromLanguage( 
Language::factory( $langCode ) );
-               }
-
-               $mockRepository = $this->getMockRepository();
-
-               if ( !$entityInfoBuilderFactory ) {
-                       $entityInfoBuilderFactory = $mockRepository;
-               }
-
-               if ( !$entityTitleLookup ) {
-                       $entityTitleLookup = $this->getEntityTitleLookupMock();
-               }
-
-               $idParser = $this->newEntityIdParser();
-
-               $formatterOptions = new FormatterOptions();
-               $snakFormatter = 
WikibaseRepo::getDefaultInstance()->getSnakFormatterFactory()
-                       ->getSnakFormatter( SnakFormatter::FORMAT_HTML_WIDGET, 
$formatterOptions );
-
-               $configBuilder = new ParserOutputJsConfigBuilder(
-                       $entityInfoBuilderFactory,
-                       $idParser,
-                       $entityTitleLookup,
-                       new ReferencedEntitiesFinder(),
-                       $langCode
-               );
-
-               // @fixme inject language codes
-               $options = $this->getSerializationOptions(
-                       $langCode,
-                       Utils::getLanguageCodes(),
-                       $languageFallbackChain
-               );
-
-               $class = $this->getEntityViewClass();
-               $entityView = new $class(
-                       $context,
-                       $snakFormatter,
-                       $mockRepository,
-                       $entityInfoBuilderFactory,
-                       $entityTitleLookup,
-                       $options,
-                       $configBuilder
-               );
-
-               return $entityView;
-       }
-
-       private function getSerializationOptions( $langCode, $langCodes,
-                                                                               
          LanguageFallbackChain $fallbackChain
-       ) {
-               $langCodes = $langCodes + array( $langCode => $fallbackChain );
-
-               $options = new SerializationOptions();
-               $options->setLanguages( $langCodes );
-
-               return $options;
-       }
-
-       private function getMockRepository() {
-               if ( $this->mockRepository === null ) {
-                       $mockRepository = new MockRepository();
-
-                       $mockRepository->putEntity( $this->makeItem( 'Q33' ) );
-                       $mockRepository->putEntity( $this->makeItem( 'Q22' ) );
-                       $mockRepository->putEntity( $this->makeItem( 'Q23' ) );
-                       $mockRepository->putEntity( $this->makeItem( 'Q24' ) );
-
-                       $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' ) );
-
-                       $this->mockRepository = $mockRepository;
-               }
-
-               return $this->mockRepository;
-       }
 
        /**
         * @return string
@@ -224,25 +48,6 @@
         * @return EntityId
         */
        protected abstract function makeEntityId( $numericId );
-
-       /**
-        * @param Statement[] $statements
-        *
-        * @return EntityRevision
-        */
-       protected function newEntityRevisionForStatements( array $statements ) {
-               static $revId = 1234;
-               $revId++;
-
-               $entity = $this->makeEntity( $this->makeEntityId( $revId ), 
$statements );
-
-               $timestamp = wfTimestamp( TS_MW );
-               $revision = new EntityRevision( $entity, $revId, $timestamp );
-
-               return $revision;
-       }
-
-       protected $guidCounter = 0;
 
        protected function makeItem( $id, array $statements = array() ) {
                if ( is_string( $id ) ) {
@@ -277,41 +82,6 @@
                }
 
                return $property;
-       }
-
-       protected function makeStatement( Snak $mainSnak, $guid = null ) {
-               if ( $guid === null ) {
-                       $this->guidCounter++;
-                       $guid = 'EntityViewTest$' . $this->guidCounter;
-               }
-
-               $statements = new Statement( new Claim( $mainSnak ) );
-               $statements->setGuid( $guid );
-
-               return $statements;
-       }
-
-       /**
-        * @return Entity
-        */
-       protected function getTestEntity() {
-               $entity = $this->makeEntity( $this->makeEntityId( 22 ) );
-               $entity->setLabel( 'de', 'fuh' );
-               $entity->setLabel( 'en', 'foo' );
-
-               $entity->setDescription( 'de', 'fuh barr' );
-               $entity->setDescription( 'en', 'foo bar' );
-
-               $q33 = new ItemId( 'Q33' );
-               $q44 = new ItemId( 'Q44' ); // unknown item
-               $p11 = new PropertyId( 'p11' );
-               $p77 = new PropertyId( 'p77' ); // unknown property
-
-               $entity->addClaim( $this->makeStatement( new PropertyValueSnak( 
$p11, new EntityIdValue( $q33 ) ) ) );
-               $entity->addClaim( $this->makeStatement( new PropertyValueSnak( 
$p11, new EntityIdValue( $q44 ) ) ) );
-               $entity->addClaim( $this->makeStatement( new PropertyValueSnak( 
$p77, new EntityIdValue( $q33 ) ) ) );
-
-               return $entity;
        }
 
 }

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

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