Jeroen De Dauw has submitted this change and it was merged.

Change subject: Generalized access to Claims by property ID.
......................................................................


Generalized access to Claims by property ID.

This provides functions to access claims by property directly from
the Entity object, and it generalizes the PropertyLookup interface
to return Claims.

Change-Id: I76e82720f3e8e9a076d4d43750f87b31337a43be
---
M DataModel/DataModel/Claim/Claim.php
M DataModel/DataModel/Claim/Claims.php
M DataModel/tests/phpunit/Claim/ClaimsTest.php
M client/includes/parserhooks/PropertyParserFunction.php
M client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
M lib/includes/store/PropertyLookup.php
M lib/includes/store/sql/PropertySQLLookup.php
M lib/tests/phpunit/MockRepository.php
M lib/tests/phpunit/store/sql/PropertySQLLookupTest.php
9 files changed, 278 insertions(+), 131 deletions(-)

Approvals:
  Jeroen De Dauw: Verified; Looks good to me, approved



diff --git a/DataModel/DataModel/Claim/Claim.php 
b/DataModel/DataModel/Claim/Claim.php
index 5b3bddb..d5fe5ed 100644
--- a/DataModel/DataModel/Claim/Claim.php
+++ b/DataModel/DataModel/Claim/Claim.php
@@ -133,7 +133,7 @@
         *
         * @since 0.2
         *
-        * @return integer
+        * @return EntityId
         */
        public function getPropertyId() {
                return $this->getMainSnak()->getPropertyId();
diff --git a/DataModel/DataModel/Claim/Claims.php 
b/DataModel/DataModel/Claim/Claims.php
index 01834bb..8dbe718 100644
--- a/DataModel/DataModel/Claim/Claims.php
+++ b/DataModel/DataModel/Claim/Claims.php
@@ -36,6 +36,7 @@
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
+ * @author Daniel Kinzler
  */
 class Claims extends HashArray implements ClaimListAccess {
 
@@ -161,6 +162,46 @@
        }
 
        /**
+        * Returns the claims for the given property.
+        *
+        * @since 0.4
+        *
+        * @param int $propertyId
+        *
+        * @throws \MWException if $propertyId isn't valid
+        * @return Claims
+        */
+       public function getClaimsForProperty( $propertyId ) {
+               if ( !is_int( $propertyId ) ) {
+                       throw new MWException( "ID must be an int." );
+               }
+
+               $claimsByProp = new ByPropertyIdArray( $this );
+               $claimsByProp->buildIndex();
+
+               $claimsForProperty = new Claims( 
$claimsByProp->getByPropertyId( $propertyId ) );
+               return $claimsForProperty;
+       }
+
+       /**
+        * Returns the main Snaks of the claims in this list.
+        *
+        * @since 0.4
+        *
+        * @return Snak[]
+        */
+       public function getMainSnaks() {
+               $snaks = array();
+
+               /* @var Claim $claim */
+               foreach ( $this as $claim ) {
+                       $snaks[] = $claim->getMainSnak();
+               }
+
+               return $snaks;
+       }
+
+       /**
         * @see GenericArrayObject::preSetElement
         *
         * @since 0.3
diff --git a/DataModel/tests/phpunit/Claim/ClaimsTest.php 
b/DataModel/tests/phpunit/Claim/ClaimsTest.php
index a6ebf73..1c285c0 100644
--- a/DataModel/tests/phpunit/Claim/ClaimsTest.php
+++ b/DataModel/tests/phpunit/Claim/ClaimsTest.php
@@ -58,8 +58,17 @@
                $instances = array();
 
                $instances[] = new \Wikibase\Claim(
-                       new \Wikibase\PropertyNoValueSnak( new 
\Wikibase\EntityId( \Wikibase\Property::ENTITY_TYPE, 42 ) )
-               );
+                       new \Wikibase\PropertyNoValueSnak(
+                               new \Wikibase\EntityId( 
\Wikibase\Property::ENTITY_TYPE, 23 ) ) );
+
+               $instances[] = new \Wikibase\Claim(
+                       new \Wikibase\PropertySomeValueSnak(
+                               new \Wikibase\EntityId( 
\Wikibase\Property::ENTITY_TYPE, 42 ) ) );
+
+               $instances[] = new \Wikibase\Claim(
+                       new \Wikibase\PropertyValueSnak(
+                               new \Wikibase\EntityId( 
\Wikibase\Property::ENTITY_TYPE, 42 ),
+                               new \DataValues\StringValue( "foo" ) ) );
 
                return $instances;
        }
@@ -137,6 +146,29 @@
                $this->assertEquals( $elementCount, count( $array ) );
        }
 
+       /**
+        * @dataProvider instanceProvider
+        *
+        * @param \Wikibase\Claims $array
+        */
+       public function testGetMainSnaks( Claims $array ) {
+               $snaks = $array->getMainSnaks();
+               $this->assertType( 'array', $snaks );
+               $this->assertSameSize( $array, $snaks );
+       }
+
+       public function testGetClaimsForProperty() {
+               $array = new Claims( $this->getElementInstances() );
+
+               $claims = $array->getClaimsForProperty( 42 );
+               $this->assertInstanceOf( 'Wikibase\Claims', $claims );
+               $this->assertCount( 2, $claims );
+
+               $claims = $array->getClaimsForProperty( 23 );
+               $this->assertInstanceOf( 'Wikibase\Claims', $claims );
+               $this->assertCount( 1, $claims );
+       }
+
        public function testDuplicateClaims() {
                $firstClaim = new Claim( new \Wikibase\PropertyNoValueSnak( 42 
) );
                $secondClaim = new Claim( new \Wikibase\PropertyNoValueSnak( 42 
) );
diff --git a/client/includes/parserhooks/PropertyParserFunction.php 
b/client/includes/parserhooks/PropertyParserFunction.php
index b842a20..977ee04 100644
--- a/client/includes/parserhooks/PropertyParserFunction.php
+++ b/client/includes/parserhooks/PropertyParserFunction.php
@@ -44,6 +44,9 @@
        /* @var \Language */
        protected $language;
 
+       /* @var EntityLookup */
+       protected $entityLookup;
+
        /* @var PropertyLookup */
        protected $propertyLookup;
 
@@ -54,54 +57,45 @@
        protected $snaksFormatter;
 
        /**
-        * @since 0.4
+        * @since    0.4
         *
-        * @param \Language $language
-        * @param PropertyLookup $propertyLookup
+        * @param \Language                   $language
+        * @param EntityLookup                $entityLookup
+        * @param PropertyLookup              $propertyLookup
         * @param ParserErrorMessageFormatter $errorFormatter
-        * @param SnakFormatter $dataTypeFactory
+        * @param Lib\SnakFormatter           $snaksFormatter
         */
-       public function __construct( \Language $language, PropertyLookup 
$propertyLookup,
+       public function __construct( \Language $language,
+               EntityLookup $entityLookup, PropertyLookup $propertyLookup,
                ParserErrorMessageFormatter $errorFormatter, SnakFormatter 
$snaksFormatter ) {
                $this->language = $language;
+               $this->entityLookup = $entityLookup;
                $this->propertyLookup = $propertyLookup;
                $this->errorFormatter = $errorFormatter;
                $this->snaksFormatter = $snaksFormatter;
        }
 
        /**
-        * @since 0.4
+        * Returns such Claims from $entity that have a main Snak for the 
property that
+        * is specified by $propertyLabel.
         *
-        * @param EntityId $entityId
-        * @param string $propertyLabel
+        * @param Entity $entity The Entity from which to get the clams
+        * @param string $propertyLabel A property label (in the wiki's content 
language) or a prefixed property ID.
         *
-        * @return string - wikitext format
+        * @return Claims The claims for the given property.
         */
-    public function renderForEntityId( EntityId $entityId, $propertyLabel ) {
-               $snakList = $this->getSnaksForProperty( $entityId, 
$propertyLabel );
-
-               if ( $snakList->isEmpty() ) {
-                       return '';
-               }
-
-               $snaks = array();
-
-               foreach( $snakList as $snak ) {
-                       $snaks[] = $snak;
-               }
-
-               return $this->formatSnakList( $snaks );
-       }
-
-       private function getSnaksForProperty( EntityId $entityId, 
$propertyLabel ) {
+       private function getClaimsForProperty( Entity $entity, $propertyLabel ) 
{
                $propertyIdToFind = EntityId::newFromPrefixedId( $propertyLabel 
);
 
-               if ( $propertyIdToFind === null ) {
+               if ( $propertyIdToFind !== null ) {
+                       $allClaims = new Claims( $entity->getClaims() );
+                       $claims = $allClaims->getClaimsForProperty( 
$propertyIdToFind->getNumericId() );
+               } else {
                        $langCode = $this->language->getCode();
-                       return 
$this->propertyLookup->getMainSnaksByPropertyLabel( $entityId, $propertyLabel, 
$langCode );
+                       $claims = 
$this->propertyLookup->getClaimsByPropertyLabel( $entity, $propertyLabel, 
$langCode );
                }
 
-               return $this->propertyLookup->getMainSnaksByPropertyId( 
$entityId, $propertyIdToFind );
+               return $claims;
        }
 
        /**
@@ -114,6 +108,38 @@
        private function formatSnakList( $snaks ) {
                $formattedValues = $this->snaksFormatter->formatSnaks( $snaks );
                return $this->language->commaList( $formattedValues );
+       }
+
+       /**
+        * @since 0.4
+        *
+        * @param EntityId $entityId
+        * @param string   $propertyLabel
+        *
+        * @return string - wikitext format
+        */
+       public function renderForEntityId( EntityId $entityId, $propertyLabel ) 
{
+               wfProfileIn( __METHOD__ );
+
+               $entity = $this->entityLookup->getEntity( $entityId );
+
+               if ( !$entity ) {
+                       wfProfileOut( __METHOD__ );
+                       return '';
+               }
+
+               $claims = $this->getClaimsForProperty( $entity, $propertyLabel 
);
+
+               if ( $claims->isEmpty() ) {
+                       wfProfileOut( __METHOD__ );
+                       return '';
+               }
+
+               $snakList = $claims->getMainSnaks();
+               $text = $this->formatSnakList( $snakList, $propertyLabel );
+
+               wfProfileOut( __METHOD__ );
+               return $text;
        }
 
        /**
@@ -143,10 +169,13 @@
 
                $wikibaseClient = WikibaseClient::newInstance();
 
+               $entityLookup = $wikibaseClient->getStore()->getEntityLookup();
                $propertyLookup = 
$wikibaseClient->getStore()->getPropertyLookup();
                $formatter = $wikibaseClient->newSnakFormatter();
 
-               $instance = new self( $targetLanguage, $propertyLookup, 
$errorFormatter, $formatter );
+               $instance = new self( $targetLanguage,
+                       $entityLookup, $propertyLookup,
+                       $errorFormatter, $formatter );
 
                $result = array(
                        $instance->renderForEntityId( $entityId, $propertyLabel 
),
diff --git 
a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php 
b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
index 2959af6..92ea1a6 100644
--- a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
+++ b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionTest.php
@@ -52,26 +52,27 @@
        private function newInstance() {
                $wikibaseClient = WikibaseClient::newInstance();
 
-               $targetLanguage = new \Language();
+               $targetLanguage = \Language::factory( 'en' );
                $errorFormatter = new ParserErrorMessageFormatter( 
$targetLanguage );
                $dataTypeFactory = $wikibaseClient->getDataTypeFactory();
-               $entityLookup = $this->newEntityLookup();
+               $mockRepo = $this->newMockRepository();
 
                $formatter = new SnakFormatter(
-                       new EntityRetrievingDataTypeLookup( $entityLookup ),
+                       new EntityRetrievingDataTypeLookup( $mockRepo ),
                        new TypedValueFormatter(),
                        $dataTypeFactory
                );
 
                return new PropertyParserFunction(
                        $targetLanguage,
-                       new PropertySQLLookup( $entityLookup ),
+                       $mockRepo,
+                       $mockRepo,
                        $errorFormatter,
                        $formatter
                );
        }
 
-       private function newEntityLookup() {
+       private function newMockRepository() {
                $propertyId = new EntityId( Property::ENTITY_TYPE, 1337 );
 
                $entityLookup = new MockRepository();
@@ -80,12 +81,18 @@
                $item->setId( 42 );
                $item->addClaim( new Claim( new PropertyValueSnak(
                        $propertyId,
-                       new StringValue( 'Please write tests before merging 
your code, or kittens will die' )
+                       new StringValue( 'Please write tests before merging 
your code' )
+               ) ) );
+               $item->addClaim( new Claim( new PropertyValueSnak(
+                       $propertyId,
+                       new StringValue( 'or kittens will die' )
                ) ) );
 
                $property = Property::newEmpty();
                $property->setId( $propertyId );
+
                $property->setDataTypeId( 'string' );
+               $property->setLabel( 'en', 'kitten' );
 
                $entityLookup->putEntity( $item );
                $entityLookup->putEntity( $property );
@@ -93,20 +100,38 @@
                return $entityLookup;
        }
 
-       public function testRenderForEntityId() {
+       public static function provideRenderForEntityId() {
+               return array(
+                       array(
+                               'p1337',
+                               'Please write tests before merging your code, 
or kittens will die',
+                               'Congratulations, you just killed a kitten'
+                       ),
+                       array(
+                               'kitten',
+                               'Please write tests before merging your code, 
or kittens will die',
+                               'Congratulations, you just killed a kitten'
+                       ),
+               );
+       }
+
+       /**
+        * @dataProvider provideRenderForEntityId
+        */
+       public function testRenderForEntityId( $name, $expected, $info ) {
                $parserFunction = $this->newInstance();
 
                $result = $parserFunction->renderForEntityId(
                        new EntityId( Item::ENTITY_TYPE, 42 ),
-                       'p1337'
+                       $name
                );
 
                $this->assertInternalType( 'string', $result );
 
                $this->assertEquals(
-                       'Please write tests before merging your code, or 
kittens will die',
+                       $expected,
                        $result,
-                       'Congratulations, you just killed a kitten'
+                       $info
                );
        }
 
diff --git a/lib/includes/store/PropertyLookup.php 
b/lib/includes/store/PropertyLookup.php
index 8469d71..07363a8 100644
--- a/lib/includes/store/PropertyLookup.php
+++ b/lib/includes/store/PropertyLookup.php
@@ -29,28 +29,22 @@
  *
  * @licence GNU GPL v2+
  * @author Katie Filbert < [email protected] >
+ * @author Daniel Kinzler
  */
 interface PropertyLookup {
 
        /**
-        * @since 0.4
+        * Returns these claims from the given entity that have a main Snak for 
the property
+        * identified by $propertyLabel in the language given by $langCode.
         *
-        * @param EntityId $entityId
-        * @param string $propertyLabel
+        * @since    0.4
         *
-        * @return SnakList
-        */
-       public function getMainSnaksByPropertyId( EntityId $entityId, EntityId 
$propertyId );
-
-       /**
-        * @since 0.4
-        *
-        * @param EntityId $entityId
+        * @param Entity $entity
         * @param string $propertyLabel
         * @param string $langCode
         *
-        * @return SnakList
+        * @return Claims
         */
-       public function getMainSnaksByPropertyLabel( EntityID $entityId, 
$propertyLabel, $langCode );
+       public function getClaimsByPropertyLabel( Entity $entity, 
$propertyLabel, $langCode );
 
 }
diff --git a/lib/includes/store/sql/PropertySQLLookup.php 
b/lib/includes/store/sql/PropertySQLLookup.php
index 3b1480f..63128f3 100644
--- a/lib/includes/store/sql/PropertySQLLookup.php
+++ b/lib/includes/store/sql/PropertySQLLookup.php
@@ -90,36 +90,6 @@
        /**
         * @since 0.4
         *
-        * @param EntityId $entityId
-        * @param string $propertyLabel
-        *
-        * @return SnakList
-        */
-       public function getMainSnaksByPropertyId( EntityId $entityId, EntityId 
$propertyId ) {
-               $entity = $this->entityLookup->getEntity( $entityId );
-               if ( !$entity ) {
-                       // Unknown entity, just return an empty SnakList
-                       return new SnakList();
-               }
-               $statements = $entity->getClaims();
-
-               $snakList = new SnakList();
-
-               foreach( $statements as $statement ) {
-                       $snak = $statement->getMainSnak();
-                       $snakPropertyId = $snak->getPropertyId();
-
-                       if ( $snakPropertyId->getPrefixedId()  === 
$propertyId->getPrefixedId() ) {
-                               $snakList->addSnak( $snak );
-                       }
-               }
-
-               return $snakList;
-       }
-
-       /**
-        * @since 0.4
-        *
         * @param EntityId $propertyId
         *
         * @return string|false
@@ -159,26 +129,6 @@
        /**
         * @since 0.4
         *
-        * @param EntityId $propertyId
-        *
-        * @return SnakList
-        */
-       protected function getSnakListForProperty( EntityId $propertyId ) {
-               wfProfileIn( __METHOD__ );
-               $statements = $this->getStatementsByProperty( $propertyId );
-               $snakList = new SnakList();
-
-               foreach( $statements as $statement ) {
-                       $snakList->addSnak( $statement->getMainSnak() );
-               }
-
-               wfProfileOut( __METHOD__ );
-               return $snakList;
-       }
-
-       /**
-        * @since 0.4
-        *
         * @param string $propertyLabel
         * @param string $langCode
         *
@@ -205,16 +155,16 @@
        /**
         * @since 0.4
         *
-        * @param EntityId $entityId
+        * @param Entity $entity
         * @param string $propertyLabel
         * @param string $langCode
         *
-        * @return SnakList
+        * @return Claims
         */
-       public function getMainSnaksByPropertyLabel( EntityId $entityId, 
$propertyLabel, $langCode ) {
+       public function getClaimsByPropertyLabel( Entity $entity, 
$propertyLabel, $langCode ) {
                wfProfileIn( __METHOD__ );
 
-               $snakList = new SnakList();
+               $claims = null;
 
                if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && 
WB_EXPERIMENTAL_FEATURES ) {
                        $propertyId = $this->getPropertyIdByLabel( 
$propertyLabel, $langCode );
@@ -224,15 +174,22 @@
                                //      in the item, we'll always try to 
re-index the item's properties.
                                //      We just hope that this is rare, because 
people notice when a label
                                //      doesn't work.
-                               $this->indexPropertiesByLabel( $entityId, 
$langCode );
+                               $this->indexPropertiesByLabel( 
$entity->getId(), $langCode );
                                $propertyId = $this->getPropertyIdByLabel( 
$propertyLabel, $langCode );
                        }
 
-                       $snakList = $propertyId !== null ? 
$this->getSnakListForProperty( $propertyId ) : $snakList;
+                       if ( $propertyId !== null ) {
+                               $allClaims = new Claims( $entity->getClaims() );
+                               $claims = $allClaims->getClaimsForProperty( 
$propertyId->getNumericId() );
+                       }
+               }
+
+               if ( $claims === null ) {
+                       $claims = new Claims();
                }
 
                wfProfileOut( __METHOD__ );
-               return $snakList;
+               return $claims;
        }
 
 }
diff --git a/lib/tests/phpunit/MockRepository.php 
b/lib/tests/phpunit/MockRepository.php
index abfb62b..9da3c2e 100644
--- a/lib/tests/phpunit/MockRepository.php
+++ b/lib/tests/phpunit/MockRepository.php
@@ -1,10 +1,15 @@
 <?php
 
 namespace Wikibase\Test;
-use \Wikibase\Entity;
-use \Wikibase\EntityId;
-use \Wikibase\Item;
-use \Wikibase\SiteLink;
+use Wikibase\Claims;
+use Wikibase\Entity;
+use Wikibase\EntityId;
+use Wikibase\EntityLookup;
+use Wikibase\Item;
+use Wikibase\PropertyLookup;
+use Wikibase\SiteLink;
+use Wikibase\SiteLinkLookup;
+use Wikibase\Property;
 
 /**
  * Mock repository for use in tests.
@@ -33,7 +38,7 @@
  * @licence GNU GPL v2+
  * @author Daniel Kinzler
  */
-class MockRepository implements \Wikibase\SiteLinkLookup, 
\Wikibase\EntityLookup {
+class MockRepository implements SiteLinkLookup, EntityLookup, PropertyLookup {
 
        protected $entities = array();
        protected $itemByLink = array();
@@ -421,5 +426,69 @@
                }
 
                return $entity->getSiteLinks();
+
+       }
+
+       /**
+        * Returns these claims from the given entity that have a main Snak for 
the property
+        * identified by $propertyLabel in the language given by $langCode.
+        *
+        * @since    0.4
+        *
+        * @param Entity $entity
+        * @param string $propertyLabel
+        * @param string $langCode
+        *
+        * @return Claims
+        */
+       public function getClaimsByPropertyLabel( Entity $entity, 
$propertyLabel, $langCode ) {
+               $prop = $this->getPropertyByLabel( $propertyLabel, $langCode );
+
+               if ( !$prop ) {
+                       return new Claims();
+               }
+
+               $allClaims = new Claims( $entity->getClaims() );
+               $theClaims = $allClaims->getClaimsForProperty( 
$prop->getId()->getNumericId() );
+
+               return $theClaims;
+       }
+
+       /**
+        * Returns the Property that has the given label in the given language.
+        *
+        * @since    0.4
+        *
+        * @param string $propertyLabel
+        * @param string $langCode
+        *
+        * @return Property|null
+        */
+       protected function getPropertyByLabel( $propertyLabel, $langCode ) {
+               $ids = array_keys( $this->entities );
+
+               foreach ( $ids as $id ) {
+                       $id = EntityId::newFromPrefixedId( $id );
+                       $entity = $this->getEntity( $id );
+
+                       if ( $entity->getType() !== Property::ENTITY_TYPE ) {
+                               continue;
+                       }
+
+                       $labels = $entity->getLabels( array( $langCode) );
+
+                       if ( empty( $labels ) ) {
+                                       continue;
+                       }
+
+                       $label = reset( $labels );
+                       if ( $label !== $propertyLabel ) {
+                               continue;
+                       }
+
+                       return $entity;
+               }
+
+               return null;
        }
 }
diff --git a/lib/tests/phpunit/store/sql/PropertySQLLookupTest.php 
b/lib/tests/phpunit/store/sql/PropertySQLLookupTest.php
index 1c8596e..ab67677 100644
--- a/lib/tests/phpunit/store/sql/PropertySQLLookupTest.php
+++ b/lib/tests/phpunit/store/sql/PropertySQLLookupTest.php
@@ -6,7 +6,6 @@
 use Wikibase\EntityId;
 use Wikibase\Property;
 use Wikibase\Item;
-use Wikibase\SnakList;
 use Wikibase\Statement;
 use Wikibase\Claims;
 use Wikibase\PropertyValueSnak;
@@ -41,6 +40,7 @@
  *
  * @licence GNU GPL v2+
  * @author Katie Filbert < [email protected] >
+ * @author Daniel Kinzler
  */
 class PropertySQLLookupTest extends \MediaWikiTestCase {
 
@@ -86,7 +86,6 @@
                        )
                );
 
-               $entityFactory = EntityFactory::singleton();
                $properties = array();
 
                foreach( $propertyData as $data ) {
@@ -205,10 +204,11 @@
                        $this->markTestSkipped( "getMainSnaksByPropertyLabel is 
experimental" );
                }
 
-               $snakList = $this->propertyLookup->getMainSnaksByPropertyLabel( 
$entityId, $propertyLabel, $langCode );
+               $entity = $this->entityLookup->getEntity( $entityId );
+               $claims = $this->propertyLookup->getClaimsByPropertyLabel( 
$entity, $propertyLabel, $langCode );
 
-               $this->assertInstanceOf( '\Wikibase\SnakList', $snakList );
-               $this->assertEquals( $expected, $snakList->count() );
+               $this->assertInstanceOf( '\Wikibase\Claims', $claims );
+               $this->assertEquals( $expected, count( $claims ) );
        }
 
        public function testGetMainSnaksByPropertyLabel2( ) {
@@ -216,19 +216,19 @@
                        $this->markTestSkipped( "getMainSnaksByPropertyLabel is 
experimental" );
                }
 
-               $entity126 = new EntityId( Item::ENTITY_TYPE, 126 );
+               $entity126 = $this->entityLookup->getEntity( new EntityId( 
Item::ENTITY_TYPE, 126 ) );
 
-               $snakList = $this->propertyLookup->getMainSnaksByPropertyLabel( 
$entity126, 'capital', 'en' );
-               $this->assertEquals( 2, $snakList->count() );
+               $claims = $this->propertyLookup->getClaimsByPropertyLabel( 
$entity126, 'capital', 'en' );
+               $this->assertEquals( 2, count( $claims ) );
 
-               $snakList = $this->propertyLookup->getMainSnaksByPropertyLabel( 
$entity126, 'country code', 'en' );
-               $this->assertEquals( 0, $snakList->count() );
+               $claims = $this->propertyLookup->getClaimsByPropertyLabel( 
$entity126, 'country code', 'en' );
+               $this->assertEquals( 0, count( $claims ) );
 
                // try to find a property in another entity, if that property 
wasn't used by the previous entity.
-               $entity128 = new EntityId( Item::ENTITY_TYPE, 128 );
+               $entity128 = $this->entityLookup->getEntity( new EntityId( 
Item::ENTITY_TYPE, 128 ) );
 
-               $snakList = $this->propertyLookup->getMainSnaksByPropertyLabel( 
$entity128, 'country code', 'en' );
-               $this->assertEquals( 1, $snakList->count(), "property unknown 
to the first item" );
+               $claims = $this->propertyLookup->getClaimsByPropertyLabel( 
$entity128, 'country code', 'en' );
+               $this->assertEquals( 1, count( $claims ), "property unknown to 
the first item" );
        }
 
        public function getPropertyLabelProvider() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I76e82720f3e8e9a076d4d43750f87b31337a43be
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to