Jonaskeutel has submitted this change and it was merged. Change subject: fixing bugs (mostly in tests) ......................................................................
fixing bugs (mostly in tests) * renaming to ConstraintParameterParser * adding missing i18n lines * making value count checkers right * various foo * some bar * ... Change-Id: Ifcbbaaa3c1aa34397e3da4a1e14a99341b8100eb --- M i18n/en.json M i18n/qqq.json M includes/Constraint.php M includes/ConstraintCheck/Checker/CommonsLinkChecker.php M includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php M includes/ConstraintCheck/Checker/FormatChecker.php M includes/ConstraintCheck/Checker/InverseChecker.php M includes/ConstraintCheck/Checker/MultiValueChecker.php M includes/ConstraintCheck/Checker/OneOfChecker.php M includes/ConstraintCheck/Checker/RangeChecker.php M includes/ConstraintCheck/Checker/SingleValueChecker.php M includes/ConstraintCheck/Checker/SymmetricChecker.php M includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php M includes/ConstraintCheck/Checker/UniqueValueChecker.php M includes/ConstraintCheck/Checker/ValueTypeChecker.php M includes/ConstraintCheck/DelegatingConstraintChecker.php R includes/ConstraintCheck/Helper/ConstraintParameterParser.php M includes/ConstraintReportFactory.php M includes/ConstraintRepository.php M maintenance/UpdateTable.php M tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php M tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php M tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php M tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php M tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php M tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php M tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php M tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php M tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php M tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php M tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php M tests/phpunit/ConstraintRepositoryTest.php M tests/phpunit/ConstraintTest.php M tests/phpunit/DelegatingConstraintCheckerTest.php R tests/phpunit/Helper/ConstraintParameterParserTest.php M tests/phpunit/Maintenance/UpdateTableTest.php M tests/phpunit/Specials/SpecialConstraintReportTest.php 47 files changed, 384 insertions(+), 365 deletions(-) Approvals: Jonaskeutel: Looks good to me, approved diff --git a/i18n/en.json b/i18n/en.json index 4b8dfd0..0bc8341 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -22,6 +22,7 @@ "wbqc-constraintreport-result-table-header-constraint": "Constraint", "wbqc-constraintreport-result-link-to-claim": "go to claim", "wbqc-constraintreport-result-link-to-constraint": "go to constraint", + "wbqc-constraintreport-no-parameter": "none", "wbq-subextension-name-wbqc": "Constraints", "wbqc-violation-header-parameters": "Parameters:", diff --git a/i18n/qqq.json b/i18n/qqq.json index 6fb7022..a9bb93f 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -25,6 +25,7 @@ "wbqc-constraintreport-result-table-header-constraint": "Header of the column that gives information about which constraint was checked.\n{{Identical|Constraint}}", "wbqc-constraintreport-result-link-to-claim": "Text for the link to a claim group on the entity page.", "wbqc-constraintreport-result-link-to-constraint": "Text for the link to a constraint on the property page.", + "wbqc-constraintreport-no-parameter": "Text that is displayed when there was no value for a parameter given.", "wbq-subextension-name-wbqc": "Name of this subextension. Is shown in special page that lists all the violations.\n{{Identical|Constraint}}", "wbqc-violation-header-parameters": "Header for section in violations special page that displays the parameters of the constraint.\n{{Identical|Parameter}}", "wbqc-violations-group": "Type of violations this extension finds.\n{{Identical|Constraint}}", diff --git a/includes/Constraint.php b/includes/Constraint.php index d79aa07..bf6f0e5 100644 --- a/includes/Constraint.php +++ b/includes/Constraint.php @@ -2,6 +2,9 @@ namespace WikibaseQuality\ConstraintReport; +use Wikibase\DataModel\Entity\PropertyId; + + class Constraint { /** diff --git a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php index 20b8484..5ee8c42 100644 --- a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php +++ b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php @@ -59,7 +59,7 @@ * $mainSnak must be PropertyValueSnak, neither PropertySomeValueSnak nor PropertyNoValueSnak is allowed */ if ( !$mainSnak instanceof PropertyValueSnak ) { - $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraintName )->escaped(); + $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } @@ -71,7 +71,7 @@ * parameter $namespace can be null, works for commons galleries */ if ( $dataValue->getType() !== 'string' ) { - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraintName, 'string' )->escaped(); + $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeName(), 'string' )->escaped(); return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } diff --git a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php index f3dc860..ec5f1cd 100644 --- a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php +++ b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php @@ -5,7 +5,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper; use Wikibase\DataModel\Statement\Statement; @@ -20,9 +20,9 @@ class DiffWithinRangeChecker implements ConstraintChecker { /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; /** * @var RangeCheckerHelper @@ -30,11 +30,11 @@ private $rangeCheckerHelper; /** - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper * @param RangeCheckerHelper $rangeCheckerHelper */ - public function __construct( ConstraintReportHelper $helper, RangeCheckerHelper $rangeCheckerHelper ) { - $this->constraintReportHelper = $helper; + public function __construct( ConstraintParameterParser $helper, RangeCheckerHelper $rangeCheckerHelper ) { + $this->constraintParameterParser = $helper; $this->rangeCheckerHelper = $rangeCheckerHelper; } @@ -53,7 +53,7 @@ $property = false; if ( array_key_exists( 'property', $constraintParameters ) ) { $property = $constraintParameters['property']; - $parameters['property'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['property'], 'PropertyId' ); + $parameters['property'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['property'], 'PropertyId' ); } if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { @@ -82,8 +82,8 @@ if ( $property && array_key_exists( 'minimum_quantity', $constraintParameters ) && array_key_exists( 'maximum_quantity', $constraintParameters ) ) { $min = $constraintParameters['minimum_quantity']; $max = $constraintParameters['maximum_quantity']; - $parameters['minimum_quantity'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['minimum_quantity'] ); - $parameters['maximum_quantity'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['maximum_quantity'] ); + $parameters['minimum_quantity'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['minimum_quantity'] ); + $parameters['maximum_quantity'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['maximum_quantity'] ); } else { $message = wfMessage( "wbqc-violation-message-parameter-needed" )->params( $constraint->getConstraintTypeName(), 'property", "minimum_quantity" and "maximum_quantity' )->escaped(); } diff --git a/includes/ConstraintCheck/Checker/FormatChecker.php b/includes/ConstraintCheck/Checker/FormatChecker.php index 9fe1173..48726b9 100644 --- a/includes/ConstraintCheck/Checker/FormatChecker.php +++ b/includes/ConstraintCheck/Checker/FormatChecker.php @@ -5,7 +5,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Entity\Entity; @@ -19,12 +19,12 @@ class FormatChecker implements ConstraintChecker { /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ private $helper; /** - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper */ public function __construct( $helper ) { $this->helper = $helper; diff --git a/includes/ConstraintCheck/Checker/InverseChecker.php b/includes/ConstraintCheck/Checker/InverseChecker.php index a86337a..05b838b 100644 --- a/includes/ConstraintCheck/Checker/InverseChecker.php +++ b/includes/ConstraintCheck/Checker/InverseChecker.php @@ -6,7 +6,7 @@ use Wikibase\Lib\Store\EntityLookup; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; @@ -26,9 +26,9 @@ private $entityLookup; /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; /** * @var ConnectionCheckerHelper @@ -37,12 +37,12 @@ /** * @param EntityLookup $lookup - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper * @param ConnectionCheckerHelper $connectionCheckerHelper */ - public function __construct( EntityLookup $lookup, ConstraintReportHelper $helper, ConnectionCheckerHelper $connectionCheckerHelper ) { + public function __construct( EntityLookup $lookup, ConstraintParameterParser $helper, ConnectionCheckerHelper $connectionCheckerHelper ) { $this->entityLookup = $lookup; - $this->constraintReportHelper = $helper; + $this->constraintParameterParser = $helper; $this->connectionCheckerHelper = $connectionCheckerHelper; } @@ -60,11 +60,11 @@ $constraintParameters = $constraint->getConstraintParameters(); if ( array_key_exists( 'property', $constraintParameters ) ) { - $parameters['property'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['property'] ); + $parameters['property'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['property'] ); }; if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { - $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); + $parameters['constraint_status'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['constraint_status'], true ); } $mainSnak = $statement->getMainSnak(); diff --git a/includes/ConstraintCheck/Checker/MultiValueChecker.php b/includes/ConstraintCheck/Checker/MultiValueChecker.php index 2c2d8c5..697a5be 100644 --- a/includes/ConstraintCheck/Checker/MultiValueChecker.php +++ b/includes/ConstraintCheck/Checker/MultiValueChecker.php @@ -29,8 +29,8 @@ private $constraintParameterParser; /** - * @param $helper - * @param $valueCountCheckerHelper + * @param ConstraintParameterParser $helper + * @param ValueCountCheckerHelper $valueCountCheckerHelper */ public function __construct( $helper, $valueCountCheckerHelper ) { $this->constraintParameterParser = $helper; diff --git a/includes/ConstraintCheck/Checker/OneOfChecker.php b/includes/ConstraintCheck/Checker/OneOfChecker.php index 55a6736..59e53d9 100644 --- a/includes/ConstraintCheck/Checker/OneOfChecker.php +++ b/includes/ConstraintCheck/Checker/OneOfChecker.php @@ -5,7 +5,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Entity\Entity; @@ -19,14 +19,14 @@ class OneOfChecker implements ConstraintChecker { /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ private $helper; /** - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper */ - public function __construct( ConstraintReportHelper $helper ) { + public function __construct( ConstraintParameterParser $helper ) { $this->helper = $helper; } diff --git a/includes/ConstraintCheck/Checker/RangeChecker.php b/includes/ConstraintCheck/Checker/RangeChecker.php index 853fa85..a2bc7e5 100644 --- a/includes/ConstraintCheck/Checker/RangeChecker.php +++ b/includes/ConstraintCheck/Checker/RangeChecker.php @@ -5,7 +5,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; @@ -20,9 +20,9 @@ class RangeChecker implements ConstraintChecker { /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; /** * @var RangeCheckerHelper @@ -30,11 +30,11 @@ private $rangeCheckerHelper; /** - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper * @param RangeCheckerHelper $rangeCheckerHelper */ - public function __construct( ConstraintReportHelper $helper, RangeCheckerHelper $rangeCheckerHelper ) { - $this->constraintReportHelper = $helper; + public function __construct( ConstraintParameterParser $helper, RangeCheckerHelper $rangeCheckerHelper ) { + $this->constraintParameterParser = $helper; $this->rangeCheckerHelper = $rangeCheckerHelper; } @@ -52,7 +52,7 @@ $constraintParameters = $constraint->getConstraintParameters(); if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { - $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); + $parameters['constraint_status'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['constraint_status'], true ); } $mainSnak = $statement->getMainSnak(); @@ -77,8 +77,8 @@ if ( array_key_exists( 'minimum_quantity', $constraintParameters ) && array_key_exists( 'maximum_quantity', $constraintParameters ) && !array_key_exists( 'minimum_date', $constraintParameters ) && !array_key_exists( 'maximum_date', $constraintParameters ) ) { $min = $constraintParameters['minimum_quantity']; $max = $constraintParameters['maximum_quantity']; - $parameters['minimum_quantity'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['minimum_quantity'] ); - $parameters['maximum_quantity'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['maximum_quantity'] ); + $parameters['minimum_quantity'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['minimum_quantity'] ); + $parameters['maximum_quantity'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['maximum_quantity'] ); } else { $message = wfMessage( "wbqc-violation-message-range-parameters-needed" )->params( 'quantity', 'minimum_quantity" and "maximum_quantity' )->escaped(); } @@ -86,8 +86,8 @@ if ( !array_key_exists( 'minimum_quantity', $constraintParameters ) && !array_key_exists( 'maximum_quantity', $constraintParameters ) && array_key_exists( 'minimum_date', $constraintParameters ) && array_key_exists( 'maximum_date', $constraintParameters ) ) { $min = $constraintParameters['minimum_date']; $max = $constraintParameters['maximum_date']; - $parameters['minimum_date'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['minimum_date'] ); - $parameters['maximum_date'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['maximum_date'] ); + $parameters['minimum_date'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['minimum_date'] ); + $parameters['maximum_date'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['maximum_date'] ); } else { $message = wfMessage( "wbqc-violation-message-range-parameters-needed" )->params( 'time', 'minimum_date" and "maximum_date' )->escaped(); } diff --git a/includes/ConstraintCheck/Checker/SingleValueChecker.php b/includes/ConstraintCheck/Checker/SingleValueChecker.php index 496a6c3..e9039c2 100644 --- a/includes/ConstraintCheck/Checker/SingleValueChecker.php +++ b/includes/ConstraintCheck/Checker/SingleValueChecker.php @@ -8,7 +8,7 @@ use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Entity\Entity; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; /** @@ -24,13 +24,17 @@ private $valueCountCheckerHelper; /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; - public function __construct( $helper ) { - $this->constraintReportHelper = $helper; - $this->valueCountCheckerHelper = new ValueCountCheckerHelper(); + /** + * @param ConstraintParameterParser $helper + * @param ValueCountCheckerHelper $valueCountCheckerHelper + */ + public function __construct( ConstraintParameterParser $helper, ValueCountCheckerHelper $valueCountCheckerHelper ) { + $this->constraintParameterParser = $helper; + $this->valueCountCheckerHelper = $valueCountCheckerHelper; } /** @@ -49,7 +53,7 @@ $constraintParameters = $constraint->getConstraintParameters(); if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { - $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); + $parameters['constraint_status'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['constraint_status'], true ); } $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount( $entity->getStatements() ); diff --git a/includes/ConstraintCheck/Checker/SymmetricChecker.php b/includes/ConstraintCheck/Checker/SymmetricChecker.php index 47967fd..0c0b032 100644 --- a/includes/ConstraintCheck/Checker/SymmetricChecker.php +++ b/includes/ConstraintCheck/Checker/SymmetricChecker.php @@ -6,7 +6,7 @@ use Wikibase\Lib\Store\EntityLookup; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; @@ -26,9 +26,9 @@ private $entityLookup; /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; /** * @var ConnectionCheckerHelper @@ -37,12 +37,12 @@ /** * @param EntityLookup $lookup - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper * @param ConnectionCheckerHelper $connectionCheckerHelper */ - public function __construct( EntityLookup $lookup, ConstraintReportHelper $helper, ConnectionCheckerHelper $connectionCheckerHelper ) { + public function __construct( EntityLookup $lookup, ConstraintParameterParser $helper, ConnectionCheckerHelper $connectionCheckerHelper ) { $this->entityLookup = $lookup; - $this->constraintReportHelper = $helper; + $this->constraintParameterParser = $helper; $this->connectionCheckerHelper = $connectionCheckerHelper; } @@ -60,7 +60,7 @@ $constraintParameters = $constraint->getConstraintParameters(); if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { - $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); + $parameters['constraint_status'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['constraint_status'], true ); } $mainSnak = $statement->getMainSnak(); diff --git a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php index 4367d02..7d8e13e 100644 --- a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php +++ b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php @@ -6,7 +6,7 @@ use Wikibase\Lib\Store\EntityLookup; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use Wikibase\DataModel\Statement\Statement; @@ -26,9 +26,9 @@ private $entityLookup; /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; /** * @var ConnectionCheckerHelper @@ -37,12 +37,12 @@ /** * @param EntityLookup $lookup - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper * @param ConnectionCheckerHelper $connectionCheckerHelper */ - public function __construct( EntityLookup $lookup, ConstraintReportHelper $helper, ConnectionCheckerHelper $connectionCheckerHelper ) { + public function __construct( EntityLookup $lookup, ConstraintParameterParser $helper, ConnectionCheckerHelper $connectionCheckerHelper ) { $this->entityLookup = $lookup; - $this->constraintReportHelper = $helper; + $this->constraintParameterParser = $helper; $this->connectionCheckerHelper = $connectionCheckerHelper; } @@ -62,17 +62,17 @@ $property = false; if ( array_key_exists( 'property', $constraintParameters ) ) { $property = $constraintParameters['property']; - $parameters['property'] = $this->constraintReportHelper->parseSingleParameter( $property ); + $parameters['property'] = $this->constraintParameterParser->parseSingleParameter( $property ); } $items = false; if ( array_key_exists( 'item', $constraintParameters ) ) { $items = explode( ',', $constraintParameters['item'] ); - $parameters['item'] = $this->constraintReportHelper->parseParameterArray( $items ); + $parameters['item'] = $this->constraintParameterParser->parseParameterArray( $items ); } if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { - $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); + $parameters['constraint_status'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['constraint_status'], true ); } $mainSnak = $statement->getMainSnak(); diff --git a/includes/ConstraintCheck/Checker/UniqueValueChecker.php b/includes/ConstraintCheck/Checker/UniqueValueChecker.php index 58bbecb..906cbb3 100644 --- a/includes/ConstraintCheck/Checker/UniqueValueChecker.php +++ b/includes/ConstraintCheck/Checker/UniqueValueChecker.php @@ -26,14 +26,15 @@ /** * @var ConstraintParameterParser */ - private $constraintReportHelper; + private $constraintParameterParser; /** * @param ConstraintParameterParser $helper + * @param ValueCountCheckerHelper $valueCountCheckerHelper */ - public function __construct( ConstraintParameterParser $helper ) { + public function __construct( ConstraintParameterParser $helper, ValueCountCheckerHelper $valueCountCheckerHelper ) { $this->constraintParameterParser = $helper; - $this->valueCountCheckerHelper = new ValueCountCheckerHelper(); + $this->valueCountCheckerHelper = $valueCountCheckerHelper; } // todo: implement when index exists that makes it possible in reasonable time @@ -49,7 +50,7 @@ $constraintParameters = $constraint->getConstraintParameters(); if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { - $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); + $parameters['constraint_status'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['constraint_status'], true ); } $message = wfMessage( "wbqc-violation-message-not-yet-implemented" )->escaped(); diff --git a/includes/ConstraintCheck/Checker/ValueTypeChecker.php b/includes/ConstraintCheck/Checker/ValueTypeChecker.php index 71f9f59..4516ed4 100644 --- a/includes/ConstraintCheck/Checker/ValueTypeChecker.php +++ b/includes/ConstraintCheck/Checker/ValueTypeChecker.php @@ -6,7 +6,7 @@ use Wikibase\Lib\Store\EntityLookup; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\ConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper; use Wikibase\DataModel\Statement\Statement; @@ -21,7 +21,7 @@ class ValueTypeChecker implements ConstraintChecker { /** - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ private $helper; @@ -40,10 +40,10 @@ /** * @param EntityLookup $lookup - * @param ConstraintReportHelper $helper + * @param ConstraintParameterParser $helper * @param TypeCheckerHelper $typeCheckerHelper */ - public function __construct( EntityLookup $lookup, ConstraintReportHelper $helper, TypeCheckerHelper $typeCheckerHelper ) { + public function __construct( EntityLookup $lookup, ConstraintParameterParser $helper, TypeCheckerHelper $typeCheckerHelper ) { $this->entityLookup = $lookup; $this->helper = $helper; $this->typeCheckerHelper = $typeCheckerHelper; diff --git a/includes/ConstraintCheck/DelegatingConstraintChecker.php b/includes/ConstraintCheck/DelegatingConstraintChecker.php index 2ee5014..bb9c2f4 100644 --- a/includes/ConstraintCheck/DelegatingConstraintChecker.php +++ b/includes/ConstraintCheck/DelegatingConstraintChecker.php @@ -8,7 +8,7 @@ use Wikibase\DataModel\Statement\StatementList; use Wikibase\DataModel\Snak; use Wikibase\DataModel\Entity\Entity; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use WikibaseQuality\ConstraintReport\ConstraintRepository; use WikibaseQuality\ConstraintReport\Constraint; @@ -35,7 +35,7 @@ /** * Class for helper functions for constraint checkers. * - * @var ConstraintReportHelper + * @var ConstraintParameterParser */ private $helper; @@ -54,7 +54,7 @@ public function __construct( EntityLookup $lookup, $checkerMap ) { $this->entityLookup = $lookup; $this->checkerMap = $checkerMap; - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->constraintRepository = new ConstraintRepository(); } diff --git a/includes/ConstraintCheck/Helper/ConstraintReportHelper.php b/includes/ConstraintCheck/Helper/ConstraintParameterParser.php similarity index 73% rename from includes/ConstraintCheck/Helper/ConstraintReportHelper.php rename to includes/ConstraintCheck/Helper/ConstraintParameterParser.php index 301888e..92f59c1 100644 --- a/includes/ConstraintCheck/Helper/ConstraintReportHelper.php +++ b/includes/ConstraintCheck/Helper/ConstraintParameterParser.php @@ -4,17 +4,14 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; - +use InvalidArgumentException; /** - * Class ConstraintReportHelper - * Class for helper functions for constraint checkers. - * * @package WikibaseQuality\ConstraintReport\ConstraintCheck\Helper * @author BP2014N1 * @license GNU GPL v2+ */ -class ConstraintReportHelper { +class ConstraintParameterParser { /** * @param string $templateString @@ -34,7 +31,7 @@ * @return array */ public function stringToArray( $templateString ) { - if ( is_null( $templateString ) || $templateString === '' ) { + if ( $templateString === null || $templateString === '' ) { return array ( '' ); } else { return explode( ',', $this->removeBrackets( str_replace( ' ', '', $templateString ) ) ); @@ -43,11 +40,11 @@ private function parseParameter( $parameter, $asString = false ) { if ( $parameter === null ) { - return 'null'; + return wfMessage( "wbqc-constraintreport-no-parameter" )->escaped(); } if ( $asString ) { - return "$parameter"; + return strval( $parameter ); } $startsWith = strtoupper( substr( $parameter, 0, 1 ) ); @@ -58,7 +55,7 @@ } elseif ( $startsWith === 'P' ) { return new PropertyId( $parameter ); } - } catch (\InvalidArgumentException $e) { + } catch ( InvalidArgumentException $e ) { return ''; } @@ -66,7 +63,7 @@ } /** - * Helps set/format a single parameter depending on its type. + * Formats a parameter with a single value and wraps it in an array. * * @param string $parameter * @param bool $asString @@ -78,7 +75,7 @@ } /** - * Helps set/format the item/class/property parameter arrays according to their respective type. + * Formats a parameter with an array of values and wraps them in an array. * * @param array $parameterArray * @param bool $asString @@ -86,12 +83,12 @@ * @return array */ public function parseParameterArray( $parameterArray, $asString = false ) { - if ( $parameterArray[ 0 ] === '' ) { // parameter not given - return array ( 'null' ); + if ( $parameterArray[0] === '' ) { // parameter not given + return array ( wfMessage( "wbqc-constraintreport-no-parameter" )->escaped() ); } else { $array = array (); foreach ( $parameterArray as $parameter ) { - $array[ ] = $this->parseParameter( $parameter, $asString ); + $array[] = $this->parseParameter( $parameter, $asString ); } return $array; } @@ -104,11 +101,7 @@ * @return null|string */ public function getParameterFromJson( $json, $parameter ) { - if ( isset( $json->$parameter ) ) { - return $json->$parameter; - } else { - return null; - } + return isset( $json->$parameter ) ? $json->$parameter : null; } } \ No newline at end of file diff --git a/includes/ConstraintReportFactory.php b/includes/ConstraintReportFactory.php index 42dead5..74e881c 100644 --- a/includes/ConstraintReportFactory.php +++ b/includes/ConstraintReportFactory.php @@ -6,7 +6,7 @@ use Wikibase\Repo\WikibaseRepo; use Wikibase\Lib\Store\EntityLookup; use WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\CommonsLinkChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\FormatChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\OneOfChecker; @@ -28,6 +28,7 @@ use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ValueCountCheckerHelper; use WikibaseQuality\ConstraintReport\Violations\CheckResultToViolationTranslator; use WikibaseQuality\ConstraintReport\Violations\ConstraintViolationFormatter; use WikibaseQuality\Violations\ViolationFormatter; @@ -35,17 +36,17 @@ class ConstraintReportFactory { - /** - * @var EntityLookup - */ - private $entityLookup; + /** + * @var EntityLookup + */ + private $entityLookup; - /** - * @var EntityRevisionLookup - */ - private $entityRevisionLookup; + /** + * @var EntityRevisionLookup + */ + private $entityRevisionLookup; - /** + /** * @var constraintRepository */ private $constraintRepository; @@ -70,10 +71,10 @@ */ private $violationFormatter; - /** - * @var CheckResultToViolationTranslator - */ - private $checkResultToViolationTranslator; + /** + * @var CheckResultToViolationTranslator + */ + private $checkResultToViolationTranslator; /** * Returns the default instance. @@ -86,21 +87,21 @@ if ( $instance === null ) { $instance = new self( - WikibaseRepo::getDefaultInstance()->getEntityLookup(), - WikibaseRepo::getDefaultInstance()->getEntityRevisionLookup() - ); + WikibaseRepo::getDefaultInstance()->getEntityLookup(), + WikibaseRepo::getDefaultInstance()->getEntityRevisionLookup() + ); } return $instance; } - /** - * @param EntityLookup $entityLookup - * @param EntityRevisionLookup $entityRevisionLookup - */ + /** + * @param EntityLookup $entityLookup + * @param EntityRevisionLookup $entityRevisionLookup + */ public function __construct( EntityLookup $entityLookup, EntityRevisionLookup $entityRevisionLookup ) { $this->entityLookup = $entityLookup; - $this->entityRevisionLookup = $entityRevisionLookup; + $this->entityRevisionLookup = $entityRevisionLookup; } /** @@ -119,39 +120,40 @@ */ public function getConstraintCheckerMap(){ if ( $this->constraintCheckerMap === null ) { - $constraintReportHelper = new ConstraintReportHelper(); + $constraintParameterParser = new ConstraintParameterParser(); $connectionCheckerHelper = new ConnectionCheckerHelper(); $rangeCheckerHelper = new RangeCheckerHelper(); $typeCheckerHelper = new TypeCheckerHelper( $this->entityLookup ); + $valueCountCheckerHelper = new ValueCountCheckerHelper(); $this->constraintCheckerMap = array( - 'Conflicts with' => new ConflictsWithChecker( $this->entityLookup, $constraintReportHelper, $connectionCheckerHelper ), - 'Item' => new ItemChecker( $this->entityLookup, $constraintReportHelper, $connectionCheckerHelper ), - 'Target required claim' => new TargetRequiredClaimChecker( $this->entityLookup, $constraintReportHelper, $connectionCheckerHelper ), - 'Symmetric' => new SymmetricChecker( $this->entityLookup, $constraintReportHelper, $connectionCheckerHelper ), - 'Inverse' => new InverseChecker( $this->entityLookup, $constraintReportHelper, $connectionCheckerHelper ), - 'Qualifier' => new QualifierChecker( $constraintReportHelper ), - 'Qualifiers' => new QualifiersChecker( $constraintReportHelper ), - 'Mandatory qualifiers' => new MandatoryQualifiersChecker( $constraintReportHelper ), - 'Range' => new RangeChecker( $constraintReportHelper, $rangeCheckerHelper ), - 'Diff within range' => new DiffWithinRangeChecker( $constraintReportHelper, $rangeCheckerHelper ), - 'Type' => new TypeChecker( $this->entityLookup, $constraintReportHelper, $typeCheckerHelper ), - 'Value type' => new ValueTypeChecker( $this->entityLookup, $constraintReportHelper, $typeCheckerHelper ), - 'Single value' => new SingleValueChecker( $constraintReportHelper ), - 'Multi value' => new MultiValueChecker( $constraintReportHelper ), - 'Unique value' => new UniqueValueChecker( $constraintReportHelper ), - 'Format' => new FormatChecker( $constraintReportHelper ), - 'Commons link' => new CommonsLinkChecker( $constraintReportHelper ), - 'One of' => new OneOfChecker( $constraintReportHelper ), + 'Conflicts with' => new ConflictsWithChecker( $this->entityLookup, $constraintParameterParser, $connectionCheckerHelper ), + 'Item' => new ItemChecker( $this->entityLookup, $constraintParameterParser, $connectionCheckerHelper ), + 'Target required claim' => new TargetRequiredClaimChecker( $this->entityLookup, $constraintParameterParser, $connectionCheckerHelper ), + 'Symmetric' => new SymmetricChecker( $this->entityLookup, $constraintParameterParser, $connectionCheckerHelper ), + 'Inverse' => new InverseChecker( $this->entityLookup, $constraintParameterParser, $connectionCheckerHelper ), + 'Qualifier' => new QualifierChecker( $constraintParameterParser ), + 'Qualifiers' => new QualifiersChecker( $constraintParameterParser ), + 'Mandatory qualifiers' => new MandatoryQualifiersChecker( $constraintParameterParser ), + 'Range' => new RangeChecker( $constraintParameterParser, $rangeCheckerHelper ), + 'Diff within range' => new DiffWithinRangeChecker( $constraintParameterParser, $rangeCheckerHelper ), + 'Type' => new TypeChecker( $this->entityLookup, $constraintParameterParser, $typeCheckerHelper ), + 'Value type' => new ValueTypeChecker( $this->entityLookup, $constraintParameterParser, $typeCheckerHelper ), + 'Single value' => new SingleValueChecker( $constraintParameterParser, $valueCountCheckerHelper ), + 'Multi value' => new MultiValueChecker( $constraintParameterParser, $valueCountCheckerHelper ), + 'Unique value' => new UniqueValueChecker( $constraintParameterParser, $valueCountCheckerHelper ), + 'Format' => new FormatChecker( $constraintParameterParser ), + 'Commons link' => new CommonsLinkChecker( $constraintParameterParser ), + 'One of' => new OneOfChecker( $constraintParameterParser ), ); } return $this->constraintCheckerMap; } - /** - * @return array - */ + /** + * @return array + */ public function getConstraintParameterMap() { if ( $this->constraintParameterMap === null ) { $this->constraintParameterMap = array( @@ -179,9 +181,9 @@ return $this->constraintParameterMap; } - /** - * @return ConstraintRepository - */ + /** + * @return ConstraintRepository + */ public function getConstraintRepository() { if ( $this->constraintRepository === null ) { $this->constraintRepository = new ConstraintRepository( CONSTRAINT_TABLE ); @@ -190,25 +192,26 @@ return $this->constraintRepository; } - /** - * @return ViolationFormatter - */ - public function getViolationFormatter() { + /** + * @return ViolationFormatter + */ + public function getViolationFormatter() { if ( $this->violationFormatter === null ) { $this->violationFormatter = new ConstraintViolationFormatter(); } return $this->violationFormatter; - } + } - /** - * @return CheckResultToViolationTranslator - */ - public function getCheckResultToViolationTranslator() { - if ( $this->checkResultToViolationTranslator === null ) { - $this->checkResultToViolationTranslator = new CheckResultToViolationTranslator( $this->entityRevisionLookup ); - } + /** + * @return CheckResultToViolationTranslator + */ + public function getCheckResultToViolationTranslator() { + if ( $this->checkResultToViolationTranslator === null ) { + $this->checkResultToViolationTranslator = new CheckResultToViolationTranslator( $this->entityRevisionLookup ); + } - return $this->checkResultToViolationTranslator; - } + return $this->checkResultToViolationTranslator; + } + } \ No newline at end of file diff --git a/includes/ConstraintRepository.php b/includes/ConstraintRepository.php index ee811ac..d25e0bc 100644 --- a/includes/ConstraintRepository.php +++ b/includes/ConstraintRepository.php @@ -3,6 +3,8 @@ namespace WikibaseQuality\ConstraintReport; use InvalidArgumentException; +use Wikibase\DataModel\Entity\PropertyId; + /** * Class ConstraintRepository @@ -13,17 +15,17 @@ class ConstraintRepository { /** - * @param $prop + * @param int $prop * * @return Constraint[] */ public function queryConstraintsForProperty( $prop ) { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_SLAVE ); $results = $db->select( CONSTRAINT_TABLE, '*', - array( 'pid' => $prop ) + array( 'pid' => $prop ) ); return $this->convertToConstraints( $results ); @@ -40,7 +42,7 @@ function ( Constraint $constraint ) { return array( 'constraint_guid' => $constraint->getConstraintClaimGuid(), - 'pid' => $constraint->getPropertyId(), + 'pid' => $constraint->getPropertyId()->getNumericId(), 'constraint_type_qid' => $constraint->getConstraintTypeQid(), 'constraint_parameters' => json_encode( $constraint->getConstraintParameters() ) ); @@ -58,7 +60,7 @@ /** * @param int $batchSize * - * @throws \DBUnexpectedError + * @throws InvalidArgumentException */ public function deleteAll( $batchSize = 1000 ) { if ( !is_int( $batchSize ) ) { @@ -82,7 +84,8 @@ foreach( $results as $result ) { $constraintTypeQid = $result->constraint_type_qid; $constraintParameters = (array) json_decode( $result->constraint_parameters ); - $constraints[] = new Constraint( $result->constraint_guid, $result->pid, $constraintTypeQid, $constraintParameters ); + $serializedPid = 'P' . $result->pid; + $constraints[] = new Constraint( $result->constraint_guid, new PropertyId( $serializedPid ), $constraintTypeQid, $constraintParameters ); } return $constraints; } diff --git a/maintenance/UpdateTable.php b/maintenance/UpdateTable.php index 2bc3a58..2672d1f 100644 --- a/maintenance/UpdateTable.php +++ b/maintenance/UpdateTable.php @@ -39,7 +39,6 @@ } private function insertValues( $constraintRepo, $csvFile ) { - $i = 0; $accumulator = array(); while ( true ) { @@ -62,8 +61,8 @@ $propertyId = new PropertyId( 'P' . $data[1] ); $accumulator[] = new Constraint( $data[0], $propertyId, $data[2], $constraintParameters ); } - } + } // @codeCoverageIgnoreStart diff --git a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php index 03f8c4a..4d7b516 100644 --- a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php +++ b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php @@ -10,7 +10,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\CommonsLinkChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; /** @@ -21,7 +21,7 @@ * @group medium * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -33,7 +33,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->commonsLinkChecker = new CommonsLinkChecker( $this->helper ); $this->tablesUsed[] = 'image'; } diff --git a/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php index 01f62dc..f8c2a78 100644 --- a/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php @@ -9,7 +9,7 @@ use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ConflictsWithChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -19,7 +19,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -34,7 +34,7 @@ protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->connectionCheckerHelper = new ConnectionCheckerHelper(); $this->checker = new ConflictsWithChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); } diff --git a/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php b/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php index 46978d4..f8dae02 100644 --- a/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php @@ -18,7 +18,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ diff --git a/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php index 448be5a..3352cab 100644 --- a/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php @@ -11,7 +11,7 @@ use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\InverseChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -21,7 +21,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -36,7 +36,7 @@ protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->connectionCheckerHelper = new ConnectionCheckerHelper(); $this->checker = new InverseChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); } diff --git a/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php index 16410ab..b2753f8 100644 --- a/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php @@ -9,7 +9,7 @@ use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ItemChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -19,7 +19,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -34,7 +34,7 @@ protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->connectionCheckerHelper = new ConnectionCheckerHelper(); $this->checker = new ItemChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); } diff --git a/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php index 9c9b73f..47b1e9e 100644 --- a/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php @@ -11,7 +11,7 @@ use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SymmetricChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -21,7 +21,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -37,7 +37,7 @@ protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->connectionCheckerHelper = new ConnectionCheckerHelper(); $this->checker = new SymmetricChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $this->entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); diff --git a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php index fcf86eb..c6f1298 100644 --- a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php @@ -11,7 +11,7 @@ use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TargetRequiredClaimChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -21,7 +21,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -37,7 +37,7 @@ protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->connectionCheckerHelper = new ConnectionCheckerHelper(); $this->checker = new TargetRequiredClaimChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $this->entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); diff --git a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php index 9b626d4..a0fe21c 100644 --- a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php +++ b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php @@ -10,7 +10,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\FormatChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; /** @@ -19,7 +19,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -31,7 +31,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->formatChecker = new FormatChecker( $this->helper ); } diff --git a/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php b/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php index fce5671..0a50bf3 100644 --- a/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php +++ b/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php @@ -10,7 +10,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\OneOfChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; /** @@ -19,7 +19,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -31,7 +31,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->oneOfChecker = new OneOfChecker( $this->helper ); } diff --git a/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php b/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php index ccc7f2f..2440831 100644 --- a/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php +++ b/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php @@ -4,7 +4,7 @@ use Wikibase\DataModel\Entity\ItemId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MandatoryQualifiersChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -14,7 +14,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -26,7 +26,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); } diff --git a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php index 7a93a91..7820c04 100644 --- a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php +++ b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php @@ -4,7 +4,7 @@ use Wikibase\DataModel\Entity\ItemId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifierChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -14,7 +14,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -26,7 +26,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); } diff --git a/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php b/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php index 6867d8a..5a3348a 100644 --- a/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php +++ b/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php @@ -4,7 +4,7 @@ use Wikibase\DataModel\Entity\ItemId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifiersChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -14,7 +14,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -27,7 +27,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->qualifiersList = 'P580,P582,P1365,P1366,P642,P805'; $this->lookup = new JsonFileEntityLookup( __DIR__ ); } diff --git a/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php b/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php index 6267e13..6b285a2 100644 --- a/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php +++ b/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php @@ -10,7 +10,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\DiffWithinRangeChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -21,7 +21,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -35,7 +35,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); $this->timeValue = new TimeValue( '+00000001970-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $this->checker = new DiffWithinRangeChecker( $this->helper, new RangeCheckerHelper() ); diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php b/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php index b06bdcc..9cb757d 100644 --- a/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php +++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerHelperTest.php @@ -14,7 +14,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php index ddc59b0..4f57f17 100644 --- a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php +++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php @@ -11,7 +11,7 @@ use DataValues\TimeValue; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -22,7 +22,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -36,7 +36,7 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); $this->timeValue = new TimeValue( '+00000001970-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $this->checker = new RangeChecker( $this->helper, new RangeCheckerHelper() ); diff --git a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php index 7ff54b8..aa34365 100644 --- a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php +++ b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php @@ -9,7 +9,7 @@ use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Statement\StatementList; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TypeChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; diff --git a/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php b/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php index f5b01e5..13319a5 100644 --- a/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php +++ b/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php @@ -7,7 +7,7 @@ use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TypeChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -18,7 +18,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -32,7 +32,7 @@ protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->checker = new TypeChecker( $this->lookup, new ConstraintReportHelper(), new TypeCheckerHelper( $this->lookup ) ); + $this->checker = new TypeChecker( $this->lookup, new ConstraintParameterParser(), new TypeCheckerHelper( $this->lookup ) ); $this->typeStatement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ); } diff --git a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php index 182def7..c96c5ae 100644 --- a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php +++ b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php @@ -9,7 +9,7 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use DataValues\StringValue; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -20,7 +20,7 @@ * @group WikibaseQualityConstraints * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @author BP2014N1 * @license GNU GPL v2+ @@ -33,9 +33,9 @@ protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); - $this->checker = new ValueTypeChecker( $this->lookup, new ConstraintReportHelper(), new TypeCheckerHelper( $this->lookup ) ); + $this->checker = new ValueTypeChecker( $this->lookup, new ConstraintParameterParser(), new TypeCheckerHelper( $this->lookup ) ); $this->valueTypePropertyId = new PropertyId( 'P1234' ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php index d294d9a..48f0e8f 100644 --- a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php @@ -9,6 +9,7 @@ use Wikibase\DataModel\Entity\EntityIdValue; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ValueCountCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -17,7 +18,7 @@ * * @group WikibaseQualityConstraints * - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult * * @author BP2014N1 * @license GNU GPL v2+ @@ -25,6 +26,7 @@ class MultiValueCheckerTest extends \MediaWikiTestCase { private $helper; + private $valueCountCheckerHelper; private $multiPropertyId; private $checker; private $lookup; @@ -33,8 +35,9 @@ parent::setUp(); $this->helper = new ConstraintParameterParser(); + $this->valueCountCheckerHelper = new ValueCountCheckerHelper(); $this->multiPropertyId = new PropertyId( 'P161' ); - $this->checker = new MultiValueChecker( $this->helper ); + $this->checker = new MultiValueChecker( $this->helper, $this->valueCountCheckerHelper ); $this->lookup = new JsonFileEntityLookup( __DIR__ ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php index 21336fe..bfac31c 100644 --- a/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php @@ -9,6 +9,7 @@ use Wikibase\DataModel\Entity\EntityIdValue; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ValueCountCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -25,6 +26,7 @@ class SingleValueCheckerTest extends \MediaWikiTestCase { private $helper; + private $valueCountCheckerHelper; private $singlePropertyId; private $checker; private $lookup; @@ -33,8 +35,9 @@ parent::setUp(); $this->helper = new ConstraintParameterParser(); + $this->valueCountCheckerHelper = new ValueCountCheckerHelper(); $this->singlePropertyId = new PropertyId( 'P36' ); - $this->checker = new SingleValueChecker( $this->helper ); + $this->checker = new SingleValueChecker( $this->helper, $this->valueCountCheckerHelper ); $this->lookup = new JsonFileEntityLookup( __DIR__ ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php index 022c216..d341a68 100644 --- a/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php @@ -9,6 +9,7 @@ use Wikibase\DataModel\Entity\EntityIdValue; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\UniqueValueChecker; use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ValueCountCheckerHelper; use WikibaseQuality\Tests\Helper\JsonFileEntityLookup; @@ -17,7 +18,7 @@ * * @group WikibaseQualityConstraints * - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult * * @author BP2014N1 * @license GNU GPL v2+ @@ -25,6 +26,7 @@ class UniqueValueCheckerTest extends \MediaWikiTestCase { private $helper; + private $valueCountCheckerHelper; private $uniquePropertyId; private $checker; private $lookup; @@ -33,8 +35,9 @@ parent::setUp(); $this->helper = new ConstraintParameterParser(); + $this->valueCountCheckerHelper = new ValueCountCheckerHelper(); $this->uniquePropertyId = new PropertyId( 'P227' ); - $this->checker = new UniqueValueChecker( $this->helper ); + $this->checker = new UniqueValueChecker( $this->helper, $this->valueCountCheckerHelper ); $this->lookup = new JsonFileEntityLookup( __DIR__ ); } diff --git a/tests/phpunit/ConstraintRepositoryTest.php b/tests/phpunit/ConstraintRepositoryTest.php index 046f9a8..7b45ede 100644 --- a/tests/phpunit/ConstraintRepositoryTest.php +++ b/tests/phpunit/ConstraintRepositoryTest.php @@ -2,6 +2,7 @@ namespace WikibaseQuality\ConstraintReport\Tests; +use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintRepository; @@ -19,7 +20,7 @@ class ConstraintRepositoryTest extends \MediaWikiTestCase { public function testQueryConstraintsForExistingProperty() { - $this->insertTestData(); + $this->insertTestData(); $repo = new ConstraintRepository(); $constraints = $repo->queryConstraintsForProperty( 1 ); @@ -30,96 +31,96 @@ } public function testQueryConstraintsForNonExistingProperty() { - $this->insertTestData(); + $this->insertTestData(); - $repo = new ConstraintRepository(); + $repo = new ConstraintRepository(); $constraints = $repo->queryConstraintsForProperty( 2 ); $this->assertEquals( true, is_array( $constraints ) ); $this->assertEquals( 0, count( $constraints ) ); } - public function testInsertBatch() { - $this->insertTestData(); + public function testInsertBatch() { + $this->insertTestData(); - $constraints = array( - new Constraint( 'foo', 42, 'TestConstraint', array( 'foo' => 'bar' ) ), - new Constraint( 'bar', 42, 'TestConstraint', array( 'bar' => 'baz' ) ) - ); - $repo = new ConstraintRepository(); - $repo->insertBatch( $constraints ); + $constraints = array( + new Constraint( 'foo', new PropertyId( 'P42' ), 'TestConstraint', array( 'foo' => 'bar' ) ), + new Constraint( 'bar', new PropertyId( 'P42' ), 'TestConstraint', array( 'bar' => 'baz' ) ) + ); + $repo = new ConstraintRepository(); + $repo->insertBatch( $constraints ); - $this->assertSelect( - CONSTRAINT_TABLE, - array( - 'constraint_guid', - 'pid', - 'constraint_type_qid', - 'constraint_parameters' - ), - array(), - array( - array ( - '1', - 1, - 'Multi value', - '{}' - ), - array ( - '3', - 1, - 'Single value', - '{}' - ), - array ( - 'bar', - '42', - 'TestConstraint', - '{"bar":"baz"}' - ), - array ( - 'foo', - '42', - 'TestConstraint', - '{"foo":"bar"}' - ) - ) - ); - } + $this->assertSelect( + CONSTRAINT_TABLE, + array( + 'constraint_guid', + 'pid', + 'constraint_type_qid', + 'constraint_parameters' + ), + array(), + array( + array ( + '1', + 1, + 'Multi value', + '{}' + ), + array ( + '3', + 1, + 'Single value', + '{}' + ), + array ( + 'bar', + '42', + 'TestConstraint', + '{"bar":"baz"}' + ), + array ( + 'foo', + '42', + 'TestConstraint', + '{"foo":"bar"}' + ) + ) + ); + } - public function testDeleteAll() { - $this->insertTestData(); + public function testDeleteAll() { + $this->insertTestData(); - $repo = new ConstraintRepository(); - $repo->deleteAll(); + $repo = new ConstraintRepository(); + $repo->deleteAll(); - $this->assertSelect( - CONSTRAINT_TABLE, - 'COUNT(constraint_guid)', - array(), - array( - array( 0 ) - ) - ); - } + $this->assertSelect( + CONSTRAINT_TABLE, + 'COUNT(constraint_guid)', + array(), + array( + array( 0 ) + ) + ); + } public function insertTestData() { $this->db->delete( CONSTRAINT_TABLE, '*' ); $this->db->insert( CONSTRAINT_TABLE, - array ( - array ( - 'constraint_guid' => '1', - 'pid' => 1, - 'constraint_type_qid' => 'Multi value', - 'constraint_parameters' => '{}' - ), - array ( - 'constraint_guid' => '3', - 'pid' => 1, - 'constraint_type_qid' => 'Single value', - 'constraint_parameters' => '{}' - ) - ) + array ( + array ( + 'constraint_guid' => '1', + 'pid' => 1, + 'constraint_type_qid' => 'Multi value', + 'constraint_parameters' => '{}' + ), + array ( + 'constraint_guid' => '3', + 'pid' => 1, + 'constraint_type_qid' => 'Single value', + 'constraint_parameters' => '{}' + ) + ) ); } diff --git a/tests/phpunit/ConstraintTest.php b/tests/phpunit/ConstraintTest.php index 09d1897..4c07b2f 100644 --- a/tests/phpunit/ConstraintTest.php +++ b/tests/phpunit/ConstraintTest.php @@ -2,6 +2,7 @@ namespace WikibaseQuality\ConstraintReport\Tests; +use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\ConstraintRepository; @@ -22,15 +23,13 @@ $constraints = $repo->queryConstraintsForProperty( 1 ); $this->assertEquals( 'Item', $constraints[0]->getConstraintTypeQid() ); - $this->assertEquals( 1, $constraints[0]->getPropertyId() ); + $this->assertEquals( new PropertyId( 'P1' ), $constraints[0]->getPropertyId() ); $this->assertEquals( '1', $constraints[0]->getConstraintClaimGuid() ); $constraintParameters = $constraints[0]->getConstraintParameters(); $this->assertEquals( 2, count( $constraintParameters ) ); $this->assertEquals( 'P21', $constraintParameters['property'] ); $this->assertEquals( 'mandatory', $constraintParameters['constraint_status'] ); } - - public function addDBData() { $this->db->delete( CONSTRAINT_TABLE, '*' ); diff --git a/tests/phpunit/DelegatingConstraintCheckerTest.php b/tests/phpunit/DelegatingConstraintCheckerTest.php index 9460dca..23b8c80 100644 --- a/tests/phpunit/DelegatingConstraintCheckerTest.php +++ b/tests/phpunit/DelegatingConstraintCheckerTest.php @@ -14,7 +14,7 @@ * @group Database * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\DiffWithinRangeChecker * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker diff --git a/tests/phpunit/Helper/ConstraintReportHelperTest.php b/tests/phpunit/Helper/ConstraintParameterParserTest.php similarity index 88% rename from tests/phpunit/Helper/ConstraintReportHelperTest.php rename to tests/phpunit/Helper/ConstraintParameterParserTest.php index d5f7575..7212d4d 100644 --- a/tests/phpunit/Helper/ConstraintReportHelperTest.php +++ b/tests/phpunit/Helper/ConstraintParameterParserTest.php @@ -1,26 +1,27 @@ <?php + namespace WikibaseQuality\ConstraintReport\Test\Helper; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; -use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper; +use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser; /** - * @covers WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @covers WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * * @group WikibaseQualityConstraints * * @author BP2014N1 * @license GNU GPL v2+ */ -class ConstraintReportHelperTest extends \MediaWikiTestCase { +class ConstraintParameterParserTest extends \MediaWikiTestCase { private $helper; protected function setUp() { parent::setUp(); - $this->helper = new ConstraintReportHelper(); + $this->helper = new ConstraintParameterParser(); } protected function tearDown() { @@ -59,12 +60,12 @@ public function testParseNullParameter() { $parameter = null; - $this->assertEquals( array ( 'null' ), $this->helper->parseSingleParameter( $parameter ) ); + $this->assertEquals( array ( 'none' ), $this->helper->parseSingleParameter( $parameter ) ); } public function testParseNullParameterArray() { $parameter = array ( '' ); - $this->assertEquals( array ( 'null' ), $this->helper->parseParameterArray( $parameter ) ); + $this->assertEquals( array ( 'none' ), $this->helper->parseParameterArray( $parameter ) ); } public function testParseParameterArray() { @@ -84,4 +85,5 @@ $parameter = 'R1'; $this->assertEquals( array ( '' ), $this->helper->parseSingleParameter( $parameter ) ); } + } \ No newline at end of file diff --git a/tests/phpunit/Maintenance/UpdateTableTest.php b/tests/phpunit/Maintenance/UpdateTableTest.php index 7661b29..a15b5f7 100644 --- a/tests/phpunit/Maintenance/UpdateTableTest.php +++ b/tests/phpunit/Maintenance/UpdateTableTest.php @@ -2,7 +2,6 @@ namespace WikibaseQuality\ConstraintReport\Tests\Maintenance; - use WikibaseQuality\ConstraintReport\Maintenance\UpdateTable; @@ -18,70 +17,71 @@ */ class UpdateTableTest extends \MediaWikiTestCase { - protected function setup() { - parent::setup(); - $this->tablesUsed[] = CONSTRAINT_TABLE; - } + protected function setup() { + parent::setup(); + $this->tablesUsed[] = CONSTRAINT_TABLE; + } - public function addDBData() { - $this->db->delete( CONSTRAINT_TABLE, '*' ); - $this->db->insert( CONSTRAINT_TABLE, - array ( - array ( - 'constraint_guid' => 'foo', - 'pid' => 42, - 'constraint_type_qid' => 'TestConstraint', - 'constraint_parameters' => '{}' - ), - array ( - 'constraint_guid' => 'bar', - 'pid' => 42, - 'constraint_type_qid' => 'TestConstraint', - 'constraint_parameters' => '{}' - ) - ) - ); - } + public function addDBData() { + $this->db->delete( CONSTRAINT_TABLE, '*' ); + $this->db->insert( CONSTRAINT_TABLE, + array ( + array ( + 'constraint_guid' => 'foo', + 'pid' => 42, + 'constraint_type_qid' => 'TestConstraint', + 'constraint_parameters' => '{}' + ), + array ( + 'constraint_guid' => 'bar', + 'pid' => 42, + 'constraint_type_qid' => 'TestConstraint', + 'constraint_parameters' => '{}' + ) + ) + ); + } - public function testExecute() { - $maintenanceScript = new UpdateTable(); - $args = array( - 'csv-file' => __DIR__ . '/constraints.csv', - 'batch-size' => 2, - 'quiet' => true - ); - $maintenanceScript->loadParamsAndArgs( null, $args ); - $maintenanceScript->execute(); + public function testExecute() { + $maintenanceScript = new UpdateTable(); + $args = array( + 'csv-file' => __DIR__ . '/constraints.csv', + 'batch-size' => 2, + 'quiet' => true + ); + $maintenanceScript->loadParamsAndArgs( null, $args ); + $maintenanceScript->execute(); - $this->assertSelect( - CONSTRAINT_TABLE, - array( - 'constraint_guid', - 'pid', - 'constraint_type_qid', - 'constraint_parameters' - ), - array(), - array( - array( - 'baz', - '42', - 'ConstraintFromCsv', - '{"foo":"bar"}' - ), - array( - 'foobar', - '42', - 'ConstraintFromCsv', - '{"foobar":"bar"}' - ), - array( - 'foobaz', - '42', - 'ConstraintFromCsv', - '{"bar":"baz"}' - ) - ) - ); - } + $this->assertSelect( + CONSTRAINT_TABLE, + array( + 'constraint_guid', + 'pid', + 'constraint_type_qid', + 'constraint_parameters' + ), + array(), + array( + array( + 'baz', + '42', + 'ConstraintFromCsv', + '{"foo":"bar"}' + ), + array( + 'foobar', + '42', + 'ConstraintFromCsv', + '{"foobar":"bar"}' + ), + array( + 'foobaz', + '42', + 'ConstraintFromCsv', + '{"bar":"baz"}' + ) + ) + ); + } + } \ No newline at end of file diff --git a/tests/phpunit/Specials/SpecialConstraintReportTest.php b/tests/phpunit/Specials/SpecialConstraintReportTest.php index a03f936..5714170 100644 --- a/tests/phpunit/Specials/SpecialConstraintReportTest.php +++ b/tests/phpunit/Specials/SpecialConstraintReportTest.php @@ -25,7 +25,7 @@ * * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker - * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintReportHelper + * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult * @uses WikibaseQuality\Html\HtmlTableBuilder -- To view, visit https://gerrit.wikimedia.org/r/219371 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifcbbaaa3c1aa34397e3da4a1e14a99341b8100eb Gerrit-PatchSet: 13 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Andreasburmeister <andreas.burmeis...@student.hpi.de> Gerrit-Reviewer: Andreasburmeister <andreas.burmeis...@student.hpi.de> Gerrit-Reviewer: Jonaskeutel <jonas.keu...@student.hpi.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits