Lucas Werkmeister (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/346977 )
Change subject: Store entity in check result ...................................................................... Store entity in check result The API will support checking for all violations of a given claim (by claim ID), and it will return check results grouped by entity ID, so it needs to know the entity ID of each check result. To avoid having to parse the entity ID out of the claim ID twice, we store it in the check result. This means that checkConstraint()’s third parameter, $entity, is no longer optional, which in turn requires many small changes to the tests, even though most of the tests don’t actually use the entity. Change-Id: I06d1256dc9c09e390aaf1367d40b5b1890c2142f --- M includes/ConstraintCheck/Checker/CommonsLinkChecker.php M includes/ConstraintCheck/Checker/ConflictsWithChecker.php M includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php M includes/ConstraintCheck/Checker/FormatChecker.php M includes/ConstraintCheck/Checker/InverseChecker.php M includes/ConstraintCheck/Checker/ItemChecker.php M includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php M includes/ConstraintCheck/Checker/MultiValueChecker.php M includes/ConstraintCheck/Checker/OneOfChecker.php M includes/ConstraintCheck/Checker/QualifierChecker.php M includes/ConstraintCheck/Checker/QualifiersChecker.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/TypeChecker.php M includes/ConstraintCheck/Checker/UniqueValueChecker.php M includes/ConstraintCheck/Checker/ValueTypeChecker.php M includes/ConstraintCheck/ConstraintChecker.php M includes/ConstraintCheck/DelegatingConstraintChecker.php M includes/ConstraintCheck/Result/CheckResult.php M tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.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/RangeCheckerTest.php M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php M tests/phpunit/Fake/FakeChecker.php M tests/phpunit/Fake/FakeCheckerTest.php M tests/phpunit/Result/CheckResultTest.php 34 files changed, 247 insertions(+), 166 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints refs/changes/77/346977/1 diff --git a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php index 3c2656d..72920a8 100644 --- a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php +++ b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php @@ -39,7 +39,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); $namespace = ''; @@ -60,7 +60,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -72,7 +72,7 @@ */ if ( $dataValue->getType() !== 'string' ) { $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 ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $commonsLink = $dataValue->getValue(); @@ -96,7 +96,7 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } /** diff --git a/includes/ConstraintCheck/Checker/ConflictsWithChecker.php b/includes/ConstraintCheck/Checker/ConflictsWithChecker.php index ae5b337..e5aed82 100644 --- a/includes/ConstraintCheck/Checker/ConflictsWithChecker.php +++ b/includes/ConstraintCheck/Checker/ConflictsWithChecker.php @@ -54,7 +54,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -64,7 +64,7 @@ */ if ( !array_key_exists( 'property', $constraintParameters ) ) { $message = wfMessage( "wbqc-violation-message-parameter-needed" )->params( $constraint->getConstraintTypeName(), 'property' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $parameters['property'] = $this->constraintParameterParser->parseSingleParameter( $constraintParameters['property'] ); @@ -95,7 +95,7 @@ } } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php index 54806d0..cde1347 100644 --- a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php +++ b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php @@ -47,7 +47,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); $property = false; @@ -68,7 +68,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -91,7 +91,7 @@ $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeName(), 'quantity" or "time' )->escaped(); } if ( isset( $message ) ) { - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $thisValue = $this->rangeCheckerHelper->getComparativeValue( $dataValue ); @@ -108,7 +108,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-diff-within-range-property-needs value" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } if ( $mainSnak->getDataValue()->getType() === $dataValue->getType() && $mainSnak->getType() === 'value' ) { @@ -129,13 +129,13 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } $message = wfMessage( "wbqc-violation-message-diff-within-range-property-must-exist" )->escaped(); $status = CheckResult::STATUS_VIOLATION; - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/FormatChecker.php b/includes/ConstraintCheck/Checker/FormatChecker.php index cbe0cb0..438938d 100644 --- a/includes/ConstraintCheck/Checker/FormatChecker.php +++ b/includes/ConstraintCheck/Checker/FormatChecker.php @@ -39,7 +39,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -48,7 +48,7 @@ $parameters['pattern'] = $this->helper->parseSingleParameter( $pattern, true ); } else { $message = wfMessage( "wbqc-violation-message-parameter-needed" )->params( $constraint->getConstraintTypeName(), 'pattern' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } if ( array_key_exists( 'constraint_status', $constraintParameters ) ) { @@ -63,7 +63,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -75,11 +75,11 @@ */ if ( $dataValue->getType() !== 'string' ) { $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 ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $message = wfMessage( 'wbqc-violation-message-security-reason' )->params( $constraint->getConstraintTypeName(), 'string' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_TODO, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_TODO, $message ); } } diff --git a/includes/ConstraintCheck/Checker/InverseChecker.php b/includes/ConstraintCheck/Checker/InverseChecker.php index 99babb2..f73164f 100644 --- a/includes/ConstraintCheck/Checker/InverseChecker.php +++ b/includes/ConstraintCheck/Checker/InverseChecker.php @@ -56,7 +56,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -76,7 +76,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -88,20 +88,20 @@ */ if ( $dataValue->getType() !== 'wikibase-entityid' ) { $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeName(), 'wikibase-entityid' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /** @var EntityIdValue $dataValue */ if ( !array_key_exists( 'property', $constraintParameters ) ) { $message = wfMessage( "wbqc-violation-message-property-needed" )->params( $constraint->getConstraintTypeName(), 'property' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $property = $constraintParameters['property']; $targetItem = $this->entityLookup->getEntity( $dataValue->getEntityId() ); if ( $targetItem === null ) { $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $targetItemStatementList = $targetItem->getStatements(); @@ -113,7 +113,7 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/ItemChecker.php b/includes/ConstraintCheck/Checker/ItemChecker.php index 105c506..bc7f8f7 100644 --- a/includes/ConstraintCheck/Checker/ItemChecker.php +++ b/includes/ConstraintCheck/Checker/ItemChecker.php @@ -54,7 +54,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -76,7 +76,7 @@ */ if ( !$property ) { $message = wfMessage( "wbqc-violation-message-property-needed" )->params( $constraint->getConstraintTypeName(), 'property' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /* @@ -102,7 +102,7 @@ } } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php b/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php index 80958d4..768dcf4 100644 --- a/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php +++ b/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php @@ -39,7 +39,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -67,7 +67,7 @@ } } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/MultiValueChecker.php b/includes/ConstraintCheck/Checker/MultiValueChecker.php index 7682742..c855591 100644 --- a/includes/ConstraintCheck/Checker/MultiValueChecker.php +++ b/includes/ConstraintCheck/Checker/MultiValueChecker.php @@ -35,7 +35,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $propertyId = $statement->getPropertyId(); $parameters = array (); @@ -50,7 +50,7 @@ $status = CheckResult::STATUS_COMPLIANCE; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/OneOfChecker.php b/includes/ConstraintCheck/Checker/OneOfChecker.php index fe735c2..58c4557 100644 --- a/includes/ConstraintCheck/Checker/OneOfChecker.php +++ b/includes/ConstraintCheck/Checker/OneOfChecker.php @@ -40,7 +40,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -62,7 +62,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, 'One of', $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, 'One of', $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -74,13 +74,13 @@ */ if ( $dataValue->getType() !== 'wikibase-entityid' ) { $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeName(), 'wikibase-entityid' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /** @var EntityIdValue $dataValue */ if ( !$items ) { $message = wfMessage( "wbqc-violation-message-property-needed" )->params( $constraint->getConstraintTypeName(), 'property' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } if ( in_array( $dataValue->getEntityId()->getSerialization(), $items ) ) { @@ -91,7 +91,7 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/QualifierChecker.php b/includes/ConstraintCheck/Checker/QualifierChecker.php index d033095..ca98bc0 100644 --- a/includes/ConstraintCheck/Checker/QualifierChecker.php +++ b/includes/ConstraintCheck/Checker/QualifierChecker.php @@ -39,9 +39,9 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $message = wfMessage( "wbqc-violation-message-qualifier" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), array (), CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), array (), CheckResult::STATUS_VIOLATION, $message ); } } diff --git a/includes/ConstraintCheck/Checker/QualifiersChecker.php b/includes/ConstraintCheck/Checker/QualifiersChecker.php index 8c467f9..1d07400 100644 --- a/includes/ConstraintCheck/Checker/QualifiersChecker.php +++ b/includes/ConstraintCheck/Checker/QualifiersChecker.php @@ -41,7 +41,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -65,7 +65,7 @@ } } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/RangeChecker.php b/includes/ConstraintCheck/Checker/RangeChecker.php index 60c6f51..8812b59 100644 --- a/includes/ConstraintCheck/Checker/RangeChecker.php +++ b/includes/ConstraintCheck/Checker/RangeChecker.php @@ -47,7 +47,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -63,7 +63,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -95,7 +95,7 @@ $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeName(), 'quantity" or "time' )->escaped(); } if ( isset( $message ) ) { - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $comparativeValue = $this->rangeCheckerHelper->getComparativeValue( $dataValue ); @@ -108,7 +108,7 @@ $status = CheckResult::STATUS_COMPLIANCE; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/SingleValueChecker.php b/includes/ConstraintCheck/Checker/SingleValueChecker.php index 3265e7a..8b2a648 100644 --- a/includes/ConstraintCheck/Checker/SingleValueChecker.php +++ b/includes/ConstraintCheck/Checker/SingleValueChecker.php @@ -35,7 +35,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $propertyId = $statement->getPropertyId(); $parameters = array (); @@ -50,7 +50,7 @@ $status = CheckResult::STATUS_COMPLIANCE; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/SymmetricChecker.php b/includes/ConstraintCheck/Checker/SymmetricChecker.php index 68d89c2..d97f164 100644 --- a/includes/ConstraintCheck/Checker/SymmetricChecker.php +++ b/includes/ConstraintCheck/Checker/SymmetricChecker.php @@ -56,7 +56,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -73,7 +73,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -84,14 +84,14 @@ */ if ( $dataValue->getType() !== 'wikibase-entityid' ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName(), 'wikibase-entityid' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /** @var EntityIdValue $dataValue */ $targetItem = $this->entityLookup->getEntity( $dataValue->getEntityId() ); if ( $targetItem === null ) { $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $targetItemStatementList = $targetItem->getStatements(); @@ -103,7 +103,7 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php index 8999461..b8efe52 100644 --- a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php +++ b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php @@ -56,7 +56,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -84,7 +84,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeName() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -96,19 +96,19 @@ */ if ( $dataValue->getType() !== 'wikibase-entityid' ) { $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeName(), 'wikibase-entityid' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /** @var EntityIdValue $dataValue */ if ( !$property ) { $message = wfMessage( "wbqc-violation-message-property-needed" )->params( $constraint->getConstraintTypeName(), 'property' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $targetEntity = $this->entityLookup->getEntity( $dataValue->getEntityId() ); if ( $targetEntity === null ) { $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $targetEntityStatementList = $targetEntity->getStatements(); @@ -135,7 +135,7 @@ } } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/TypeChecker.php b/includes/ConstraintCheck/Checker/TypeChecker.php index 62fdf47..bd375c7 100644 --- a/includes/ConstraintCheck/Checker/TypeChecker.php +++ b/includes/ConstraintCheck/Checker/TypeChecker.php @@ -57,7 +57,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -79,7 +79,7 @@ */ if ( !$classes ) { $message = wfMessage( "wbqc-violation-message-parameter-needed" )->params( $constraint->getConstraintTypeName(), 'class' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /* @@ -92,7 +92,7 @@ $relationId = self::subclassId; } else { $message = wfMessage( "wbqc-violation-message-type-relation-instance-or-subclass" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } if ( $this->typeCheckerHelper->hasClassInRelation( $entity->getStatements(), $relationId, $classes ) ) { @@ -103,7 +103,7 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/Checker/UniqueValueChecker.php b/includes/ConstraintCheck/Checker/UniqueValueChecker.php index b6c46bc..396ddef 100644 --- a/includes/ConstraintCheck/Checker/UniqueValueChecker.php +++ b/includes/ConstraintCheck/Checker/UniqueValueChecker.php @@ -36,11 +36,11 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); - $message = wfMessage( "wbqc-violation-message-not-yet-implemented" )->params( $constraint->getConstraintTypeName(), 'string' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_TODO, $message ); + $message = wfMessage( "wbqc-violation-message-not-yet-implemented" )->params( $constraint->getConstraintTypeName() )->escaped(); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_TODO, $message ); } } diff --git a/includes/ConstraintCheck/Checker/ValueTypeChecker.php b/includes/ConstraintCheck/Checker/ValueTypeChecker.php index 7f66399..acec3b6 100644 --- a/includes/ConstraintCheck/Checker/ValueTypeChecker.php +++ b/includes/ConstraintCheck/Checker/ValueTypeChecker.php @@ -59,7 +59,7 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ) { + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ) { $parameters = array (); $constraintParameters = $constraint->getConstraintParameters(); @@ -87,7 +87,7 @@ */ if ( !$mainSnak instanceof PropertyValueSnak ) { $message = wfMessage( "wbqc-violation-message-value-needed" )->params( $constraint->getConstraintTypeQid() )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $dataValue = $mainSnak->getDataValue(); @@ -99,13 +99,13 @@ */ if ( $dataValue->getType() !== 'wikibase-entityid' ) { $message = wfMessage( "wbqc-violation-message-value-needed-of-type" )->params( $constraint->getConstraintTypeQid(), 'wikibase-entityid' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /** @var EntityIdValue $dataValue */ if ( !$classes ) { $message = wfMessage( "wbqc-violation-message-parameter-needed" )->params( $constraint->getConstraintTypeQid(), 'class' )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } /* @@ -118,14 +118,14 @@ $relationId = self::subclassId; } else { $message = wfMessage( "wbqc-violation-message-type-relation-instance-or-subclass" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $item = $this->entityLookup->getEntity( $dataValue->getEntityId() ); if ( !( $item instanceof StatementListProvider ) ) { $message = wfMessage( "wbqc-violation-message-value-entity-must-exist" )->escaped(); - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, CheckResult::STATUS_VIOLATION, $message ); } $statements = $item->getStatements(); @@ -138,7 +138,7 @@ $status = CheckResult::STATUS_VIOLATION; } - return new CheckResult( $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), $parameters, $status, $message ); } } diff --git a/includes/ConstraintCheck/ConstraintChecker.php b/includes/ConstraintCheck/ConstraintChecker.php index a6638c0..59fd0dd 100644 --- a/includes/ConstraintCheck/ConstraintChecker.php +++ b/includes/ConstraintCheck/ConstraintChecker.php @@ -17,6 +17,6 @@ * * @return CheckResult */ - public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity = null ); + public function checkConstraint( Statement $statement, Constraint $constraint, EntityDocument $entity ); } diff --git a/includes/ConstraintCheck/DelegatingConstraintChecker.php b/includes/ConstraintCheck/DelegatingConstraintChecker.php index 20bdab1..0735ede 100644 --- a/includes/ConstraintCheck/DelegatingConstraintChecker.php +++ b/includes/ConstraintCheck/DelegatingConstraintChecker.php @@ -117,7 +117,7 @@ $parameter = $constraint->getConstraintParameters(); if ( array_key_exists( 'known_exception', $parameter) && in_array( $entity->getId()->getSerialization(), explode( ',', $parameter['known_exception'] ) ) ) { $message = 'This entity is a known exception for this constraint and has been marked as such.'; - $result[] = new CheckResult( $statement, $constraint->getConstraintTypeQid(), array (), CheckResult::STATUS_EXCEPTION, $message ); // todo: display parameters anyway + $result[] = new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid(), array (), CheckResult::STATUS_EXCEPTION, $message ); // todo: display parameters anyway continue; } @@ -149,7 +149,7 @@ return $result; } else { - return new CheckResult( $statement, $constraint->getConstraintTypeQid() ); + return new CheckResult( $entity, $statement, $constraint->getConstraintTypeQid() ); } } diff --git a/includes/ConstraintCheck/Result/CheckResult.php b/includes/ConstraintCheck/Result/CheckResult.php index d5bdd8d..c93accf 100644 --- a/includes/ConstraintCheck/Result/CheckResult.php +++ b/includes/ConstraintCheck/Result/CheckResult.php @@ -5,6 +5,7 @@ use DataValues\DataValue; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Statement\Statement; +use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\PropertyId; use LogicException; @@ -22,6 +23,11 @@ const STATUS_VIOLATION = 'violation'; const STATUS_EXCEPTION = 'exception'; const STATUS_TODO = 'todo'; + + /** + * @var EntityDocument + */ + private $entity; /** * @var Statement @@ -50,13 +56,15 @@ private $message; /** + * @param EntityDocument $entity * @param Statement $statement * @param string $constraintName * @param array $parameters (string => string[]) * @param string $status * @param string $message (sanitized HTML) */ - public function __construct( Statement $statement, $constraintName, $parameters = array (), $status = self::STATUS_TODO, $message = '' ) { + public function __construct( EntityDocument $entity, Statement $statement, $constraintName, $parameters = array (), $status = self::STATUS_TODO, $message = '' ) { + $this->entity = $entity; $this->statement = $statement; $this->constraintName = $constraintName; $this->parameters = $parameters; @@ -65,6 +73,13 @@ } /** + * @return EntityDocument + */ + public function getEntity() { + return $this->entity; + } + + /** * @return Statement */ public function getStatement() { diff --git a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php index 156d888..a805dfa 100644 --- a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php +++ b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php @@ -7,6 +7,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; +use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\Constraint; @@ -38,16 +39,23 @@ */ private $commonsLinkChecker; + /** + * @var EntityDocument Required parameter of checkConstraint (unused by this checker) + */ + private $entity; + protected function setUp() { parent::setUp(); $this->helper = new ConstraintParameterParser(); $this->commonsLinkChecker = new CommonsLinkChecker( $this->helper ); $this->tablesUsed[] = 'image'; + $this->entity = new Item( new ItemId( 'Q1' ) ); } protected function tearDown() { unset( $this->helper ); unset( $this->commonsLinkChecker ); + unset( $this->entity ); parent::tearDown(); } @@ -75,7 +83,7 @@ public function testCommonsLinkConstraintValid() { $value = new StringValue( 'test image.jpg' ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ); - $this->assertEquals( 'compliance', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should comply' ); + $this->assertEquals( 'compliance', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should comply' ); } public function testCommonsLinkConstraintInvalid() { @@ -85,36 +93,36 @@ $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value1 ) ); $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value2 ) ); $statement3 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value3 ) ); - $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement3, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement3, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testNotImplementedNamespaces() { $value = new StringValue( 'test image.jpg' ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ); - $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array() ) )->getStatus(), 'check is not implemented' ); - $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Gallery') ) )->getStatus(), 'check is not implemented' ); - $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Institution') ) )->getStatus(), 'check is not implemented' ); - $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Museum') ) )->getStatus(), 'check is not implemented' ); - $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Creator') ) )->getStatus(), 'check is not implemented' ); + $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array() ), $this->entity )->getStatus(), 'check is not implemented' ); + $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Gallery') ), $this->entity )->getStatus(), 'check is not implemented' ); + $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Institution') ), $this->entity )->getStatus(), 'check is not implemented' ); + $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Museum') ), $this->entity )->getStatus(), 'check is not implemented' ); + $this->assertEquals( 'todo', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'Creator') ), $this->entity )->getStatus(), 'check is not implemented' ); } public function testCommonsLinkConstraintNotExistent() { $value = new StringValue( 'no image.jpg' ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ); - $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testCommonsLinkConstraintNoStringValue() { $value = new EntityIdValue( new ItemId( 'Q1' ) ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ); - $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testCommonsLinkConstraintNoValueSnak() { $statement = new Statement( new PropertyNoValueSnak( 1 ) ); - $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ), $this->entity )->getStatus(), 'check should not comply' ); } /** diff --git a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php index b1468ca..310f71d 100644 --- a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php @@ -6,6 +6,7 @@ use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; +use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; @@ -48,12 +49,18 @@ */ private $checker; + /** + * @var EntityDocument Required parameter of checkConstraint (unused by this checker) + */ + private $entity; + protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); $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' ) ); } protected function tearDown() { @@ -61,6 +68,7 @@ unset( $this->helper ); unset( $this->connectionCheckerHelper ); unset( $this->checker ); + unset( $this->entity ); parent::tearDown(); } @@ -72,7 +80,7 @@ 'property' => 'P2', 'item' => 'Q42' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -84,7 +92,7 @@ 'property' => 'P2', 'item' => 'Q2' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -95,7 +103,7 @@ $constraintParameters = array( 'property' => 'P2' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -106,7 +114,7 @@ $constraintParameters = array( 'property' => 'P3' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -115,7 +123,7 @@ $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array(); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -126,7 +134,7 @@ $constraintParameters = array( 'property' => 'P2' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -137,7 +145,7 @@ $constraintParameters = array( 'property' => 'P2' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -147,7 +155,7 @@ $constraintParameters = array( 'property' => 'P2' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php index f2601dc..44f6c3e 100644 --- a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php +++ b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php @@ -7,6 +7,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; +use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\Constraint; @@ -36,15 +37,22 @@ */ private $formatChecker; + /** + * @var EntityDocument Required parameter of checkConstraint (unused by this checker) + */ + private $entity; + protected function setUp() { parent::setUp(); $this->helper = new ConstraintParameterParser(); $this->formatChecker = new FormatChecker( $this->helper ); + $this->entity = new Item( new ItemId( 'Q1' ) ); } protected function tearDown() { unset( $this->helper ); unset( $this->formatChecker ); + unset( $this->entity ); parent::tearDown(); } @@ -73,16 +81,16 @@ $statement9 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value9 ) ); $statement10 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value10 ) ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement3, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement4, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement5, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement6, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement7, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement8, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement9, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement10, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement3, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement4, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement5, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement6, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement7, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement8, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement9, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement10, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testFormatConstraintTaxonName() { @@ -110,36 +118,36 @@ $statement9 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value9 ) ); $statement10 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value10 ) ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement3, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement4, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement5, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement6, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement7, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement8, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement9, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement10, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement3, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement4, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement5, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement6, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement7, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement8, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement9, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement10, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testFormatConstraintEmptyPattern() { $pattern = null; $value = new StringValue( 'Populus × canescens' ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value ) ); - $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'todo', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testFormatConstraintNoStringValue() { $pattern = "(|somevalue|novalue|.*virus.*|.*viroid.*|.*phage.*|((×)?[A-Z]([a-z]+-)?[a-z]+(( [A-Z]?[a-z]+)|( ([a-z]+-)?([a-z]+-)?[a-z]+)|( ×([a-z]+-)?([a-z]+-)?([a-z]+-)?([a-z]+-)?[a-z]+)|( \([A-Z][a-z]+\) [a-z]+)|( (‘|')[A-Z][a-z]+(('|’)s)?( de)?( [A-Z][a-z]+(-([A-Z])?[a-z]+)*)*('|’)*)|( ×| Group| (sub)?sp\.| (con)?(sub)?(notho)?var\.| (sub)?ser\.| (sub)?sect\.| subg\.| (sub)?f\.))*))"; $value = new EntityIdValue( new ItemId( 'Q1' ) ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value ) ); - $this->assertEquals( 'violation', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testFormatConstraintNoValueSnak() { $pattern = "."; $statement = new Statement( new PropertyNoValueSnak( 1 ) ); - $this->assertEquals( 'violation', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ), $this->entity )->getStatus(), 'check should not comply' ); } /** diff --git a/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php b/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php index e88f679..ec0838c 100644 --- a/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php +++ b/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php @@ -7,6 +7,7 @@ use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; +use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\Constraint; @@ -36,14 +37,21 @@ */ private $oneOfChecker; + /** + * @var EntityDocument Required parameter of checkConstraint (unused by this checker) + */ + private $entity; + protected function setUp() { parent::setUp(); $this->helper = new ConstraintParameterParser(); $this->oneOfChecker = new OneOfChecker( $this->helper ); + $this->entity = new Item( new ItemId( 'Q1' ) ); } protected function tearDown() { unset( $this->helper, $this->oneOfChecker ); + unset( $this->entity ); parent::tearDown(); } @@ -56,34 +64,34 @@ $values = 'Q1,Q2,Q3'; - $this->assertEquals( 'compliance', $this->oneOfChecker->checkConstraint( $statementIn, $this->getConstraintMock( array( 'item' => $values ) ) )->getStatus(), 'check should comply' ); - $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statementNotIn, $this->getConstraintMock( array( 'item' => $values ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'compliance', $this->oneOfChecker->checkConstraint( $statementIn, $this->getConstraintMock( array( 'item' => $values ) ), $this->entity )->getStatus(), 'check should comply' ); + $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statementNotIn, $this->getConstraintMock( array( 'item' => $values ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testOneOfConstraintWrongType() { $value = new StringValue( 'Q1' ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ); $values = 'Q1,Q2,Q3'; - $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'item' => $values ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'item' => $values ) ), $this->entity )->getStatus(), 'check should not comply' ); } public function testOneOfConstraintEmptyArray() { $value = new EntityIdValue( new ItemId( 'Q1' ) ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ); - $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array() ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array() ), $this->entity )->getStatus(), 'check should not comply' ); } public function testOneOfConstraintArrayWithSomevalue() { $value = new EntityIdValue( new ItemId( 'Q1' ) ); $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ); $values = 'Q1,Q2,Q3,somevalue'; - $this->assertEquals( 'compliance', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'item' => $values ) ) )->getStatus(), 'check should comply' ); + $this->assertEquals( 'compliance', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'item' => $values ) ), $this->entity )->getStatus(), 'check should comply' ); } public function testOneOfConstraintNoValueSnak() { $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $values = 'Q1,Q2,Q3,somevalue'; - $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'item' => $values ) ) )->getStatus(), 'check should not comply' ); + $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'item' => $values ) ), $this->entity )->getStatus(), 'check should not comply' ); } /** diff --git a/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php b/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php index 5f6a53f..4b0a84b 100644 --- a/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php +++ b/tests/phpunit/Checker/QualifierChecker/MandatoryQualifiersCheckerTest.php @@ -60,7 +60,7 @@ /** @var Item $entity */ $entity = $this->lookup->getEntity( new ItemId( 'Q5' ) ); $qualifierChecker = new MandatoryQualifiersChecker( $this->helper ); - $checkResult = $qualifierChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => 'P2' ) ) ); + $checkResult = $qualifierChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => 'P2' ) ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -68,7 +68,7 @@ /** @var Item $entity */ $entity = $this->lookup->getEntity( new ItemId( 'Q5' ) ); $qualifierChecker = new MandatoryQualifiersChecker( $this->helper ); - $checkResult = $qualifierChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => 'P2,P3' ) ) ); + $checkResult = $qualifierChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => 'P2,P3' ) ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php index e0959d8..b575d46 100644 --- a/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php +++ b/tests/phpunit/Checker/QualifierChecker/QualifierCheckerTest.php @@ -60,7 +60,7 @@ /** @var Item $entity */ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $qualifierChecker = new QualifierChecker( $this->helper ); - $checkResult = $qualifierChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array() ) ); + $checkResult = $qualifierChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php b/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php index ba30bd7..38c89d7 100644 --- a/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php +++ b/tests/phpunit/Checker/QualifierChecker/QualifiersCheckerTest.php @@ -67,7 +67,7 @@ /** @var Item $entity */ $entity = $this->lookup->getEntity( new ItemId( 'Q2' ) ); $qualifiersChecker = new QualifiersChecker( $this->helper ); - $checkResult = $qualifiersChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => $this->qualifiersList ) ) ); + $checkResult = $qualifiersChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => $this->qualifiersList ) ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -75,7 +75,7 @@ /** @var Item $entity */ $entity = $this->lookup->getEntity( new ItemId( 'Q3' ) ); $qualifiersChecker = new QualifiersChecker( $this->helper ); - $checkResult = $qualifiersChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => $this->qualifiersList ) ) ); + $checkResult = $qualifiersChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => $this->qualifiersList ) ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -83,7 +83,7 @@ /** @var Item $entity */ $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) ); $qualifiersChecker = new QualifiersChecker( $this->helper ); - $checkResult = $qualifiersChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => $this->qualifiersList ) ) ); + $checkResult = $qualifiersChecker->checkConstraint( $this->getFirstStatement( $entity ), $this->getConstraintMock( array( 'property' => $this->qualifiersList ) ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php index aa8bb84..a282034 100644 --- a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php +++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php @@ -9,6 +9,8 @@ use DataValues\QuantityValue; use DataValues\StringValue; use DataValues\TimeValue; +use Wikibase\DataModel\Entity\Item; +use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use WikibaseQuality\ConstraintReport\Constraint; use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker; @@ -49,12 +51,18 @@ */ private $checker; + /** + * @var EntityDocument Required parameter of checkConstraint (unused by this checker) + */ + private $entity; + protected function setUp() { parent::setUp(); $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() ); + $this->entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); } protected function tearDown() { @@ -62,6 +70,7 @@ unset( $this->lookup ); unset( $this->timeValue ); unset( $this->checker ); + unset( $this->entity ); parent::tearDown(); } @@ -72,7 +81,7 @@ 'minimum_quantity' => 0, 'maximum_quantity' => 10 ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -83,7 +92,7 @@ 'minimum_quantity' => 100, 'maximum_quantity' => 1000 ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -94,7 +103,7 @@ 'minimum_quantity' => 0, 'maximum_quantity' => 1 ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -106,7 +115,7 @@ 'minimum_date' => $min, 'maximum_date' => $max ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -118,7 +127,7 @@ 'minimum_date' => $min, 'maximum_date' => $max ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -130,7 +139,7 @@ 'minimum_date' => $min, 'maximum_date' => $max ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -142,7 +151,7 @@ 'minimum_quantity' => $min, 'maximum_date' => $max ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -154,7 +163,7 @@ 'minimum_quantity' => $min, 'maximum_date' => $max ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -166,14 +175,14 @@ 'minimum_date' => $min, 'maximum_date' => $max ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } public function testRangeConstraintNoValueSnak() { $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $constraintParameters = array(); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php index 08fdc41..94142cd 100644 --- a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php +++ b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php @@ -4,6 +4,7 @@ use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Snak\PropertyValueSnak; +use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; @@ -43,17 +44,24 @@ */ private $valueTypePropertyId; + /** + * @var EntityDocument Required parameter of checkConstraint (unused by this checker) + */ + private $entity; + protected function setUp() { parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); $this->checker = new ValueTypeChecker( $this->lookup, new ConstraintParameterParser(), new TypeCheckerHelper( $this->lookup ) ); $this->valueTypePropertyId = new PropertyId( 'P1234' ); + $this->entity = $this->lookup->getEntity( new ItemId ( 'Q1' ) ); } protected function tearDown() { unset( $this->lookup ); unset( $this->valueTypePropertyId ); unset( $this->valueTypeTypeChecker ); + unset( $this->entity ); parent::tearDown(); } @@ -64,7 +72,7 @@ 'relation' => 'instance', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -74,7 +82,7 @@ 'relation' => 'instance', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -84,7 +92,7 @@ 'relation' => 'instance', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -95,7 +103,7 @@ 'relation' => 'subclass', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -105,7 +113,7 @@ 'relation' => 'subclass', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -115,7 +123,7 @@ 'relation' => 'subclass', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } @@ -126,7 +134,7 @@ 'relation' => 'instance', 'class' => 'Q200,Q201' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -136,7 +144,7 @@ 'relation' => 'instance', 'class' => 'Q200,Q201' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -146,7 +154,7 @@ 'relation' => 'instance', 'class' => 'Q200,Q201' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -157,7 +165,7 @@ 'relation' => 'subclass', 'class' => 'Q200,Q201' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -167,7 +175,7 @@ 'relation' => 'subclass', 'class' => 'Q200,Q201' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -177,7 +185,7 @@ 'relation' => 'subclass', 'class' => 'Q200,Q201' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -187,7 +195,7 @@ $constraintParameters = array( 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -196,7 +204,7 @@ $constraintParameters = array( 'relation' => 'instance' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -206,7 +214,7 @@ 'relation' => 'instance', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -216,7 +224,7 @@ 'relation' => 'instance', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } @@ -226,7 +234,7 @@ 'relation' => 'instance', 'class' => 'Q100,Q101' ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php index c8e3527..6920e02 100644 --- a/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php @@ -4,6 +4,7 @@ use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Snak\PropertyValueSnak; +use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Entity\EntityIdValue; @@ -46,8 +47,10 @@ // todo: it is currently only testing that 'todo' comes back public function testCheckUniqueValueConstraint() { - $statement = new Statement( new PropertyValueSnak( $this->uniquePropertyId, new EntityIdValue( new ItemId( 'Q404' ) ) ) ); - $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ) ); + $itemId = new ItemId( 'Q404' ); + $entity = new Item( $itemId ); + $statement = new Statement( new PropertyValueSnak( $this->uniquePropertyId, new EntityIdValue( $itemId ) ) ); + $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'todo', $checkResult->getStatus(), 'check should point out that it should be implemented soon' ); } diff --git a/tests/phpunit/Fake/FakeChecker.php b/tests/phpunit/Fake/FakeChecker.php index 9a9a797..ab605d8 100644 --- a/tests/phpunit/Fake/FakeChecker.php +++ b/tests/phpunit/Fake/FakeChecker.php @@ -27,10 +27,10 @@ public function checkConstraint( Statement $statement, Constraint $constraint, - EntityDocument $entity = null + EntityDocument $entity ) { return new CheckResult( - $statement, $constraint->getConstraintTypeQid(), [], $this->status + $entity, $statement, $constraint->getConstraintTypeQid(), [], $this->status ); } } diff --git a/tests/phpunit/Fake/FakeCheckerTest.php b/tests/phpunit/Fake/FakeCheckerTest.php index 4dc8ed0..b960d74 100644 --- a/tests/phpunit/Fake/FakeCheckerTest.php +++ b/tests/phpunit/Fake/FakeCheckerTest.php @@ -2,6 +2,7 @@ namespace WikibaseQuality\ConstraintReport\Tests\Fake; +use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Statement\Statement; use WikibaseQuality\ConstraintReport\Constraint; @@ -14,7 +15,8 @@ $statement = $this->dummy( Statement::class ); $result = $checker->checkConstraint( $statement, - $this->dummy( Constraint::class ) + $this->dummy( Constraint::class ), + $this->dummy( Item::class ) ); $this->assertSame( $statement, $result->getStatement() ); @@ -26,7 +28,8 @@ $constraintTypeId = 'constraint id'; $result = $checker->checkConstraint( $this->dummy( Statement::class ), - new Constraint( 'some guid', $this->dummy( PropertyId::class ), $constraintTypeId, [] ) + new Constraint( 'some guid', $this->dummy( PropertyId::class ), $constraintTypeId, [] ), + $this->dummy( Item::class ) ); $this->assertSame( $constraintTypeId, $result->getConstraintName() ); @@ -38,7 +41,8 @@ $checker = new FakeChecker( $expectedStatus ); $result = $checker->checkConstraint( $this->dummy( Statement::class ), - $this->dummy( Constraint::class ) + $this->dummy( Constraint::class ), + $this->dummy( Item::class ) ); $this->assertSame( $expectedStatus, $result->getStatus() ); diff --git a/tests/phpunit/Result/CheckResultTest.php b/tests/phpunit/Result/CheckResultTest.php index 2cb2e54..bbca65f 100644 --- a/tests/phpunit/Result/CheckResultTest.php +++ b/tests/phpunit/Result/CheckResultTest.php @@ -7,6 +7,8 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; use Wikibase\DataModel\Snak\PropertyValueSnak; +use Wikibase\DataModel\Entity\Item; +use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; use DataValues\StringValue; use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult; @@ -19,6 +21,11 @@ * @license GNU GPL v2+ */ class CheckResultTest extends PHPUnit_Framework_TestCase { + + /** + * @var EntityDocument + */ + private $entity; /** * @var Statement @@ -47,6 +54,7 @@ protected function setUp() { parent::setUp(); + $this->entity = new Item( new ItemId( 'Q1' ) ); $this->statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new StringValue( 'Foo' ) ) ); $this->constraintName = 'Range'; $this->parameters = array (); @@ -56,6 +64,7 @@ protected function tearDown() { parent::tearDown(); + unset( $this->entity ); unset( $this->statement ); unset( $this->constraintName ); unset( $this->parameters ); @@ -64,7 +73,8 @@ } public function testConstructAndGetters() { - $checkResult = new CheckResult( $this->statement, $this->constraintName, $this->parameters, $this->status, $this->message ); + $checkResult = new CheckResult( $this->entity, $this->statement, $this->constraintName, $this->parameters, $this->status, $this->message ); + $this->assertEquals( $this->entity, $checkResult->getEntity() ); $this->assertEquals( $this->statement, $checkResult->getStatement() ); $this->assertEquals( $this->statement->getPropertyId(), $checkResult->getPropertyId() ); $this->assertEquals( $this->statement->getMainSnak()->getDataValue(), $checkResult->getDataValue() ); @@ -76,7 +86,7 @@ } public function testWithWrongSnakType() { - $checkResult = new CheckResult( new Statement( new PropertyNoValueSnak( 1 ) ), $this->constraintName, $this->parameters, $this->status, $this->message ); + $checkResult = new CheckResult( $this->entity, new Statement( new PropertyNoValueSnak( 1 ) ), $this->constraintName, $this->parameters, $this->status, $this->message ); $this->setExpectedException( LogicException::class ); $checkResult->getDataValue(); } -- To view, visit https://gerrit.wikimedia.org/r/346977 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06d1256dc9c09e390aaf1367d40b5b1890c2142f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits