[MediaWiki-commits] [Gerrit] Avoid getDefaultInstance method name in tests - change (mediawiki...Wikibase)
jenkins-bot has submitted this change and it was merged. Change subject: Avoid getDefaultInstance method name in tests .. Avoid getDefaultInstance method name in tests This is split from I04767f2 to make it easier to review. Change-Id: I712432649c38e5e8cc3148e5c12001b1cf33c6ed --- M client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php M client/tests/phpunit/includes/WikibaseClientTest.php M repo/tests/phpunit/includes/WikibaseRepoTest.php 4 files changed, 102 insertions(+), 100 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php b/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php index b8dbc26..1a4ef8d 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php @@ -20,14 +20,14 @@ */ class PropertyIdResolverTest extends \PHPUnit_Framework_TestCase { - private function getDefaultInstance() { - $repo = $this->newMockRepository(); - $propertyLabelResolver = new MockPropertyLabelResolver( 'en', $repo ); + private function getPropertyIdResolver() { + $mockRepository = $this->getMockRepository(); + $propertyLabelResolver = new MockPropertyLabelResolver( 'en', $mockRepository ); return new PropertyIdResolver( $propertyLabelResolver ); } - private function newMockRepository() { + private function getMockRepository() { $propertyId = new PropertyId( 'P1337' ); $property = Property::newFromType( 'string' ); @@ -43,8 +43,8 @@ /** * @dataProvider resolvePropertyIdProvider */ - public function testResolvePropertyId( $expected, $propertyLabelOrId ) { - $propertyIdResolver = $this->getDefaultInstance(); + public function testResolvePropertyId( PropertyId $expected, $propertyLabelOrId ) { + $propertyIdResolver = $this->getPropertyIdResolver(); $propertyId = $propertyIdResolver->resolvePropertyId( $propertyLabelOrId, 'en' ); $this->assertEquals( $expected, $propertyId ); @@ -63,7 +63,7 @@ * @dataProvider resolvePropertyIdWithInvalidInput_throwsExceptionProvider */ public function testResolvePropertyIdWithInvalidInput_throwsException( $propertyIdOrLabel ) { - $propertyIdResolver = $this->getDefaultInstance(); + $propertyIdResolver = $this->getPropertyIdResolver(); $this->setExpectedException( 'Wikibase\Lib\PropertyLabelNotResolvedException' ); diff --git a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php index 65ddf59..108a822 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php @@ -11,6 +11,7 @@ use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Statement\Statement; +use Wikibase\Lib\Store\EntityLookup; use Wikibase\Test\MockRepository; /** @@ -26,16 +27,19 @@ */ class SnaksFinderTest extends \PHPUnit_Framework_TestCase { - private function getDefaultInstance() { - $repo = $this->newMockRepository(); + private function getSnaksFinder() { + $entityLookup = $this->getEntityLookup(); - return new SnaksFinder( $repo ); + return new SnaksFinder( $entityLookup ); } - private function newMockRepository() { + /** +* @return EntityLookup +*/ + private function getEntityLookup() { $propertyId = new PropertyId( 'P1337' ); - $entityLookup = new MockRepository(); + $mockRepository = new MockRepository(); $statement1 = new Statement( new Claim( new PropertyValueSnak( $propertyId, @@ -67,19 +71,19 @@ $property->setId( $propertyId ); $property->getFingerprint()->setLabel( 'en', 'a kitten!' ); - $entityLookup->putEntity( $item ); - $entityLookup->putEntity( $property ); + $mockRepository->putEntity( $item ); + $mockRepository->putEntity( $property ); - return $entityLookup; + return $mockRepository; } /** * @dataProvider findSnaksProvider */ - public function testFindSnaks( $expected, ItemId $itemId, $propertyLabelOrId ) { -
[MediaWiki-commits] [Gerrit] Avoid getDefaultInstance method name in tests - change (mediawiki...Wikibase)
Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/176915 Change subject: Avoid getDefaultInstance method name in tests .. Avoid getDefaultInstance method name in tests This is split from I04767f2 to make it easier to review. Change-Id: I712432649c38e5e8cc3148e5c12001b1cf33c6ed --- M client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php M client/tests/phpunit/includes/WikibaseClientTest.php M repo/tests/phpunit/includes/WikibaseRepoTest.php 4 files changed, 102 insertions(+), 100 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/15/176915/1 diff --git a/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php b/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php index b8dbc26..1a4ef8d 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyIdResolverTest.php @@ -20,14 +20,14 @@ */ class PropertyIdResolverTest extends \PHPUnit_Framework_TestCase { - private function getDefaultInstance() { - $repo = $this->newMockRepository(); - $propertyLabelResolver = new MockPropertyLabelResolver( 'en', $repo ); + private function getPropertyIdResolver() { + $mockRepository = $this->getMockRepository(); + $propertyLabelResolver = new MockPropertyLabelResolver( 'en', $mockRepository ); return new PropertyIdResolver( $propertyLabelResolver ); } - private function newMockRepository() { + private function getMockRepository() { $propertyId = new PropertyId( 'P1337' ); $property = Property::newFromType( 'string' ); @@ -43,8 +43,8 @@ /** * @dataProvider resolvePropertyIdProvider */ - public function testResolvePropertyId( $expected, $propertyLabelOrId ) { - $propertyIdResolver = $this->getDefaultInstance(); + public function testResolvePropertyId( PropertyId $expected, $propertyLabelOrId ) { + $propertyIdResolver = $this->getPropertyIdResolver(); $propertyId = $propertyIdResolver->resolvePropertyId( $propertyLabelOrId, 'en' ); $this->assertEquals( $expected, $propertyId ); @@ -63,7 +63,7 @@ * @dataProvider resolvePropertyIdWithInvalidInput_throwsExceptionProvider */ public function testResolvePropertyIdWithInvalidInput_throwsException( $propertyIdOrLabel ) { - $propertyIdResolver = $this->getDefaultInstance(); + $propertyIdResolver = $this->getPropertyIdResolver(); $this->setExpectedException( 'Wikibase\Lib\PropertyLabelNotResolvedException' ); diff --git a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php index 65ddf59..108a822 100644 --- a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php +++ b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/SnaksFinderTest.php @@ -11,6 +11,7 @@ use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Statement\Statement; +use Wikibase\Lib\Store\EntityLookup; use Wikibase\Test\MockRepository; /** @@ -26,16 +27,19 @@ */ class SnaksFinderTest extends \PHPUnit_Framework_TestCase { - private function getDefaultInstance() { - $repo = $this->newMockRepository(); + private function getSnaksFinder() { + $entityLookup = $this->getEntityLookup(); - return new SnaksFinder( $repo ); + return new SnaksFinder( $entityLookup ); } - private function newMockRepository() { + /** +* @return EntityLookup +*/ + private function getEntityLookup() { $propertyId = new PropertyId( 'P1337' ); - $entityLookup = new MockRepository(); + $mockRepository = new MockRepository(); $statement1 = new Statement( new Claim( new PropertyValueSnak( $propertyId, @@ -67,19 +71,19 @@ $property->setId( $propertyId ); $property->getFingerprint()->setLabel( 'en', 'a kitten!' ); - $entityLookup->putEntity( $item ); - $entityLookup->putEntity( $property ); + $mockRepository->putEntity( $item ); + $mockRepository->putEntity( $property ); - return $entityLookup; + return $mockRepository; } /** * @dataProvider findSnaksProvider */ - public function testFind