Jeroen De Dauw has submitted this change and it was merged. Change subject: Remove OPT_PREFIX_MAP from EntityIdParser ......................................................................
Remove OPT_PREFIX_MAP from EntityIdParser Change-Id: Id3f505a368f0962816d3a61fc538f60f33fb80fe --- M client/tests/phpunit/includes/RepoItemLinkGeneratorTest.php M lib/includes/ClaimGuidValidator.php M lib/includes/LibRegistry.php M lib/includes/parsers/EntityIdParser.php M lib/tests/phpunit/ClaimGuidValidatorTest.php M lib/tests/phpunit/Validators/EntityIdValidatorTest.php M repo/includes/WikibaseRepo.php M repo/includes/api/GetClaims.php 8 files changed, 22 insertions(+), 126 deletions(-) Approvals: Jeroen De Dauw: Looks good to me, approved jenkins-bot: Verified diff --git a/client/tests/phpunit/includes/RepoItemLinkGeneratorTest.php b/client/tests/phpunit/includes/RepoItemLinkGeneratorTest.php index 0d8f88f..bafc72c 100644 --- a/client/tests/phpunit/includes/RepoItemLinkGeneratorTest.php +++ b/client/tests/phpunit/includes/RepoItemLinkGeneratorTest.php @@ -74,16 +74,7 @@ } protected function getEntityIdParser() { - $entityPrefixes = array( - 'q' => \Wikibase\Item::ENTITY_TYPE, - 'p' => \Wikibase\Property::ENTITY_TYPE, - ); - - $options = new \ValueParsers\ParserOptions( array( - EntityIdParser::OPT_PREFIX_MAP => $entityPrefixes - ) ); - - return new EntityIdParser( $options ); + return new EntityIdParser( new \ValueParsers\ParserOptions() ); } public function getLinksProvider() { diff --git a/lib/includes/ClaimGuidValidator.php b/lib/includes/ClaimGuidValidator.php index bce056a..87b2399 100644 --- a/lib/includes/ClaimGuidValidator.php +++ b/lib/includes/ClaimGuidValidator.php @@ -6,21 +6,6 @@ use ValueParsers\ParserOptions; /** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * * @since 0.4 * * @file @@ -30,12 +15,6 @@ * @author Katie Filbert < aude.w...@gmail.com > */ class ClaimGuidValidator { - - protected $entityPrefixes; - - public function __construct( array $entityPrefixes ) { - $this->entityPrefixes = $entityPrefixes; - } /** * Validates a claim guid @@ -114,10 +93,7 @@ * @return boolean */ protected function validateClaimGuidPrefix( $prefixedId ) { - $options = new ParserOptions( array( - EntityIdParser::OPT_PREFIX_MAP => $this->entityPrefixes - ) ); - + $options = new ParserOptions(); $entityIdParser = new EntityIdParser( $options ); $entityId = $entityIdParser->parse( $prefixedId ); diff --git a/lib/includes/LibRegistry.php b/lib/includes/LibRegistry.php index 2ac5ccf..b9732aa 100644 --- a/lib/includes/LibRegistry.php +++ b/lib/includes/LibRegistry.php @@ -108,10 +108,7 @@ * @return EntityIdParser */ public function getEntityIdParser() { - $options = new ParserOptions( array( - EntityIdParser::OPT_PREFIX_MAP => $this->settings->getSetting( 'entityPrefixes' ) - ) ); - + $options = new ParserOptions(); return new EntityIdParser( $options ); } @@ -146,4 +143,4 @@ // Do not add new stuff here without reading the notice at the top first. -} \ No newline at end of file +} diff --git a/lib/includes/parsers/EntityIdParser.php b/lib/includes/parsers/EntityIdParser.php index ae568f2..175fca1 100644 --- a/lib/includes/parsers/EntityIdParser.php +++ b/lib/includes/parsers/EntityIdParser.php @@ -23,11 +23,6 @@ class EntityIdParser extends StringValueParser { /** - * @deprecated - */ - const OPT_PREFIX_MAP = 'prefixmap'; - - /** * @see StringValueParser::stringParse * * @since 0.4 diff --git a/lib/tests/phpunit/ClaimGuidValidatorTest.php b/lib/tests/phpunit/ClaimGuidValidatorTest.php index fcb4a88..d97515a 100644 --- a/lib/tests/phpunit/ClaimGuidValidatorTest.php +++ b/lib/tests/phpunit/ClaimGuidValidatorTest.php @@ -5,21 +5,7 @@ use Wikibase\Lib\ClaimGuidValidator; /** - * Tests for the ClaimGuidValidator class. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * @covers Wikibase\Lib\ClaimGuidValidator * * @file * @since 0.4 @@ -35,22 +21,11 @@ */ class ClaimGuidValidatorTest extends \PHPUnit_Framework_TestCase { - protected $entityPrefixes; - - public function setUp() { - parent::setUp(); - - $this->entityPrefixes = array( - 'q' => \Wikibase\Item::ENTITY_TYPE, - 'p' => \Wikibase\Property::ENTITY_TYPE, - ); - } - /** * @dataProvider validateProvider */ public function testValidate( $guid ) { - $claimGuidValidator = new ClaimGuidValidator( $this->entityPrefixes ); + $claimGuidValidator = new ClaimGuidValidator(); $isValid = $claimGuidValidator->validate( $guid ); $this->assertTrue( $isValid, "Assert that claim guid $guid is valid" ); @@ -68,7 +43,7 @@ * @dataProvider validateInvalidProvider */ public function testValidateInvalid( $guid ) { - $claimGuidValidator = new ClaimGuidValidator( $this->entityPrefixes ); + $claimGuidValidator = new ClaimGuidValidator(); $isValid = $claimGuidValidator->validate( $guid ); $this->assertFalse( $isValid, "Assert that claim guid $guid is invalid" ); @@ -96,7 +71,7 @@ * @dataProvider validateProvider */ public function testValidateFormat( $guid ) { - $claimGuidValidator = new ClaimGuidValidator( $this->entityPrefixes ); + $claimGuidValidator = new ClaimGuidValidator(); $isValid = $claimGuidValidator->validate( $guid ); $this->assertTrue( $isValid, "Assert that claim guid $guid has a valid format." ); @@ -106,7 +81,7 @@ * @dataProvider invalidFormatProvider */ public function testInvalidFormat( $guid ) { - $claimGuidValidator = new ClaimGuidValidator( $this->entityPrefixes ); + $claimGuidValidator = new ClaimGuidValidator(); $isValid = $claimGuidValidator->validate( $guid ); $this->assertFalse( $isValid, "Assert that claim guid $guid has an invalid format." ); @@ -124,7 +99,7 @@ * @dataProvider validateInvalidPrefixedIdProvider */ public function testValidateInvalidPrefixedId( $guid ) { - $claimGuidValidator = new ClaimGuidValidator( $this->entityPrefixes ); + $claimGuidValidator = new ClaimGuidValidator(); $this->setExpectedException( 'ValueParsers\ParseException' ); diff --git a/lib/tests/phpunit/Validators/EntityIdValidatorTest.php b/lib/tests/phpunit/Validators/EntityIdValidatorTest.php index fc08fdd..f6bb59e 100644 --- a/lib/tests/phpunit/Validators/EntityIdValidatorTest.php +++ b/lib/tests/phpunit/Validators/EntityIdValidatorTest.php @@ -1,35 +1,4 @@ <?php - /** - * - * Copyright © 14.06.13 by the authors listed below. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @license GPL 2+ - * @file - * - * @ingroup WikibaseLib - * @ingroup Test - * - * @group WikibaseLib - * @group Wikibase - * @group WikibaseValidators - * - * @author Daniel Kinzler - */ namespace Wikibase\Test\Validators; @@ -41,9 +10,14 @@ use Wikibase\Validators\ValidatorErrorLocalizer; /** - * Class EntityIdValidatorTest * @covers Wikibase\Validators\EntityIdValidator - * @package Wikibase\Test\Validators + * + * @group WikibaseLib + * @group Wikibase + * @group WikibaseValidators + * + * @license GPL 2+ + * @author Daniel Kinzler */ class EntityIdValidatorTest extends \PHPUnit_Framework_TestCase { @@ -60,16 +34,10 @@ } /** - * @dataProvider provideValidate() + * @dataProvider provideValidate */ public function testValidate( $types, $value, $expected, $message ) { - //XXX: the ParserOptions stuff seems cumbersome, what is it good for? - $parser = new EntityIdParser( new ParserOptions( array( - EntityIdParser::OPT_PREFIX_MAP => array( - 'q' => Item::ENTITY_TYPE, - 'p' => Property::ENTITY_TYPE, - ) - ) ) ); + $parser = new EntityIdParser( new ParserOptions() ); $validator = new EntityIdValidator( $parser, $types ); $result = $validator->validate( $value ); diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php index 601067b..4e4e50e 100644 --- a/repo/includes/WikibaseRepo.php +++ b/repo/includes/WikibaseRepo.php @@ -263,10 +263,7 @@ * @return EntityIdParser */ public function getEntityIdParser() { - $options = new ParserOptions( array( - EntityIdParser::OPT_PREFIX_MAP => $this->settings->getSetting( 'entityPrefixes' ) - ) ); - + $options = new ParserOptions(); return new EntityIdParser( $options ); } @@ -309,9 +306,7 @@ */ public function getClaimGuidValidator() { if ( $this->claimGuidValidator === null ) { - $this->claimGuidValidator = new ClaimGuidValidator( - $this->settings->getSetting( 'entityPrefixes' ) - ); + $this->claimGuidValidator = new ClaimGuidValidator(); } return $this->claimGuidValidator; diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php index 65f4e4b..8d2f525 100644 --- a/repo/includes/api/GetClaims.php +++ b/repo/includes/api/GetClaims.php @@ -214,8 +214,7 @@ // @todo handle the settings in a more generalized way for all the api modules $settings = WikibaseRepo::getDefaultInstance()->getSettings(); - $entityPrefixes = $settings->getSetting( 'entityPrefixes' ); - $claimGuidValidator = new ClaimGuidValidator( $entityPrefixes ); + $claimGuidValidator = new ClaimGuidValidator(); if ( isset( $params['claim'] ) && $claimGuidValidator->validateFormat( $params['claim'] ) === false ) { $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' ); -- To view, visit https://gerrit.wikimedia.org/r/81552 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id3f505a368f0962816d3a61fc538f60f33fb80fe Gerrit-PatchSet: 6 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: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits