Soeren.oldag has submitted this change and it was merged. Change subject: Add status mapping for partial compliance and add/extend tests for partial compliance ......................................................................
Add status mapping for partial compliance and add/extend tests for partial compliance Change-Id: I538611b55b2ed3c3a26b84a3f16c7fe3a9be700b --- M specials/SpecialCrossCheck.php M tests/phpunit/CrossCheck/CrossCheckerTest.php M tests/phpunit/CrossCheck/Result/CrossCheckResultTest.php M tests/phpunit/Serializer/CompareResultSerializerTest.php M tests/phpunit/Specials/SpecialCrossCheckTest.php 5 files changed, 107 insertions(+), 4 deletions(-) Approvals: Soeren.oldag: Verified; Looks good to me, approved diff --git a/specials/SpecialCrossCheck.php b/specials/SpecialCrossCheck.php index 29d8f05..ccd4ec0 100755 --- a/specials/SpecialCrossCheck.php +++ b/specials/SpecialCrossCheck.php @@ -149,6 +149,7 @@ protected function getStatusMapping() { return array( CrossCheckResult::STATUS_COMPLIANCE => 'success', + CrossCheckResult::STATUS_PARTIAL_COMPLIANCE => 'partial-success', CrossCheckResult::STATUS_REFERENCES_MISSING => 'warning', CrossCheckResult::STATUS_DATA_MISMATCH => 'error' ); diff --git a/tests/phpunit/CrossCheck/CrossCheckerTest.php b/tests/phpunit/CrossCheck/CrossCheckerTest.php index f2a4507..d581061 100755 --- a/tests/phpunit/CrossCheck/CrossCheckerTest.php +++ b/tests/phpunit/CrossCheck/CrossCheckerTest.php @@ -185,7 +185,6 @@ * Test cases for testCrossCheckStatements */ public function crossCheckStatementsDataProvider() { - $statementsQ1 = $this->items['Q1']->getStatements()->toArray(); return array( // Cross-check all statements of Q1 diff --git a/tests/phpunit/CrossCheck/Result/CrossCheckResultTest.php b/tests/phpunit/CrossCheck/Result/CrossCheckResultTest.php index a82176f..6f23ceb 100755 --- a/tests/phpunit/CrossCheck/Result/CrossCheckResultTest.php +++ b/tests/phpunit/CrossCheck/Result/CrossCheckResultTest.php @@ -19,7 +19,7 @@ class CrossCheckResultTest extends \MediaWikiTestCase { - public function testConstructValidArguments( ) + public function testConstructValidArguments() { // Create test data @@ -149,7 +149,7 @@ ) ), array( - CrossCheckResult::STATUS_COMPLIANCE, + CrossCheckResult::STATUS_PARTIAL_COMPLIANCE, new CrossCheckResult( new PropertyId( 'P42' ), 'Q42$fccafc70-07a0-4e82-807f-288a4b21c13c', @@ -160,7 +160,7 @@ ) ), array( - CrossCheckResult::STATUS_COMPLIANCE, + CrossCheckResult::STATUS_PARTIAL_COMPLIANCE, new CrossCheckResult( new PropertyId( 'P42' ), 'Q42$fccafc70-07a0-4e82-807f-288a4b21c13c', diff --git a/tests/phpunit/Serializer/CompareResultSerializerTest.php b/tests/phpunit/Serializer/CompareResultSerializerTest.php index 2093590..1eb0e0e 100755 --- a/tests/phpunit/Serializer/CompareResultSerializerTest.php +++ b/tests/phpunit/Serializer/CompareResultSerializerTest.php @@ -36,6 +36,24 @@ ), CompareResult::STATUS_MISMATCH ) + ), + array( + new CompareResult( + $this->getDataValueMock(), + array( + $this->getDataValueMock() + ), + CompareResult::STATUS_COMPLIANCE + ) + ), + array( + new CompareResult( + $this->getDataValueMock(), + array( + $this->getDataValueMock() + ), + CompareResult::STATUS_PARTIAL_COMPLIANCE + ) ) ); } @@ -92,6 +110,24 @@ 'localValue' => 'foobar', 'externalValues' => array( 'foobar', + 'foobar' + ), + 'result' => CompareResult::STATUS_PARTIAL_COMPLIANCE + ), + new CompareResult( + $this->getDataValueMock(), + array( + $this->getDataValueMock(), + $this->getDataValueMock() + ), + CompareResult::STATUS_PARTIAL_COMPLIANCE + ) + ), + array( + array( + 'localValue' => 'foobar', + 'externalValues' => array( + 'foobar', '_element' => 'dataValue' ), 'result' => CompareResult::STATUS_MISMATCH @@ -128,6 +164,28 @@ array( 'shouldIndexTags' => true ) + ), + array( + array( + 'localValue' => 'foobar', + 'externalValues' => array( + 0 => 'foobar', + 1 => 'foobar', + '_element' => 'dataValue' + ), + 'result' => CompareResult::STATUS_PARTIAL_COMPLIANCE + ), + new CompareResult( + $this->getDataValueMock(), + array( + $this->getDataValueMock(), + $this->getDataValueMock() + ), + CompareResult::STATUS_PARTIAL_COMPLIANCE + ), + array( + 'shouldIndexTags' => true + ) ) ); } diff --git a/tests/phpunit/Specials/SpecialCrossCheckTest.php b/tests/phpunit/Specials/SpecialCrossCheckTest.php index 9b12a19..40e279b 100755 --- a/tests/phpunit/Specials/SpecialCrossCheckTest.php +++ b/tests/phpunit/Specials/SpecialCrossCheckTest.php @@ -96,6 +96,10 @@ $store->saveEntity( $propertyP3, 'TestEntityP3', $GLOBALS[ 'wgUser' ], EDIT_NEW ); self::$idMap[ 'P3' ] = $propertyP3->getId(); + $propertyP3 = Property::newFromType( 'string' ); + $store->saveEntity( $propertyP3, 'TestEntityP4', $GLOBALS[ 'wgUser' ], EDIT_NEW ); + self::$idMap[ 'P4' ] = $propertyP3->getId(); + $itemQ1 = new Item(); $store->saveEntity( $itemQ1, 'TestEntityQ1', $GLOBALS[ 'wgUser' ], EDIT_NEW ); self::$idMap[ 'Q1' ] = $itemQ1->getId(); @@ -125,6 +129,15 @@ $claim = new Claim( $snak ); $claimGuid = $claimGuidGenerator->newGuid( self::$idMap[ 'Q1' ] ); self::$claimGuids[ 'P3' ] = $claimGuid; + $claim->setGuid( $claimGuid ); + $statement = new Statement( $claim ); + $itemQ1->addClaim( $statement ); + + $dataValue = new StringValue( 'partiall' ); + $snak = new PropertyValueSnak( self::$idMap[ 'P4' ], $dataValue ); + $claim = new Claim( $snak ); + $claimGuid = $claimGuidGenerator->newGuid( self::$idMap[ 'Q1' ] ); + self::$claimGuids[ 'P4' ] = $claimGuid; $claim->setGuid( $claimGuid ); $statement = new Statement( $claim ); $itemQ1->addClaim( $statement ); @@ -185,6 +198,12 @@ 'external_id' => '1234', 'pid' => self::$idMap[ 'P2' ]->getSerialization(), 'external_value' => 'bar' + ), + array( + 'dump_id' => 'foobar', + 'external_id' => '1234', + 'pid' => self::$idMap[ 'P4' ]->getSerialization(), + 'external_value' => 'partial' ) ) ); @@ -379,6 +398,32 @@ 'content' => 'bar' ); + $matchers['value status - partial compliance'] = array( + 'tag' => 'span', + 'attributes' => array( + 'class' => 'wdqa-status wdqa-status-partial-success' + ), + 'content' => '(wikidataquality-checkresult-status-partial-compliance)' + ); + + $matchers['value local value partiall'] = array( + 'tag' => 'td', + 'attributes' => array( + 'rowspan' => '1', + 'colspan' => '1' + ), + 'content' => 'partiall' + ); + + $matchers['value external value partial'] = array( + 'tag' => 'span', + 'attributes' => array( + 'lang' => 'en', + 'class' => 'wb-monolingualtext-value' + ), + 'content' => 'partial' + ); + $cases['valid input - existing item without references'] = array( '$id', array(), $userLanguage, $matchers ); // TODO $cases['valid input - existing item with references'] = array( '$id', array(), 'en', $matchers ); -- To view, visit https://gerrit.wikimedia.org/r/209200 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I538611b55b2ed3c3a26b84a3f16c7fe3a9be700b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataQualityExternalValidation Gerrit-Branch: v1 Gerrit-Owner: Dominic.sauer <dominic.sa...@yahoo.de> Gerrit-Reviewer: Soeren.oldag <soeren_ol...@freenet.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits