Dominic.sauer has submitted this change and it was merged.
Change subject: Fixed GetViolations
......................................................................
Fixed GetViolations
The rasults array now saves violations as 'claimGuid' =>
array(violations)
Change-Id: I032bbd37fc7b66f4272d92acf9f7265437710e04
---
M api/GetViolations.php
M tests/phpunit/Api/GetViolationsTest.php
2 files changed, 23 insertions(+), 5 deletions(-)
Approvals:
Dominic.sauer: Verified; Looks good to me, approved
diff --git a/api/GetViolations.php b/api/GetViolations.php
index c3b03d7..bea556c 100644
--- a/api/GetViolations.php
+++ b/api/GetViolations.php
@@ -75,7 +75,7 @@
if ( $result ) {
foreach ( $result as $violation ) {
$serializedViolation =
$this->violationSerializer->serialize( $violation );
- $output[ $violation->getClaimGuid() ] =
$serializedViolation;
+ $output[ $violation->getClaimGuid() ][] =
$serializedViolation;
}
$this->getResult()->setIndexedTagName( $output,
'violatedClaims' );
diff --git a/tests/phpunit/Api/GetViolationsTest.php
b/tests/phpunit/Api/GetViolationsTest.php
index c1fdf92..7995048 100644
--- a/tests/phpunit/Api/GetViolationsTest.php
+++ b/tests/phpunit/Api/GetViolationsTest.php
@@ -44,6 +44,17 @@
),
array(
'entity_id' => 'Q1',
+ 'pid' => 'P1',
+ 'claim_guid' =>
'P1$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
+ 'constraint_id' =>
'P669$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
+ 'constraint_type_entity_id' => 'Q669',
+ 'additional_info' => '{"type":"JSON",
"mandatory":false}',
+ 'updated_at' => wfTimestamp( TS_MW,
'2014-10-15T15:00:00Z' ),
+ 'revision_id' => 1234,
+ 'status' => 'compliance'
+ ),
+ array(
+ 'entity_id' => 'Q1',
'pid' => 'P2',
'claim_guid' =>
'P2$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
'constraint_id' =>
'P667$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
@@ -84,14 +95,21 @@
);
$result = $this->doApiRequest( $params );
+ $violations = $result[0]['results'];
+
$claimGuidP1 = 'P1$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';
$claimGuidP2 = 'P2$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';
$claimGuidP3 = 'P3$aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';
- $this->assertArrayHasKey( $claimGuidP1, $result[0]['results'] );
- $this->assertEquals( 9, count( $result[0]['results'][
$claimGuidP1 ] ) );
-
- $this->assertArrayHasKey( $claimGuidP2, $result[0]['results'] );
+ $this->assertArrayHasKey( $claimGuidP1, $violations );
+ $this->assertArrayHasKey( $claimGuidP2, $violations );
$this->assertArrayNotHasKey( $claimGuidP3,
$result[0]['results'] );
+
+ $this->assertEquals( 2, count( $violations ) );
+
+ $this->assertEquals( 2, count( $result[0]['results'][
$claimGuidP1 ] ) );
+ $this->assertEquals( 1, count( $result[0]['results'][
$claimGuidP2 ] ) );
+
+ $this->assertEquals( 9, count( $result[0]['results'][
$claimGuidP1 ][0] ) );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/208625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I032bbd37fc7b66f4272d92acf9f7265437710e04
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataQuality
Gerrit-Branch: master
Gerrit-Owner: Tamslo <[email protected]>
Gerrit-Reviewer: Dominic.sauer <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits