Lucas Werkmeister (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/369623 )
Change subject: Skip novalue/somevalue instead of reporting violation
......................................................................
Skip novalue/somevalue instead of reporting violation
Checkers that use the value of a statement previously reported a
violation for novalue/somevalue statements. This is rarely appropriate,
since semantically, those values should usually be accepted – the
constraints simply don’t apply in those cases. The checkers are updated
to return a compliance result in those cases instead of a violation, and
tests for the old behavior are updated to expect compliance instead.
DiffWithinRangeChecker also reported a violation if the statement of the
referenced property was novalue/somevalue; instead, it skips those
statements now, and either uses the first value statement it finds or
reports a violation due to missing statement otherwise. Tests are added
for this behavior.
Tests for CommonsLinkChecker and FormatChecker used to use novalue
statements to test that those checkers still check deprecated
statements; they have been changed to check actual statements that
violate constraints.
Two messages that are no longer used (generic “must have a value” and
DiffWithinRangeChecker-specific “referenced property must have a value”)
are removed.
Bug: T172130
Change-Id: I8bb33ead10770c938d04b00dd637924d4599a752
---
M i18n/en.json
M i18n/qqq.json
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/RangeChecker.php
M includes/ConstraintCheck/Checker/SymmetricChecker.php
M includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
M includes/ConstraintCheck/Checker/ValueTypeChecker.php
M tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
M tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.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/RangeChecker/DiffWithinRangeCheckerTest.php
M tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
18 files changed, 66 insertions(+), 101 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
refs/changes/23/369623/1
diff --git a/i18n/en.json b/i18n/en.json
index bce0d22..4462bea 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -65,7 +65,6 @@
"wbqc-violation-message-not-yet-implemented": "For technical reasons,
the check for the constraint \"$1\" has not yet been implemented.",
"wbqc-violation-message-security-reason": "For security reasons, it is
not possible to check the \"$1\" constraint at the moment. We are working on a
solution.",
- "wbqc-violation-message-value-needed": "Properties with constraint
\"$1\" need to have a value.",
"wbqc-violation-message-value-needed-of-type": "Properties with
constraint \"$1\" need to have values of type \"$2\".",
"wbqc-violation-message-value-needed-of-types-2": "Properties with
constraint \"$1\" need to have values of type \"$2\" or \"$3\".",
"wbqc-violation-message-parameter-needed": "Properties with constraint
\"$1\" need a parameter \"$2\".",
@@ -94,7 +93,6 @@
"wbqc-violation-message-diff-within-range-leftopen": "The difference
between $3 ($4) and $1 ($2) should be no more than $5 ((−∞; $5]).",
"wbqc-violation-message-diff-within-range-rightopen": "The difference
between $3 ($4) and $1 ($2) should be no less than $5 ([$5; ∞)).",
"wbqc-violation-message-diff-within-range-property-must-exist": "The
property defined in the parameters must exist.",
- "wbqc-violation-message-diff-within-range-property-needs value": "The
property defined in the parameters needs to have a value.",
"wbqc-violation-message-diff-within-range-must-have-equal-types": "The
property defined in the parameters must have a value of the same type as this
property.",
"wbqc-violation-message-format": "The value for $1 ($2) should match
the pattern $3.",
"wbqc-violation-message-inverse": "$1 should also have the inverse
statement $2 $3.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 06b593b..90a81d1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -62,7 +62,6 @@
"wbqc-violation-message": "Generic message to tell that there was a
violation.",
"wbqc-violation-message-not-yet-implemented": "Message for when a check
is yet to be implemented. Not actually a violation, more of a todo.",
"wbqc-violation-message-security-reason": "Message for when a check is
not possible due to security reasons. Not actually a violation, more of a
todo.",
- "wbqc-violation-message-value-needed": "Message for when a property
needs a value (rather than no or some value), but hasn't.",
"wbqc-violation-message-value-needed-of-type": "Message for when a
property needs a value of a specific type (like string or wikibase-entityid),
but it doesn't.",
"wbqc-violation-message-value-needed-of-types-2": "Message for when a
property needs a value of one of two specific types (like string or
wikibase-entityid), but it doesn't.",
"wbqc-violation-message-parameter-needed": "Message for when a
constraint needs a specific parameter, but it's missing.",
@@ -90,7 +89,6 @@
"wbqc-violation-message-diff-within-range-leftopen": "Message for a
violation of the “Diff within range” constraint, when the difference between
two values is larger than allowed (for a range with an upper but no lower
limit). Parameters:\n* $1 is the first property.\n* $2 is the value of the
first property.\n* $3 is the second property.\n* $4 is the value of the second
property.\n* $5 is the upper bound of the range (inclusive).\nThe “first
property” is the one referenced in the constraint, and the “second property” is
the one that the constraint is placed on. The difference is calculated as
“second property” − “first property” ($4 −
$2).\n{{Related|wbqc-violation-message-diff-within-range}}",
"wbqc-violation-message-diff-within-range-rightopen": "Message for a
violation of the “Diff within range” constraint, when the difference between
two values is larger than allowed (for a range with a lower but no upper
limit). Parameters:\n* $1 is the first property.\n* $2 is the value of the
first property.\n* $3 is the second property.\n* $4 is the value of the second
property.\n* $5 is the lower bound of the range (inclusive).\nThe “first
property” is the one referenced in the constraint, and the “second property” is
the one that the constraint is placed on. The difference is calculated as
“second property” − “first property” ($4 −
$2).\n{{Related|wbqc-violation-message-diff-within-range}}",
"wbqc-violation-message-diff-within-range-property-must-exist":
"Message for violation of Diff within range constraint. When given property
does not exist (any more).",
- "wbqc-violation-message-diff-within-range-property-needs value":
"Message for violation of Diff within range constraint. When given property
does not have a value.",
"wbqc-violation-message-diff-within-range-must-have-equal-types":
"Message for violation of Diff within range constraint. When this and the given
property differ in value type.",
"wbqc-violation-message-format": "Message for a violation of the
“Format” constraint, when the value of a statement does not match a certain
pattern. Parameters:\n* $1 is the property of the statement that has the
constraint.\n* $2 is the text value of the statement.\n* $3 is the pattern.",
"wbqc-violation-message-inverse": "Message for a violation of the
“Inverse” constraint, when the inverse statement of a statement does not exist.
$1, $2 and $3 contain the expected subject entity, property, and target entity
of the missing inverse statement.",
diff --git a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
index 0a81ff7..a60c05a 100644
--- a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
+++ b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
@@ -71,15 +71,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index bd5050e..df06ecb 100644
--- a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -93,15 +93,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
@@ -111,28 +105,14 @@
// checks only the first occurrence of the referenced property
(this constraint implies a single value constraint on that property)
/** @var Statement $otherStatement */
foreach ( $entity->getStatements() as $otherStatement ) {
- if ( $otherStatement->getRank() ===
Statement::RANK_DEPRECATED
- || !$property->equals(
$otherStatement->getPropertyId() )
- ) {
- continue;
- }
-
$otherMainSnak = $otherStatement->getMainSnak();
- /*
- * error handling:
- * types of this and the other value have to be
equal, both must contain actual values
- */
- if ( !$otherMainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-diff-within-range-property-needs value" )->escaped();
- return new CheckResult(
- $entity->getId(),
- $otherStatement,
- $constraint,
- $parameters,
- CheckResult::STATUS_VIOLATION,
- $message
- );
+ if (
+ !$property->equals(
$otherStatement->getPropertyId() ) ||
+ $otherStatement->getRank() ===
Statement::RANK_DEPRECATED ||
+ !$otherMainSnak instanceof PropertyValueSnak
+ ) {
+ continue;
}
if ( $otherMainSnak->getDataValue()->getType() ===
$dataValue->getType() ) {
diff --git a/includes/ConstraintCheck/Checker/FormatChecker.php
b/includes/ConstraintCheck/Checker/FormatChecker.php
index 479bfd9..d3d3de7 100644
--- a/includes/ConstraintCheck/Checker/FormatChecker.php
+++ b/includes/ConstraintCheck/Checker/FormatChecker.php
@@ -80,15 +80,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git a/includes/ConstraintCheck/Checker/InverseChecker.php
b/includes/ConstraintCheck/Checker/InverseChecker.php
index a822262..d355d0b 100644
--- a/includes/ConstraintCheck/Checker/InverseChecker.php
+++ b/includes/ConstraintCheck/Checker/InverseChecker.php
@@ -84,15 +84,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git a/includes/ConstraintCheck/Checker/RangeChecker.php
b/includes/ConstraintCheck/Checker/RangeChecker.php
index 7919a2a..6217a35 100644
--- a/includes/ConstraintCheck/Checker/RangeChecker.php
+++ b/includes/ConstraintCheck/Checker/RangeChecker.php
@@ -80,15 +80,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git a/includes/ConstraintCheck/Checker/SymmetricChecker.php
b/includes/ConstraintCheck/Checker/SymmetricChecker.php
index e881423..1460c12 100644
--- a/includes/ConstraintCheck/Checker/SymmetricChecker.php
+++ b/includes/ConstraintCheck/Checker/SymmetricChecker.php
@@ -71,15 +71,9 @@
$mainSnak = $statement->getMainSnak();
$propertyId = $statement->getPropertyId();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
index 2667c43..caca406 100644
--- a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
+++ b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
@@ -87,15 +87,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git a/includes/ConstraintCheck/Checker/ValueTypeChecker.php
b/includes/ConstraintCheck/Checker/ValueTypeChecker.php
index cc2ae5d..cf84af2 100644
--- a/includes/ConstraintCheck/Checker/ValueTypeChecker.php
+++ b/includes/ConstraintCheck/Checker/ValueTypeChecker.php
@@ -110,15 +110,9 @@
$mainSnak = $statement->getMainSnak();
- /*
- * error handling:
- * $mainSnak must be PropertyValueSnak, neither
PropertySomeValueSnak nor PropertyNoValueSnak is allowed
- */
if ( !$mainSnak instanceof PropertyValueSnak ) {
- $message = wfMessage(
"wbqc-violation-message-value-needed" )
- ->rawParams(
$this->constraintParameterRenderer->formatItemId(
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
- ->escaped();
- return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
+ // nothing to check
+ return new CheckResult( $entity->getId(), $statement,
$constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
}
$dataValue = $mainSnak->getDataValue();
diff --git
a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
index 6521542..238cfb3 100644
--- a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
+++ b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php
@@ -178,11 +178,12 @@
$this->getConstraintMock( $this->namespaceParameter(
'File' ) ),
$this->getEntity()
);
- $this->assertViolation( $result,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $result );
}
public function testCommonsLinkConstraintDeprecatedStatement() {
- $statement = NewStatement::noValueFor( 'P1' )
+ $statement = NewStatement::forProperty( 'P1' )
+ ->withValue( 'not_well formed' )
->withDeprecatedRank()
->build();
$constraint = $this->getConstraintMock( [] );
@@ -192,7 +193,7 @@
$checkResult = $this->commonsLinkChecker->checkConstraint(
$statement, $constraint, $entity );
// this constraint is still checked on deprecated statements
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertViolation( $checkResult,
'wbqc-violation-message-commons-link-not-well-formed' );
}
public function testCheckConstraintParameters() {
diff --git a/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php
b/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php
index 9c942f8..449640b 100644
--- a/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php
+++ b/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php
@@ -151,7 +151,7 @@
'property' => 'P1'
];
$checkResult = $this->checker->checkConstraint( $statement,
$this->getConstraintMock( $constraintParameters ), $entity );
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $checkResult );
}
public function testInverseConstraintDeprecatedStatement() {
diff --git a/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php
b/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php
index 75161d9..a9d8012 100644
--- a/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php
+++ b/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php
@@ -107,7 +107,7 @@
$statement = new Statement( new PropertyNoValueSnak( 1 ) );
$checkResult = $this->checker->checkConstraint( $statement,
$this->getConstraintMock(), $this->getEntity() );
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $checkResult );
}
public function testSymmetricConstraintDeprecatedStatement() {
diff --git
a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php
b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php
index 0818db6..2b1815e 100644
--- a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php
+++ b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php
@@ -138,7 +138,7 @@
'property' => 'P2'
];
$checkResult = $this->checker->checkConstraint( $statement,
$this->getConstraintMock( $constraintParameters ), $this->getEntity() );
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $checkResult );
}
public function testTargetRequiredClaimConstraintWithStatement() {
diff --git a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php
b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php
index 31c8475..e001cdc 100644
--- a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php
+++ b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php
@@ -289,7 +289,7 @@
$this->getConstraintMock( $this->formatParameter(
$pattern ) ),
$this->getEntity()
);
- $this->assertEquals( 'violation', $result->getStatus(), 'check
should not comply' );
+ $this->assertCompliance( $result );
}
public function testFormatConstraintWithoutSparql() {
@@ -336,17 +336,18 @@
}
public function testFormatConstraintDeprecatedStatement() {
- $statement = NewStatement::noValueFor( 'P1' )
+ $statement = NewStatement::forProperty( 'P1' )
+ ->withValue( 'abc' )
->withDeprecatedRank()
->build();
- $constraint = $this->getConstraintMock( $this->formatParameter(
'' ) );
+ $constraint = $this->getConstraintMock( $this->formatParameter(
'a.b.' ) );
$entity = NewItem::withId( 'Q1' )
->build();
$checkResult = $this->formatChecker->checkConstraint(
$statement, $constraint, $entity );
// this constraint is still checked on deprecated statements
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertViolation( $checkResult,
'wbqc-violation-message-format' );
}
public function testCheckConstraintParameters() {
diff --git a/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php
b/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php
index a83ad12..07c7840 100644
--- a/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php
+++ b/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php
@@ -161,6 +161,21 @@
$this->assertCompliance( $checkResult );
}
+ public function
testDiffWithinRangeConstraintWithinRangeWithOtherSnakTypes() {
+ $noValueStatement = NewStatement::noValueFor( 'P569' );
+ $someValueStatement = NewStatement::someValueFor( 'P569' );
+ $entity = self::$i1970
+ ->andStatement( $noValueStatement ) // should be ignored
+ ->andStatement( $someValueStatement ) // should be
ignored
+ ->andStatement( NewStatement::forProperty( 'P569'
)->withValue( self::$t1900 ) )
+ ->build();
+ $constraint = $this->getConstraintMock(
$this->dob0to150Parameters );
+
+ $checkResult = $this->checker->checkConstraint( self::$s1970,
$constraint, $entity );
+
+ $this->assertCompliance( $checkResult );
+ }
+
public function testDiffWithinRangeConstraintWithoutStatement() {
$entity = self::$i1970->build();
$constraint = $this->getConstraintMock(
$this->dob0to150Parameters );
@@ -176,6 +191,20 @@
->withRank( Statement::RANK_DEPRECATED );
$entity = self::$i1970
->andStatement( $deprecatedStatement ) // should be
ignored
+ ->build();
+ $constraint = $this->getConstraintMock(
$this->dob0to150Parameters );
+
+ $checkResult = $this->checker->checkConstraint( self::$s1970,
$constraint, $entity );
+
+ $this->assertViolation( $checkResult,
'wbqc-violation-message-diff-within-range-property-must-exist' );
+ }
+
+ public function testDiffWithinRangeConstraintWithOnlyOtherSnakTypes() {
+ $noValueStatement = NewStatement::noValueFor( 'P569' );
+ $someValueStatement = NewStatement::someValueFor( 'P569' );
+ $entity = self::$i1970
+ ->andStatement( $noValueStatement ) // should be ignored
+ ->andStatement( $someValueStatement ) // should be
ignored
->build();
$constraint = $this->getConstraintMock(
$this->dob0to150Parameters );
@@ -202,7 +231,7 @@
$checkResult = $this->checker->checkConstraint( $statement,
$constraint, $entity );
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $checkResult );
}
public function testDiffWithinRangeConstraintLeftOpenWithinRange() {
diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
index 70c3d32..bf2b3f8 100644
--- a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
+++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php
@@ -174,7 +174,7 @@
$statement = new Statement( new PropertyNoValueSnak( 1 ) );
$constraintParameters = [];
$checkResult = $this->checker->checkConstraint( $statement,
$this->getConstraintMock( $constraintParameters ), $this->getEntity() );
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $checkResult );
}
public function testRangeConstraintLeftOpenWithinRange() {
diff --git a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
index b6ae9e8..8cbacd9 100644
--- a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
+++ b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php
@@ -258,7 +258,7 @@
'class' => 'Q100,Q101'
];
$checkResult = $this->checker->checkConstraint( $statement,
$this->getConstraintMock( $constraintParameters ), $this->getEntity() );
- $this->assertViolation( $checkResult,
'wbqc-violation-message-value-needed' );
+ $this->assertCompliance( $checkResult );
}
public function testTypeConstraintDeprecatedStatement() {
--
To view, visit https://gerrit.wikimedia.org/r/369623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8bb33ead10770c938d04b00dd637924d4599a752
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits