jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/349968 )
Change subject: Streamline PropertyIdResolverTest::testResolvePropertyId a bit
......................................................................
Streamline PropertyIdResolverTest::testResolvePropertyId a bit
This streamlines the code introduced in I82239df a bit.
* The original patch did not compared the array keys. This one does.
* In exchange I do not compare the array values any more, because this
is not critical for this class.
* I changed the parameter order to have the two expected values together.
* I changed the expected ID to a string. This makes the test case
provider easier to read.
Change-Id: I022cafafaec570de6f0a0caf888321dd3380af5d
---
M client/includes/DataAccess/PropertyIdResolver.php
M client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php
2 files changed, 8 insertions(+), 17 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
Hoo man: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/client/includes/DataAccess/PropertyIdResolver.php
b/client/includes/DataAccess/PropertyIdResolver.php
index 5ced2ca..20dbeb8 100644
--- a/client/includes/DataAccess/PropertyIdResolver.php
+++ b/client/includes/DataAccess/PropertyIdResolver.php
@@ -60,7 +60,6 @@
if ( !$this->entityLookup->hasEntity( $propertyId ) ) {
throw new PropertyLabelNotResolvedException(
$propertyLabelOrId, $languageCode );
}
-
} catch ( InvalidArgumentException $ex ) {
$propertyId = $this->findPropertyByLabel(
$propertyLabelOrId, $languageCode );
}
diff --git
a/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php
b/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php
index d4be23e..95645f7 100644
--- a/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php
+++ b/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php
@@ -5,7 +5,6 @@
use PHPUnit_Framework_TestCase;
use Wikibase\Client\DataAccess\PropertyIdResolver;
use Wikibase\Client\PropertyLabelNotResolvedException;
-use Wikibase\Client\Usage\EntityUsage;
use Wikibase\Client\Usage\HashUsageAccumulator;
use Wikibase\Client\Usage\UsageAccumulator;
use Wikibase\DataModel\Entity\Property;
@@ -54,28 +53,21 @@
/**
* @dataProvider resolvePropertyIdProvider
*/
- public function testResolvePropertyId( PropertyId $expected,
$propertyLabelOrId, array $expectedUsages = [] ) {
+ public function testResolvePropertyId( $propertyLabelOrId, $expectedId,
array $expectedUsages ) {
$usageAccumulator = new HashUsageAccumulator();
$propertyIdResolver = $this->getPropertyIdResolver(
$usageAccumulator );
- $propertyId = $propertyIdResolver->resolvePropertyId(
$propertyLabelOrId, 'en' );
- $this->assertEquals( $expected, $propertyId );
- $this->assertEquals( $expectedUsages,
$usageAccumulator->getUsages() );
+ $id = $propertyIdResolver->resolvePropertyId(
$propertyLabelOrId, 'en' );
+
+ $this->assertSame( $expectedId, $id->getSerialization() );
+ $this->assertSame( $expectedUsages, array_keys(
$usageAccumulator->getUsages() ) );
}
public function resolvePropertyIdProvider() {
- $p1337 = new PropertyId( 'P1337' );
-
return [
- [
- $p1337,
- 'a kitten!',
- [
- 'P1337#L.en' => new EntityUsage(
$p1337, EntityUsage::LABEL_USAGE, 'en' )
- ]
- ],
- [ $p1337, 'p1337' ],
- [ $p1337, 'P1337' ],
+ [ 'a kitten!', 'P1337', [ 'P1337#L.en' ] ],
+ [ 'p1337', 'P1337', [] ],
+ [ 'P1337', 'P1337', [] ],
];
}
--
To view, visit https://gerrit.wikimedia.org/r/349968
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I022cafafaec570de6f0a0caf888321dd3380af5d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits