Daniel Kinzler has submitted this change and it was merged. Change subject: Use Property->setDataTypeId rather then ->setDataType so no DataType construction is needed ......................................................................
Use Property->setDataTypeId rather then ->setDataType so no DataType construction is needed This gets rid of LibRegistry usage as well Change-Id: I07e334767054310f1a725e43c304db8c91ec6ca0 --- M repo/maintenance/importProperties.php M repo/tests/phpunit/includes/api/GetClaimsTest.php M repo/tests/phpunit/includes/api/RemoveClaimsTest.php M repo/tests/phpunit/includes/api/SetClaimValueTest.php M repo/tests/phpunit/includes/content/PropertyContentTest.php 5 files changed, 7 insertions(+), 25 deletions(-) Approvals: Daniel Kinzler: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/repo/maintenance/importProperties.php b/repo/maintenance/importProperties.php index 85f86f4..bbe547f 100644 --- a/repo/maintenance/importProperties.php +++ b/repo/maintenance/importProperties.php @@ -121,9 +121,7 @@ foreach ( $data as $lang => $title ) { $label = $title; $property->setLabel( $lang, $label ); - - $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); - $property->setDataType( $libRegistry->getDataTypeFactory()->getType( 'wikibase-item' ) ); + $property->setDataTypeId( 'wikibase-item' ); } $content = \Wikibase\PropertyContent::newFromProperty( $property ); diff --git a/repo/tests/phpunit/includes/api/GetClaimsTest.php b/repo/tests/phpunit/includes/api/GetClaimsTest.php index 0c2e558..602daff 100644 --- a/repo/tests/phpunit/includes/api/GetClaimsTest.php +++ b/repo/tests/phpunit/includes/api/GetClaimsTest.php @@ -68,9 +68,7 @@ protected function getNewEntities() { $property = \Wikibase\Property::newEmpty(); - $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); - $dataTypes = $libRegistry->getDataTypeFactory()->getTypes(); - $property->setDataType( reset( $dataTypes ) ); + $property->setDataTypeId( 'string' ); return array( $this->addClaimsAndSave( \Wikibase\Item::newEmpty() ), diff --git a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php index 7e88acf..105d4c6 100644 --- a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php +++ b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php @@ -62,11 +62,7 @@ public function entityProvider() { $property = \Wikibase\Property::newEmpty(); - - $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); - $dataTypes = $libRegistry->getDataTypeFactory()->getTypes(); - - $property->setDataType( reset( $dataTypes ) ); + $property->setDataTypeId( 'string' ); return array( $this->addClaimsAndSave( \Wikibase\Item::newEmpty() ), diff --git a/repo/tests/phpunit/includes/api/SetClaimValueTest.php b/repo/tests/phpunit/includes/api/SetClaimValueTest.php index 2520708..0ed51d8 100644 --- a/repo/tests/phpunit/includes/api/SetClaimValueTest.php +++ b/repo/tests/phpunit/includes/api/SetClaimValueTest.php @@ -66,11 +66,7 @@ */ protected function getEntities( EntityId $propertyId ) { $property = \Wikibase\Property::newEmpty(); - - $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); - $dataTypes = $libRegistry->getDataTypeFactory()->getTypes(); - - $property->setDataType( reset( $dataTypes ) ); + $property->setDataTypeId( 'string' ); return array( $this->addClaimsAndSave( \Wikibase\Item::newEmpty(), $propertyId ), diff --git a/repo/tests/phpunit/includes/content/PropertyContentTest.php b/repo/tests/phpunit/includes/content/PropertyContentTest.php index ba7e599..d709458 100644 --- a/repo/tests/phpunit/includes/content/PropertyContentTest.php +++ b/repo/tests/phpunit/includes/content/PropertyContentTest.php @@ -59,10 +59,7 @@ */ protected function newEmpty() { $content = PropertyContent::newEmpty(); - - $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); - $dataTypes = $libRegistry->getDataTypeFactory()->getTypes(); - $content->getProperty()->setDataType( array_shift( $dataTypes ) ); + $content->getProperty()->setDataTypeId( 'string' ); return $content; } @@ -70,20 +67,17 @@ public function testLabelUniquenessRestriction() { \Wikibase\StoreFactory::getStore()->getTermIndex()->clear(); - $libRegistry = new \Wikibase\LibRegistry( \Wikibase\Settings::singleton() ); - $dataTypeFactory = $libRegistry->getDataTypeFactory(); - $propertyContent = PropertyContent::newEmpty(); $propertyContent->getProperty()->setLabel( 'en', 'testLabelUniquenessRestriction' ); $propertyContent->getProperty()->setLabel( 'de', 'testLabelUniquenessRestriction' ); - $propertyContent->getProperty()->setDataType( $dataTypeFactory->getType( 'wikibase-item' ) ); + $propertyContent->getProperty()->setDataTypeId( 'wikibase-item' ); $status = $propertyContent->save( 'create property', null, EDIT_NEW ); $this->assertTrue( $status->isOK(), "property creation should work" ); $propertyContent1 = PropertyContent::newEmpty(); $propertyContent1->getProperty()->setLabel( 'nl', 'testLabelUniquenessRestriction' ); - $propertyContent1->getProperty()->setDataType( $dataTypeFactory->getType( 'wikibase-item' ) ); + $propertyContent1->getProperty()->setDataTypeId( 'wikibase-item' ); $status = $propertyContent1->save( 'create property', null, EDIT_NEW ); $this->assertTrue( $status->isOK(), "property creation should work" ); -- To view, visit https://gerrit.wikimedia.org/r/60217 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I07e334767054310f1a725e43c304db8c91ec6ca0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Daniel Werner <daniel.wer...@wikimedia.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits