Jonaskeutel has submitted this change and it was merged. Change subject: Phasing out of claims ......................................................................
Phasing out of claims [Rebased] Change-Id: I3ea25bcff5a2b64bf5dbb56d0305a837eed2487a --- M includes/ConstraintCheck/Checker/CommonsLinkChecker.php M includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php M includes/ConstraintCheck/Checker/FormatChecker.php M includes/ConstraintCheck/Checker/InverseChecker.php M includes/ConstraintCheck/Checker/MultiValueChecker.php M includes/ConstraintCheck/Checker/OneOfChecker.php M includes/ConstraintCheck/Checker/RangeChecker.php M includes/ConstraintCheck/Checker/SingleValueChecker.php M includes/ConstraintCheck/Checker/SymmetricChecker.php M includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php M includes/ConstraintCheck/Checker/ValueTypeChecker.php M includes/ConstraintCheck/DelegatingConstraintChecker.php M includes/ConstraintCheck/Helper/TypeCheckerHelper.php M includes/ConstraintCheck/Result/CheckResult.php M tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php M tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php M tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php M tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php M tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php M tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php M tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php M tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php M tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php M tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php M tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php M tests/phpunit/EvaluateConstraintReportJobServiceTest.php M tests/phpunit/Result/CheckResultTest.php M tests/phpunit/Specials/SpecialConstraintReportTest.php M tests/phpunit/Violations/CheckResultToViolationTranslatorTest.php 36 files changed, 157 insertions(+), 181 deletions(-) Approvals: Jonaskeutel: Verified; Looks good to me, approved diff --git a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php index 392c5b4..e127219 100644 --- a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php +++ b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php @@ -53,7 +53,7 @@ $parameters['constraint_status'] = $this->helper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php index bb0e161..a9d3cb1 100644 --- a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php +++ b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php @@ -61,7 +61,7 @@ $parameters[ 'constraint_status' ] = $this->helper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: @@ -99,8 +99,8 @@ // checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property) foreach ( $entity->getStatements() as $statement ) { - if ( $property === $statement->getClaim()->getPropertyId()->getSerialization() ) { - $mainSnak = $statement->getClaim()->getMainSnak(); + if ( $property === $statement->getPropertyId()->getSerialization() ) { + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/FormatChecker.php b/includes/ConstraintCheck/Checker/FormatChecker.php index f7e2ba6..06647f6 100644 --- a/includes/ConstraintCheck/Checker/FormatChecker.php +++ b/includes/ConstraintCheck/Checker/FormatChecker.php @@ -56,7 +56,7 @@ $parameters['constraint_status'] = $this->helper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/InverseChecker.php b/includes/ConstraintCheck/Checker/InverseChecker.php index 8ef13ae..e294e8d 100644 --- a/includes/ConstraintCheck/Checker/InverseChecker.php +++ b/includes/ConstraintCheck/Checker/InverseChecker.php @@ -68,7 +68,7 @@ $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* /* diff --git a/includes/ConstraintCheck/Checker/MultiValueChecker.php b/includes/ConstraintCheck/Checker/MultiValueChecker.php index 3cb1324..f5e0b11 100644 --- a/includes/ConstraintCheck/Checker/MultiValueChecker.php +++ b/includes/ConstraintCheck/Checker/MultiValueChecker.php @@ -43,7 +43,7 @@ * @return CheckResult */ public function checkConstraint( Statement $statement, Constraint $constraint, Entity $entity = null ) { - $propertyId = $statement->getClaim()->getPropertyId(); + $propertyId = $statement->getPropertyId(); $parameters = array (); diff --git a/includes/ConstraintCheck/Checker/OneOfChecker.php b/includes/ConstraintCheck/Checker/OneOfChecker.php index 5950148..c431449 100644 --- a/includes/ConstraintCheck/Checker/OneOfChecker.php +++ b/includes/ConstraintCheck/Checker/OneOfChecker.php @@ -54,7 +54,7 @@ $parameters['constraint_status'] = $this->helper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/RangeChecker.php b/includes/ConstraintCheck/Checker/RangeChecker.php index 3c27b8f..a3dd4c9 100644 --- a/includes/ConstraintCheck/Checker/RangeChecker.php +++ b/includes/ConstraintCheck/Checker/RangeChecker.php @@ -56,7 +56,7 @@ $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/SingleValueChecker.php b/includes/ConstraintCheck/Checker/SingleValueChecker.php index 8f19c9b..496a6c3 100644 --- a/includes/ConstraintCheck/Checker/SingleValueChecker.php +++ b/includes/ConstraintCheck/Checker/SingleValueChecker.php @@ -43,7 +43,7 @@ * @return CheckResult */ public function checkConstraint( Statement $statement, Constraint $constraint, Entity $entity = null ) { - $propertyId = $statement->getClaim()->getPropertyId(); + $propertyId = $statement->getPropertyId(); $parameters = array (); diff --git a/includes/ConstraintCheck/Checker/SymmetricChecker.php b/includes/ConstraintCheck/Checker/SymmetricChecker.php index 41b9fbb..383e291 100644 --- a/includes/ConstraintCheck/Checker/SymmetricChecker.php +++ b/includes/ConstraintCheck/Checker/SymmetricChecker.php @@ -64,8 +64,8 @@ $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); - $propertyId = $statement->getClaim()->getPropertyId(); + $mainSnak = $statement->getMainSnak(); + $propertyId = $statement->getPropertyId(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php index 6dceccd..f39b256 100644 --- a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php +++ b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php @@ -76,7 +76,7 @@ $parameters['constraint_status'] = $this->constraintReportHelper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/Checker/ValueTypeChecker.php b/includes/ConstraintCheck/Checker/ValueTypeChecker.php index 33ce151..efd407b 100644 --- a/includes/ConstraintCheck/Checker/ValueTypeChecker.php +++ b/includes/ConstraintCheck/Checker/ValueTypeChecker.php @@ -79,7 +79,7 @@ $parameters['constraint_status'] = $this->helper->parseSingleParameter( $constraintParameters['constraint_status'], true ); } - $mainSnak = $statement->getClaim()->getMainSnak(); + $mainSnak = $statement->getMainSnak(); /* * error handling: diff --git a/includes/ConstraintCheck/DelegatingConstraintChecker.php b/includes/ConstraintCheck/DelegatingConstraintChecker.php index 2c86991..2ee5014 100644 --- a/includes/ConstraintCheck/DelegatingConstraintChecker.php +++ b/includes/ConstraintCheck/DelegatingConstraintChecker.php @@ -82,14 +82,12 @@ $result = array (); foreach ( $this->statements as $statement ) { - $claim = $statement->getClaim(); - - if ( $claim->getMainSnak()->getType() !== 'value' ) { + if ( $statement->getMainSnak()->getType() !== 'value' ) { // skip 'somevalue' and 'novalue' cases, todo: handle in a better way continue; } - $propertyId = $claim->getPropertyId(); + $propertyId = $statement->getPropertyId(); $numericPropertyId = $propertyId->getNumericId(); $constraints = $this->constraintRepository->queryConstraintsForProperty( $numericPropertyId ); diff --git a/includes/ConstraintCheck/Helper/TypeCheckerHelper.php b/includes/ConstraintCheck/Helper/TypeCheckerHelper.php index 360edbd..4b5973f 100644 --- a/includes/ConstraintCheck/Helper/TypeCheckerHelper.php +++ b/includes/ConstraintCheck/Helper/TypeCheckerHelper.php @@ -30,7 +30,7 @@ } /** - * Checks, if one of the itemId serializations in $classesToCheck + * Checks if one of the itemId serializations in $classesToCheck * is subclass of $comparativeClass * Due to cyclic dependencies, the checks stops after a certain * depth is reached @@ -48,8 +48,8 @@ return false; // lookup failed, probably because item doesn't exist } - foreach ( $item->getStatements()->getWithPropertyId( new PropertyId( self::subclassId ) ) as $statement ) { - $mainSnak = $statement->getClaim()->getMainSnak(); + foreach ( $item->getStatements()->getByPropertyId( new PropertyId( self::subclassId ) ) as $statement ) { + $mainSnak = $statement->getMainSnak(); if ( !( $this->hasCorrectType( $mainSnak ) ) ) { continue; @@ -88,8 +88,8 @@ */ public function hasClassInRelation( StatementList $statements, $relationId, $classesToCheck ) { $compliance = null; - foreach ( $statements->getWithPropertyId( new PropertyId( $relationId ) ) as $statement ) { - $mainSnak = $claim = $statement->getClaim()->getMainSnak(); + foreach ( $statements->getByPropertyId( new PropertyId( $relationId ) ) as $statement ) { + $mainSnak = $claim = $statement->getMainSnak(); if ( !$this->hasCorrectType( $mainSnak ) ) { continue; diff --git a/includes/ConstraintCheck/Result/CheckResult.php b/includes/ConstraintCheck/Result/CheckResult.php index 0c7c313..3249fad 100644 --- a/includes/ConstraintCheck/Result/CheckResult.php +++ b/includes/ConstraintCheck/Result/CheckResult.php @@ -68,7 +68,7 @@ * @return PropertyId */ public function getPropertyId() { - return $this->statement->getClaim()->getPropertyId(); + return $this->statement->getPropertyId(); } /** diff --git a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php index e59715c..452089d 100644 --- a/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php +++ b/tests/phpunit/Checker/CommonsLinkChecker/CommonsLinkCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; @@ -68,7 +67,7 @@ public function testCommonsLinkConstraintValid() { $value = new StringValue( 'test image.jpg' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ) ); + $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' ); } @@ -76,9 +75,9 @@ $value1 = new StringValue( 'test_image.jpg' ); $value2 = new StringValue( 'test%20image.jpg' ); $value3 = new StringValue( 'File:test image.jpg' ); - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value1 ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value2 ) ) ); - $statement3 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value3 ) ) ); + $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' ); @@ -86,7 +85,7 @@ public function testNotImplementedNamespaces() { $value = new StringValue( 'test image.jpg' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ) ); + $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' ); @@ -96,18 +95,18 @@ public function testCommonsLinkConstraintNotExistent() { $value = new StringValue( 'no image.jpg' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ) ); + $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' ); } public function testCommonsLinkConstraintNoStringValue() { $value = new EntityIdValue( new ItemId( 'Q1' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), $value ) ) ); + $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' ); } public function testCommonsLinkConstraintNoValueSnak() { - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $this->assertEquals( 'violation', $this->commonsLinkChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'namespace' => 'File' ) ) )->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php index 546eb8b..eff8830 100644 --- a/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/ConflictsWithCheckerTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Test\ConnectionChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; @@ -52,7 +51,7 @@ $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2' @@ -67,7 +66,7 @@ $this->checker = new ConflictsWithChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2' @@ -82,7 +81,7 @@ $this->checker = new ConflictsWithChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'item' => 'Q1', @@ -98,7 +97,7 @@ $this->checker = new ConflictsWithChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'item' => 'Q42', @@ -114,7 +113,7 @@ $this->checker = new ConflictsWithChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement(new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array(); @@ -127,7 +126,7 @@ $this->checker = new ConflictsWithChecker( $this->lookup, $this->helper, $this->connectionCheckerHelper ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'item' => 'Q42', diff --git a/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php b/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php index 7d93eb0..46978d4 100644 --- a/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/ConnectionCheckerHelperTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; @@ -31,8 +30,8 @@ protected function setUp() { parent::setUp(); - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q2' ) ) ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q2' ) ) ) ); $this->statementList = new StatementList( array( $statement1, $statement2 ) ); $this->connectionCheckerHelper = new ConnectionCheckerHelper(); } @@ -67,7 +66,7 @@ } public function testHasClaimNoValueSnak() { - $statementList = new StatementList( new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ) ); + $statementList = new StatementList( new Statement( new PropertyNoValueSnak( 1 ) ) ); $this->assertEquals( false, $this->connectionCheckerHelper->hasClaim( $statementList, 'P1', array( 'Q1', 'Q2' ) ) ); } } \ No newline at end of file diff --git a/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php index ba1a699..bbbb035 100644 --- a/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/InverseCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; @@ -54,7 +53,7 @@ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $value = new EntityIdValue( new ItemId( 'Q7' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P1' @@ -67,7 +66,7 @@ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $value = new EntityIdValue( new ItemId( 'Q8' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P1' @@ -80,7 +79,7 @@ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $value = new EntityIdValue( new ItemId( 'Q7' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array(); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); @@ -91,7 +90,7 @@ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $value = new StringValue( 'Q7' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P1' @@ -104,7 +103,7 @@ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P1' @@ -116,7 +115,7 @@ public function testInverseConstraintNoValueSnak() { $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $constraintParameters = array( 'property' => 'P1' diff --git a/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php index f99169c..99f0aba 100644 --- a/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/ItemCheckerTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Test\ConnectionChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; @@ -54,7 +53,7 @@ 'property' => 'P2' ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -67,7 +66,7 @@ ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); @@ -81,7 +80,7 @@ ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -94,7 +93,7 @@ 'item' => 'Q42' ); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); @@ -105,7 +104,7 @@ $constraintParameters = array(); $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); diff --git a/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php index bb586e2..2999cd6 100644 --- a/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/SymmetricCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; @@ -55,7 +54,7 @@ public function testSymmetricConstraintWithCorrectSpouse() { $value = new EntityIdValue( new ItemId( 'Q3' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock(), $this->entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); @@ -63,7 +62,7 @@ public function testSymmetricConstraintWithWrongSpouse() { $value = new EntityIdValue( new ItemId( 'Q2' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock(), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -71,7 +70,7 @@ public function testSymmetricConstraintWithWrongDataValue() { $value = new StringValue( 'Q3' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock(), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -79,14 +78,14 @@ public function testSymmetricConstraintWithNonExistentEntity() { $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock(), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } public function testSymmetricConstraintNoValueSnak() { - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock(), $this->entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); diff --git a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php index 81f675d..608bf06 100644 --- a/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php +++ b/tests/phpunit/Checker/ConnectionChecker/TargetRequiredClaimCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; @@ -55,7 +54,7 @@ public function testTargetRequiredClaimConstraintValid() { $value = new EntityIdValue( new ItemId( 'Q5' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2', @@ -67,7 +66,7 @@ public function testTargetRequiredClaimConstraintWrongItem() { $value = new EntityIdValue( new ItemId( 'Q5' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2', @@ -79,7 +78,7 @@ public function testTargetRequiredClaimConstraintOnlyProperty() { $value = new EntityIdValue( new ItemId( 'Q5' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2' @@ -90,7 +89,7 @@ public function testTargetRequiredClaimConstraintOnlyPropertyButDoesNotExist() { $value = new EntityIdValue( new ItemId( 'Q5' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P3' @@ -101,7 +100,7 @@ public function testTargetRequiredClaimConstraintWithoutProperty() { $value = new EntityIdValue( new ItemId( 'Q5' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array(); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); @@ -110,7 +109,7 @@ public function testTargetRequiredClaimConstraintWrongDataTypeForItem() { $value = new StringValue( 'Q5' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2' @@ -121,7 +120,7 @@ public function testTargetRequiredClaimConstraintItemDoesNotExist() { $value = new EntityIdValue( new ItemId( 'Q100' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P188' ), $value ) ); $constraintParameters = array( 'property' => 'P2' @@ -131,7 +130,7 @@ } public function testTargetRequiredClaimConstraintNoValueSnak() { - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $constraintParameters = array( 'property' => 'P2' diff --git a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php index f670563..9ffddf8 100644 --- a/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php +++ b/tests/phpunit/Checker/FormatChecker/FormatCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; @@ -56,16 +55,16 @@ $value9 = new StringValue( 'nm000139' ); $value10 = new StringValue( 'nmnm0001398' ); - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value1 ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value2 ) ) ); - $statement3 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value3 ) ) ); - $statement4 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value4 ) ) ); - $statement5 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value5 ) ) ); - $statement6 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value6 ) ) ); - $statement7 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value7 ) ) ); - $statement8 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value8 ) ) ); - $statement9 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value9 ) ) ); - $statement10 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value10 ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value1 ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value2 ) ); + $statement3 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value3 ) ); + $statement4 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value4 ) ); + $statement5 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value5 ) ); + $statement6 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value6 ) ); + $statement7 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value7 ) ); + $statement8 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value8 ) ); + $statement9 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value9 ) ); + $statement10 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value10 ) ); $this->assertEquals( 'compliance', $this->formatChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); $this->assertEquals( 'compliance', $this->formatChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); @@ -93,16 +92,16 @@ $value9 = new StringValue( 'Deinococcus-Thermus' ); $value10 = new StringValue( 'Escherichia coli O157:H7' ); - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value1 ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value2 ) ) ); - $statement3 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value3 ) ) ); - $statement4 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value4 ) ) ); - $statement5 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value5 ) ) ); - $statement6 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value6 ) ) ); - $statement7 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value7 ) ) ); - $statement8 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value8 ) ) ); - $statement9 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value9 ) ) ); - $statement10 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value10 ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value1 ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value2 ) ); + $statement3 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value3 ) ); + $statement4 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value4 ) ); + $statement5 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value5 ) ); + $statement6 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value6 ) ); + $statement7 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value7 ) ); + $statement8 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value8 ) ); + $statement9 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value9 ) ); + $statement10 = new Statement( new PropertyValueSnak( new PropertyId( 'P345' ), $value10 ) ); $this->assertEquals( 'compliance', $this->formatChecker->checkConstraint( $statement1, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); $this->assertEquals( 'compliance', $this->formatChecker->checkConstraint( $statement2, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should comply' ); @@ -119,20 +118,20 @@ public function testFormatConstraintEmptyPattern() { $pattern = null; $value = new StringValue( 'Populus × canescens' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value ) ) ); + $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' ); } 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 Claim( new PropertyValueSnak( new PropertyId( 'P345' ), $value ) ) ); + $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' ); } public function testFormatConstraintNoValueSnak() { $pattern = "."; - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $this->assertEquals( 'violation', $this->formatChecker->checkConstraint( $statement, $this->getConstraintMock( array( 'pattern' => $pattern ) ) )->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php b/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php index 3b22d38..4af7c81 100644 --- a/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php +++ b/tests/phpunit/Checker/OneOfChecker/OneOfCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use Wikibase\DataModel\Entity\EntityIdValue; @@ -45,8 +44,8 @@ $valueIn = new EntityIdValue( new ItemId( 'Q1' ) ); $valueNotIn = new EntityIdValue( new ItemId( 'Q9' ) ); - $statementIn = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P123' ), $valueIn ) ) ); - $statementNotIn = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P123' ), $valueNotIn ) ) ); + $statementIn = new Statement( new PropertyValueSnak( new PropertyId( 'P123' ), $valueIn ) ); + $statementNotIn = new Statement( new PropertyValueSnak( new PropertyId( 'P123' ), $valueNotIn ) ); $values = 'Q1,Q2,Q3'; @@ -56,26 +55,26 @@ public function testOneOfConstraintWrongType() { $value = new StringValue( 'Q1' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ) ); + $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' ); } public function testOneOfConstraintEmptyArray() { $value = new EntityIdValue( new ItemId( 'Q1' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ); $this->assertEquals( 'violation', $this->oneOfChecker->checkConstraint( $statement, $this->getConstraintMock( array() ) )->getStatus(), 'check should not comply' ); } public function testOneOfConstraintArrayWithSomevalue() { $value = new EntityIdValue( new ItemId( 'Q1' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P123' ), $value ) ) ); + $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' ); } public function testOneOfConstraintNoValueSnak() { - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $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' ); } diff --git a/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php b/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php index b285904..de81d09 100644 --- a/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php +++ b/tests/phpunit/Checker/RangeChecker/DiffWithinRangeCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\StringValue; use DataValues\TimeValue; @@ -57,7 +56,7 @@ 'minimum_quantity' => 0, 'maximum_quantity' => 150 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); @@ -70,7 +69,7 @@ 'minimum_quantity' => 50, 'maximum_quantity' => 150 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -83,7 +82,7 @@ 'minimum_quantity' => 0, 'maximum_quantity' => 150 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -92,7 +91,7 @@ public function testDiffWithinRangeConstraintWithoutProperty() { $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); $constraintParameters = array(); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -103,7 +102,7 @@ $constraintParameters = array( 'property' => 'P1' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), new StringValue( '1.1.1970' ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), new StringValue( '1.1.1970' ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -116,7 +115,7 @@ 'minimum_quantity' => 1, 'maximum_quantity' => 100 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -129,7 +128,7 @@ 'minimum_quantity' => 0, 'maximum_quantity' => 150 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P570' ), $this->timeValue ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); @@ -137,7 +136,7 @@ public function testDiffWithinRangeConstraintNoValueSnak() { $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) ); - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $constraintParameters = array( 'property' => 'P1000', 'minimum_quantity' => 0, diff --git a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php index a1dea51..9fa338d 100644 --- a/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php +++ b/tests/phpunit/Checker/RangeChecker/RangeCheckerTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use DataValues\DecimalValue; use DataValues\QuantityValue; @@ -54,7 +53,7 @@ public function testRangeConstraintWithinRange() { $value = new DecimalValue( 3.1415926536 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ); $constraintParameters = array( 'minimum_quantity' => 0, 'maximum_quantity' => 10 @@ -65,7 +64,7 @@ public function testRangeConstraintTooSmall() { $value = new DecimalValue( 42 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ); $constraintParameters = array( 'minimum_quantity' => 100, 'maximum_quantity' => 1000 @@ -76,7 +75,7 @@ public function testRangeConstraintTooBig() { $value = new DecimalValue( 3.141592 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ); $constraintParameters = array( 'minimum_quantity' => 0, 'maximum_quantity' => 1 @@ -88,7 +87,7 @@ public function testRangeConstraintTimeWithinRange() { $min = new TimeValue( '+00000001960-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $max = new TimeValue( '+00000001980-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ); $constraintParameters = array( 'minimum_date' => $min, 'maximum_date' => $max @@ -100,7 +99,7 @@ public function testRangeConstraintTimeTooSmall() { $min = new TimeValue( '+00000001975-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $max = new TimeValue( '+00000001980-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ); $constraintParameters = array( 'minimum_date' => $min, 'maximum_date' => $max @@ -112,7 +111,7 @@ public function testRangeConstraintTimeTooBig() { $min = new TimeValue( '+00000001960-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $max = new TimeValue( '+00000001965-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ); $constraintParameters = array( 'minimum_date' => $min, 'maximum_date' => $max @@ -124,7 +123,7 @@ public function testRangeConstraintQuantityWrongParameter() { $min = new TimeValue( '+00000001970-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $value = $max = new DecimalValue( 42 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), new QuantityValue( $value, '1', $value, $value ) ) ); $constraintParameters = array( 'minimum_quantity' => $min, 'maximum_date' => $max @@ -136,7 +135,7 @@ public function testRangeConstraintTimeWrongParameter() { $min = new TimeValue( '+00000001970-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $max = new DecimalValue( 42 ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), $this->timeValue ) ); $constraintParameters = array( 'minimum_quantity' => $min, 'maximum_date' => $max @@ -148,7 +147,7 @@ public function testRangeConstraintWrongType() { $min = new TimeValue( '+00000001960-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); $max = new TimeValue( '+00000001965-01-01T00:00:00Z', 0, 0, 0, 11, 'http://www.wikidata.org/entity/Q1985727' ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1457' ), new StringValue( '1.1.1970' ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1457' ), new StringValue( '1.1.1970' ) ) ); $constraintParameters = array( 'minimum_date' => $min, 'maximum_date' => $max @@ -158,7 +157,7 @@ } public function testRangeConstraintNoValueSnak() { - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $constraintParameters = array(); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( $constraintParameters ) ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); diff --git a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php index 860669a..554420d 100644 --- a/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php +++ b/tests/phpunit/Checker/TypeChecker/TypeCheckerHelperTest.php @@ -39,22 +39,22 @@ public function testCheckHasClassInRelationValid() { - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) ); $statements = new StatementList( array( $statement1, $statement2 ) ); $this->assertEquals( true, $this->helper->hasClassInRelation( $statements, 'P31', array( 'Q1' ) ) ); } public function testCheckHasClassInRelationInvalid() { - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q100' ) ) ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q100' ) ) ) ); $statements = new StatementList( array( $statement1, $statement2 ) ); $this->assertEquals( false, $this->helper->hasClassInRelation( $statements, 'P31', array( 'Q1' ) ) ); } public function testCheckHasClassInRelationValidWithIndirection() { - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q5' ) ) ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P31' ), new EntityIdValue( new ItemId( 'Q5' ) ) ) ); $statements = new StatementList( array( $statement1, $statement2 ) ); $this->assertEquals( true, $this->helper->hasClassInRelation( $statements, 'P31', array( 'Q4' ) ) ); } diff --git a/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php b/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php index 454f1c2..f03e784 100644 --- a/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php +++ b/tests/phpunit/Checker/TypeChecker/TypeCheckerTest.php @@ -2,7 +2,6 @@ namespace WikibaseQuality\ConstraintReport\Test\TypeChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; @@ -34,7 +33,7 @@ parent::setUp(); $this->lookup = new JsonFileEntityLookup( __DIR__ ); $this->checker = new TypeChecker( $this->lookup, new ConstraintReportHelper(), new TypeCheckerHelper( $this->lookup ) ); - $this->typeStatement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ) ); + $this->typeStatement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q42' ) ) ) ); } protected function tearDown() { diff --git a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php index 0dc1420..ffbb26a 100644 --- a/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php +++ b/tests/phpunit/Checker/TypeChecker/ValueTypeCheckerTest.php @@ -2,7 +2,6 @@ namespace WikibaseQuality\ConstraintReport\Test\TypeChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\EntityIdValue; use Wikibase\DataModel\Entity\ItemId; @@ -50,7 +49,7 @@ // relation 'instance' public function testValueTypeConstraintInstanceValid() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q100,Q101' @@ -60,7 +59,7 @@ } public function testValueTypeConstraintInstanceValidWithIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q2' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q2' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q100,Q101' @@ -70,7 +69,7 @@ } public function testValueTypeConstraintInstanceValidWithMoreIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q3' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q3' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q100,Q101' @@ -81,7 +80,7 @@ // relation 'subclass' public function testValueTypeConstraintSubclassValid() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q4' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q4' ) ) ) ); $constraintParameters = array( 'relation' => 'subclass', 'class' => 'Q100,Q101' @@ -91,7 +90,7 @@ } public function testValueTypeConstraintSubclassValidWithIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q5' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q5' ) ) ) ); $constraintParameters = array( 'relation' => 'subclass', 'class' => 'Q100,Q101' @@ -101,7 +100,7 @@ } public function testValueTypeConstraintSubclassValidWithMoreIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q6' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q6' ) ) ) ); $constraintParameters = array( 'relation' => 'subclass', 'class' => 'Q100,Q101' @@ -112,7 +111,7 @@ // relation 'instance', violations public function testValueTypeConstraintInstanceInvalid() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q200,Q201' @@ -122,7 +121,7 @@ } public function testValueTypeConstraintInstanceInvalidWithIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q2' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q2' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q200,Q201' @@ -132,7 +131,7 @@ } public function testValueTypeConstraintInstanceInvalidWithMoreIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q3' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q3' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q200,Q201' @@ -143,7 +142,7 @@ // relation 'subclass', violations public function testValueTypeConstraintSubclassInvalid() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q4' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q4' ) ) ) ); $constraintParameters = array( 'relation' => 'subclass', 'class' => 'Q200,Q201' @@ -153,7 +152,7 @@ } public function testValueTypeConstraintSubclassInvalidWithIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q5' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q5' ) ) ) ); $constraintParameters = array( 'relation' => 'subclass', 'class' => 'Q200,Q201' @@ -163,7 +162,7 @@ } public function testValueTypeConstraintSubclassInvalidWithMoreIndirection() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q6' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q6' ) ) ) ); $constraintParameters = array( 'relation' => 'subclass', 'class' => 'Q200,Q201' @@ -174,7 +173,7 @@ // edge cases public function testValueTypeConstraintMissingRelation() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ); $constraintParameters = array( 'class' => 'Q100,Q101' ); @@ -183,7 +182,7 @@ } public function testValueTypeConstraintMissingClass() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q1' ) ) ) ); $constraintParameters = array( 'relation' => 'instance' ); @@ -192,7 +191,7 @@ } public function testValueTypeConstraintWrongType() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new StringValue( 'foo bar baz' ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new StringValue( 'foo bar baz' ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q100,Q101' @@ -202,7 +201,7 @@ } public function testValueTypeConstraintNonExistingValue() { - $statement = new Statement( new Claim( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q100' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->valueTypePropertyId, new EntityIdValue( new ItemId( 'Q100' ) ) ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q100,Q101' @@ -212,7 +211,7 @@ } public function testValueTypeConstraintNoValueSnak() { - $statement = new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ); + $statement = new Statement( new PropertyNoValueSnak( 1 ) ); $constraintParameters = array( 'relation' => 'instance', 'class' => 'Q100,Q101' diff --git a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php index 83d8ea2..11f52a6 100644 --- a/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/MultiValueCheckerTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; @@ -49,21 +48,21 @@ public function testMultiValueConstraintOne() { $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->multiPropertyId, new EntityIdValue( new ItemId( 'Q207' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->multiPropertyId, new EntityIdValue( new ItemId( 'Q207' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } public function testMultiValueConstraintTwo() { $entity = $this->lookup->getEntity( new ItemId( 'Q5' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->multiPropertyId, new EntityIdValue( new ItemId( 'Q207' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->multiPropertyId, new EntityIdValue( new ItemId( 'Q207' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } public function testMultiValueConstraintTwoButOneDeprecated() { $entity = $this->lookup->getEntity( new ItemId( 'Q6' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->multiPropertyId, new EntityIdValue( new ItemId( 'Q409' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->multiPropertyId, new EntityIdValue( new ItemId( 'Q409' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php index beb82e3..e97387e 100644 --- a/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/SingleValueCheckerTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; @@ -49,21 +48,21 @@ public function testSingleValueConstraintOne() { $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->singlePropertyId, new EntityIdValue( new ItemId( 'Q1384' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->singlePropertyId, new EntityIdValue( new ItemId( 'Q1384' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } public function testSingleValueConstraintTwo() { $entity = $this->lookup->getEntity( new ItemId( 'Q2' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->singlePropertyId, new EntityIdValue( new ItemId( 'Q1384' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->singlePropertyId, new EntityIdValue( new ItemId( 'Q1384' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'violation', $checkResult->getStatus(), 'check should not comply' ); } public function testSingleValueConstraintTwoButOneDeprecated() { $entity = $this->lookup->getEntity( new ItemId( 'Q3' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->singlePropertyId, new EntityIdValue( new ItemId( 'Q1384' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->singlePropertyId, new EntityIdValue( new ItemId( 'Q1384' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ), $entity ); $this->assertEquals( 'compliance', $checkResult->getStatus(), 'check should comply' ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php b/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php index 7bd6305..289db9f 100644 --- a/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/UniqueValueCheckerTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Entity\PropertyId; @@ -49,7 +48,7 @@ // todo: it is currently only testing that 'todo' comes back public function testCheckUniqueValueConstraint() { $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) ); - $statement = new Statement( new Claim( new PropertyValueSnak( $this->uniquePropertyId, new EntityIdValue( new ItemId( 'Q404' ) ) ) ) ); + $statement = new Statement( new PropertyValueSnak( $this->uniquePropertyId, new EntityIdValue( new ItemId( 'Q404' ) ) ) ); $checkResult = $this->checker->checkConstraint( $statement, $this->getConstraintMock( array() ) ); $this->assertEquals( 'todo', $checkResult->getStatus(), 'check should point out that it should be implemented soon' ); } diff --git a/tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php b/tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php index a6f6b88..d2c5c84 100644 --- a/tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php +++ b/tests/phpunit/Checker/ValueCountChecker/ValueCountCheckerHelperTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Test\ValueCountChecker; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Statement\StatementList; use Wikibase\DataModel\Entity\PropertyId; @@ -26,10 +25,10 @@ protected function setUp() { parent::setUp(); - $statement1 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) ) ); - $statement2 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q2' ) ) ) ) ); - $statement3 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q3' ) ) ) ) ); - $statement4 = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q4' ) ) ) ) ); + $statement1 = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new EntityIdValue( new ItemId( 'Q1' ) ) ) ); + $statement2 = new Statement( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q2' ) ) ) ); + $statement3 = new Statement( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q3' ) ) ) ); + $statement4 = new Statement( new PropertyValueSnak( new PropertyId( 'P2' ), new EntityIdValue( new ItemId( 'Q4' ) ) ) ); $statement4->setRank( Statement::RANK_DEPRECATED ); $this->statementList = new StatementList( array( $statement1, $statement2, $statement3, $statement4 ) ); } diff --git a/tests/phpunit/EvaluateConstraintReportJobServiceTest.php b/tests/phpunit/EvaluateConstraintReportJobServiceTest.php index 3081f09..384a5d1 100644 --- a/tests/phpunit/EvaluateConstraintReportJobServiceTest.php +++ b/tests/phpunit/EvaluateConstraintReportJobServiceTest.php @@ -3,7 +3,6 @@ namespace WikibaseQuality\ConstraintReport\Tests; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\PropertyId; use Wikibase\DataModel\Entity\ItemId; @@ -38,7 +37,7 @@ $this->checkTimestamp = wfTimestamp( TS_MW ); - $statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1337' ), new StringValue( 'f00b4r' ) ) ) ); + $statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1337' ), new StringValue( 'f00b4r' ) ) ); $this->constraintName = 'Single value'; $results = array (); diff --git a/tests/phpunit/Result/CheckResultTest.php b/tests/phpunit/Result/CheckResultTest.php index c6a9a41..210e689 100644 --- a/tests/phpunit/Result/CheckResultTest.php +++ b/tests/phpunit/Result/CheckResultTest.php @@ -4,7 +4,6 @@ use Wikibase\DataModel\Snak\PropertyNoValueSnak; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\PropertyId; use DataValues\StringValue; @@ -28,7 +27,7 @@ protected function setUp() { parent::setUp(); - $this->statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new StringValue( 'Foo' ) ) ) ); + $this->statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new StringValue( 'Foo' ) ) ); $this->constraintName = 'Range'; $this->parameters = array (); $this->status = 'compliance'; @@ -47,8 +46,8 @@ public function testConstructAndGetters() { $checkResult = new CheckResult( $this->statement, $this->constraintName, $this->parameters, $this->status, $this->message ); $this->assertEquals( $this->statement, $checkResult->getStatement() ); - $this->assertEquals( $this->statement->getClaim()->getPropertyId(), $checkResult->getPropertyId() ); - $this->assertEquals( $this->statement->getClaim()->getMainSnak()->getDataValue(), $checkResult->getDataValue() ); + $this->assertEquals( $this->statement->getPropertyId(), $checkResult->getPropertyId() ); + $this->assertEquals( $this->statement->getMainSnak()->getDataValue(), $checkResult->getDataValue() ); $this->assertEquals( $this->constraintName, $checkResult->getConstraintName() ); $this->assertEquals( $this->parameters, $checkResult->getParameters() ); $this->assertEquals( $this->status, $checkResult->getStatus() ); @@ -57,7 +56,7 @@ } public function testWithWrongSnakType() { - $checkResult = new CheckResult( new Statement( new Claim( new PropertyNoValueSnak( 1 ) ) ), $this->constraintName, $this->parameters, $this->status, $this->message ); + $checkResult = new CheckResult( new Statement( new PropertyNoValueSnak( 1 ) ), $this->constraintName, $this->parameters, $this->status, $this->message ); $this->setExpectedException( '\Exception' ); $checkResult->getDataValue(); } diff --git a/tests/phpunit/Specials/SpecialConstraintReportTest.php b/tests/phpunit/Specials/SpecialConstraintReportTest.php index 9ba51a2..a03f936 100644 --- a/tests/phpunit/Specials/SpecialConstraintReportTest.php +++ b/tests/phpunit/Specials/SpecialConstraintReportTest.php @@ -4,7 +4,6 @@ use Wikibase\Test\SpecialPageTestBase; use DataValues\StringValue; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Entity\Property; use Wikibase\DataModel\Snak\PropertyValueSnak; @@ -101,16 +100,15 @@ $store->saveEntity( $itemQ1, 'TestEntityQ1', $GLOBALS[ 'wgUser' ], EDIT_NEW ); self::$idMap[ 'Q1' ] = $itemQ1->getId(); - $claimGuidGenerator = new ClaimGuidGenerator(); + $statementGuidGenerator = new ClaimGuidGenerator(); $dataValue = new StringValue( 'foo' ); $snak = new PropertyValueSnak( self::$idMap[ 'P1' ], $dataValue ); - $claim = new Claim( $snak ); - $claimGuid = $claimGuidGenerator->newGuid( self::$idMap[ 'Q1' ] ); - self::$claimGuids[ 'P1' ] = $claimGuid; - $claim->setGuid( $claimGuid ); - $statement = new Statement( $claim ); - $itemQ1->addClaim( $statement ); + $statement = new Statement( $snak ); + $statementGuid = $statementGuidGenerator->newGuid( self::$idMap[ 'Q1' ] ); + self::$claimGuids[ 'P1' ] = $statementGuid; + $statement->setGuid( $statementGuid ); + $itemQ1->getStatements()->addStatement( $statement ); $store->saveEntity( $itemQ1, 'TestEntityQ1', $GLOBALS[ 'wgUser' ], EDIT_UPDATE ); diff --git a/tests/phpunit/Violations/CheckResultToViolationTranslatorTest.php b/tests/phpunit/Violations/CheckResultToViolationTranslatorTest.php index bebc810..e40a404 100644 --- a/tests/phpunit/Violations/CheckResultToViolationTranslatorTest.php +++ b/tests/phpunit/Violations/CheckResultToViolationTranslatorTest.php @@ -6,7 +6,6 @@ use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\Item; use Wikibase\DataModel\Statement\Statement; -use Wikibase\DataModel\Claim\Claim; use Wikibase\DataModel\Snak\PropertyValueSnak; use Wikibase\DataModel\Entity\PropertyId; use DataValues\StringValue; @@ -77,7 +76,7 @@ protected function setUp() { parent::setUp(); $this->translator = new CheckResultToViolationTranslator( $this->getEntityRevisionLookupMock() ); - $this->statement = new Statement( new Claim( new PropertyValueSnak( new PropertyId( 'P1' ), new StringValue( 'Foo' ) ) ) ); + $this->statement = new Statement( new PropertyValueSnak( new PropertyId( 'P1' ), new StringValue( 'Foo' ) ) ); $this->propertyId = new PropertyId( 'P1' ); $this->claimGuid = 'P1$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'; $this->statement->setGuid( 'P1$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' ); -- To view, visit https://gerrit.wikimedia.org/r/218902 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3ea25bcff5a2b64bf5dbb56d0305a837eed2487a Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/WikidataQualityConstraints Gerrit-Branch: master Gerrit-Owner: Tamslo <tamaraslosa...@gmail.com> Gerrit-Reviewer: Jonaskeutel <jonas.keu...@student.hpi.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits