Tamslo has uploaded a new change for review.
https://gerrit.wikimedia.org/r/203841
Change subject: Implemented ViolationQuery
......................................................................
Implemented ViolationQuery
ViolationQuery receives params for a database query and converts them to
an array. Also implemented comments from last commit: Refactored tests and
Violation holds now the original types of its variables, not strings.
Change-Id: Ie0de8568b391c27fe9bf0e03b92787cda623ad63
---
M includes/Violations/Violation.php
M includes/Violations/ViolationLookup.php
A includes/Violations/ViolationQuery.php
M includes/Violations/ViolationStore.php
M tests/phpunit/Violations/ViolationLookupTest.php
A tests/phpunit/Violations/ViolationQueryTest.php
M tests/phpunit/Violations/ViolationStoreTest.php
M tests/phpunit/Violations/ViolationTest.php
8 files changed, 394 insertions(+), 54 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataQuality
refs/changes/41/203841/1
diff --git a/includes/Violations/Violation.php
b/includes/Violations/Violation.php
index 948d397..e07bf0b 100644
--- a/includes/Violations/Violation.php
+++ b/includes/Violations/Violation.php
@@ -4,13 +4,14 @@
use Doctrine\Instantiator\Exception\InvalidArgumentException;
use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\Statement\Statement;
/**
* Class Violation
*
- * holds data that will be inserted into the violation table
+ * Holds data that will be inserted into the violation table
*
* @package WikidataQuality\Violation
* @author BP2014N1
@@ -21,14 +22,14 @@
/**
* entity that contains the violation
*
- * @var string $entityId
+ * @var EntityId $entityId
*/
private $entityId;
/**
* property of the claim that contains the violation
*
- * @var string $pid
+ * @var PropertyId $pid
*/
private $pid;
@@ -49,7 +50,7 @@
/**
* type of the constraint that is violated
*
- * @var $constraintTypeEntityId
+ * @var EntityId $constraintTypeEntityId
*/
private $constraintTypeEntityId;
@@ -89,11 +90,17 @@
* @param string $additionalInfo
*/
public function __construct( EntityId $entityId, $statement,
$constraintClaimGuid, EntityId $constraintTypeEntityId, $revisionId, $status,
$additionalInfo = null, $updatedAt = null ) {
- $this->entityId = $entityId->getSerialization();
+ $this->entityId = $entityId;
if ( $statement instanceof Statement ) {
- $this->pid =
$statement->getPropertyId()->getSerialization();
+ $this->pid = $statement->getPropertyId();
$this->claimGuid = $statement->getGuid();
} else if ( is_array( $statement ) ) {
+ if ( !( $statement[ 'pid' ] instanceof PropertyId ) ) {
+ throw new InvalidArgumentException( 'pid must
be of type PropertyId' );
+ }
+ if ( !is_string( $statement[ 'claimGuid' ] ) ) {
+ throw new InvalidArgumentException( 'claimGuid
must be of type string' );
+ }
$this->pid = $statement[ 'pid' ];
$this->claimGuid = $statement[ 'claimGuid' ];
} else {
@@ -104,7 +111,7 @@
} else {
throw new InvalidArgumentException(
'$constraintClaimGuid must be of type string' );
}
- $this->constraintTypeEntityId =
$constraintTypeEntityId->getSerialization();
+ $this->constraintTypeEntityId = $constraintTypeEntityId;
if ( is_int( $revisionId ) ) {
$this->revisionId = $revisionId;
} else {
@@ -142,14 +149,14 @@
}
/**
- * @return string
+ * @return EntityId
*/
public function getEntityId() {
return $this->entityId;
}
/**
- * @return string
+ * @return PropertyId
*/
public function getPropertyId() {
return $this->pid;
@@ -170,7 +177,7 @@
}
/**
- * @return string
+ * @return EntityId
*/
public function getConstraintTypeEntityId() {
return $this->constraintTypeEntityId;
diff --git a/includes/Violations/ViolationLookup.php
b/includes/Violations/ViolationLookup.php
index c1d801d..6c4ec22 100644
--- a/includes/Violations/ViolationLookup.php
+++ b/includes/Violations/ViolationLookup.php
@@ -4,11 +4,13 @@
use Doctrine\Instantiator\Exception\InvalidArgumentException;
use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\DataModel\Entity\PropertyId;
/**
* Class ViolationLookup
*
+ * Receives an object of ViolationQuery, performs the query and returns an
object of type Violation
*
* @package WikidataQuality\ViolationLookup
* @author BP2014N1
@@ -23,22 +25,10 @@
*
* @return array of Violations|null
*/
- public function getWhere( array $conditions ) {
- $queryConditions = $this->convertConditions( $conditions );
+ public function getWhere( ViolationQuery $violationQuery ) {
$this->getDBConnection();
- $queryResult = $this->db->select( VIOLATION_TABLE, '*',
$queryConditions );
+ $queryResult = $this->db->select( VIOLATION_TABLE, '*',
$violationQuery->toArray() );
return $this->queryResultToViolationObjects( $queryResult );
- }
-
- private function convertConditions( $conditions ) {
- $queryConditions = array ();
- foreach ( $conditions as $column => $value ) {
- if ( !is_string( $column ) || !is_string( $value ) ) {
- throw new InvalidArgumentException( 'The values
provided in $opts have to be of type string' );
- }
- $queryConditions[ ] = $column . '="' . $value . '"';
- }
- return $queryConditions;
}
private function queryResultToViolationObjects( $queryResult ) {
@@ -51,7 +41,7 @@
foreach ( $queryResult as $result ) {
$violation = new Violation(
new ItemId( $result->entity_id ),
- array ( 'pid' => $result->pid, 'claimGuid' =>
$result->claim_guid ),
+ array ( 'pid' => new PropertyId( $result->pid
), 'claimGuid' => $result->claim_guid ),
$result->constraint_claim_guid,
new ItemId( $result->constraint_type_entity_id
),
(int) $result->revision_id,
diff --git a/includes/Violations/ViolationQuery.php
b/includes/Violations/ViolationQuery.php
new file mode 100644
index 0000000..7115734
--- /dev/null
+++ b/includes/Violations/ViolationQuery.php
@@ -0,0 +1,180 @@
+<?php
+
+namespace WikidataQuality\Violations;
+
+use Doctrine\Instantiator\Exception\InvalidArgumentException;
+
+
+/**
+ * Class ViolationQuery
+ *
+ * Receives values of queries as strings and converts them to
+ * an array that can be used as $conds in methods like
+ * DataBase::select( $table, $a, $conds )
+ *
+ * @package WikidataQuality\ViolationQuery
+ * @author BP2014N1
+ * @license GNU GPL v2+
+ */
+class ViolationQuery {
+
+ /**
+ * Holds all conditions that were set
+ *
+ * @var array
+ */
+ private $conditions = array ();
+
+ /**
+ * Holds column names in VIOLATION_TABLE
+ *
+ * @var array
+ */
+ private $keys = array (
+ 'entityId' => 'entity_id',
+ 'propertyId' => 'pid',
+ 'claimGuid' => 'claim_guid',
+ 'constraintClaimGuid' => 'constraint_claim_guid',
+ 'constraintTypeEntityId' => 'constraint_type_entity_id',
+ 'additionalInfo' => 'additional_info',
+ 'updatedAt' => 'updated_at',
+ 'revisionId' => 'revision_id',
+ 'status' => 'status'
+ );
+
+ /**
+ * Returns array that works with DataBase::select and similar methods
+ *
+ * @return array
+ */
+ public function toArray() {
+ $conditionArray = array ();
+ foreach ( $this->conditions as $condition ) {
+ $conditionArray[ ] = $condition;
+ }
+ return $conditionArray;
+ }
+
+ /**
+ * @param $entityId
+ */
+ public function setEntityId( $entityId ) {
+ $this->testParamType( $entityId, __FUNCTION__ );
+ $key = $this->keys[ 'entityId' ];
+ $this->conditions[ $key ] = $key . '="' . $entityId . '"';
+ }
+
+ public function unsetEntityId() {
+ unset( $this->conditions[ $this->keys[ 'entityId' ] ] );
+ }
+
+ /**
+ * @param $propertyId
+ */
+ public function setPropertyId( $propertyId ) {
+ $this->testParamType( $propertyId, __FUNCTION__ );
+ $key = $this->keys[ 'propertyId' ];
+ $this->conditions[ $key ] = $key . '="' . $propertyId . '"';
+ }
+
+ public function unsetPropertyId() {
+ unset( $this->conditions[ $this->keys[ 'propertyId' ] ] );
+ }
+
+ /**
+ * @param $claimGuid
+ */
+ public function setClaimGuid( $claimGuid ) {
+ $this->testParamType( $claimGuid, __FUNCTION__ );
+ $key = $this->keys[ 'claimGuid' ];
+ $this->conditions[ $key ] = $key . '="' . $claimGuid . '"';
+ }
+
+ public function unsetClaimGuid() {
+ unset( $this->conditions[ $this->keys[ 'claimGuid' ] ] );
+ }
+
+ /**
+ * @param $constraintClaimGuid
+ */
+ public function setConstraintClaimGuid( $constraintClaimGuid ) {
+ $this->testParamType( $constraintClaimGuid, __FUNCTION__ );
+ $key = $this->keys[ 'constraintClaimGuid' ];
+ $this->conditions[ $key ] = $key . '="' . $constraintClaimGuid
. '"';
+ }
+
+ public function unsetConstraintClaimGuid() {
+ unset( $this->conditions[ $this->keys[ 'constraintClaimGuid' ]
] );
+ }
+
+ /**
+ * @param $constraintTypeEntityId
+ */
+ public function setConstraintTypeEntityId( $constraintTypeEntityId ) {
+ $this->testParamType( $constraintTypeEntityId, __FUNCTION__ );
+ $key = $this->keys[ 'constraintTypeEntityId' ];
+ $this->conditions[ $key ] = $key . '="' .
$constraintTypeEntityId . '"';
+ }
+
+ public function unsetConstraintTypeEntityId() {
+ unset( $this->conditions[ $this->keys[ 'constraintTypeEntityId'
] ] );
+ }
+
+ /**
+ * @param $additionalInfo
+ */
+ public function setAdditionalInfo( $additionalInfo ) {
+ $this->testParamType( $additionalInfo, __FUNCTION__ );
+ $key = $this->keys[ 'additionalInfo' ];
+ $this->conditions[ $key ] = $key . '="' . $additionalInfo . '"';
+ }
+
+ public function unsetAdditionalInfo() {
+ unset( $this->conditions[ $this->keys[ 'additionalInfo' ] ] );
+ }
+
+ /**
+ * @param $updatedAt
+ */
+ public function setUpdatedAt( $updatedAt ) {
+ $this->testParamType( $updatedAt, __FUNCTION__ );
+ $key = $this->keys[ 'updatedAt' ];
+ $this->conditions[ $key ] = $key . '="' . $updatedAt . '"';
+ }
+
+ public function unsetUpdatedAt() {
+ unset( $this->conditions[ $this->keys[ 'updatedAt' ] ] );
+ }
+
+ /**
+ * @param $revisionId
+ */
+ public function setRevisionId( $revisionId ) {
+ $this->testParamType( $revisionId, __FUNCTION__ );
+ $key = $this->keys[ 'revisionId' ];
+ $this->conditions[ $key ] = $key . '="' . $revisionId . '"';
+ }
+
+ public function unsetRevisionId() {
+ unset( $this->conditions[ $this->keys[ 'revisionId' ] ] );
+ }
+
+ /**
+ * @param $status
+ */
+ public function setStatus( $status ) {
+ $this->testParamType( $status, __FUNCTION__ );
+ $key = $this->keys[ 'status' ];
+ $this->conditions[ $key ] = $key . '="' . $status . '"';
+ }
+
+ public function unsetStatus() {
+ unset( $this->conditions[ $this->keys[ 'status' ] ] );
+ }
+
+ private function testParamType( $param, $function ) {
+ if ( !is_string( $param ) ) {
+ throw new InvalidArgumentException( "Input of $function
has to be of type string" );
+ }
+ }
+}
\ No newline at end of file
diff --git a/includes/Violations/ViolationStore.php
b/includes/Violations/ViolationStore.php
index f750d60..1cdb6d9 100644
--- a/includes/Violations/ViolationStore.php
+++ b/includes/Violations/ViolationStore.php
@@ -36,11 +36,11 @@
foreach ( $violations as $violation ) {
$updatedAt = wfTimestamp( TS_MW );
$accumulator = array (
- 'entity_id' => $violation->getEntityId(),
- 'pid' => $violation->getPropertyId(),
+ 'entity_id' =>
$violation->getEntityId()->getSerialization(),
+ 'pid' =>
$violation->getPropertyId()->getSerialization(),
'claim_guid' => $violation->getClaimGuid(),
'constraint_claim_guid' =>
$violation->getConstraintClaimGuid(),
- 'constraint_type_entity_id' =>
$violation->getConstraintTypeEntityId(),
+ 'constraint_type_entity_id' =>
$violation->getConstraintTypeEntityId()->getSerialization(),
'additional_info' =>
$violation->getAdditionalInfo(),
'updated_at' => $updatedAt,
'revision_id' => $violation->getRevisionId(),
diff --git a/tests/phpunit/Violations/ViolationLookupTest.php
b/tests/phpunit/Violations/ViolationLookupTest.php
index d2eac96..822acfc 100644
--- a/tests/phpunit/Violations/ViolationLookupTest.php
+++ b/tests/phpunit/Violations/ViolationLookupTest.php
@@ -3,12 +3,14 @@
namespace WikidataQuality\Tests\Violation;
use WikidataQuality\Violations\ViolationLookup;
+use WikidataQuality\Violations\ViolationQuery;
/**
* @covers WikidataQuality\Violations\ViolationLookup
*
* @uses WikidataQuality\Violations\Violation
+ * @uses WikidataQuality\Violations\ViolationQuery
*
* @group database
* @group medium
@@ -18,24 +20,36 @@
*/
class ViolationLookupTest extends \MediaWikiTestCase {
- public function testGet( ) {
+ public function testGetOne( ) {
$violationLookup = new ViolationLookup();
+ $violationQuery = new ViolationQuery();
- $queryResult = $violationLookup->getWhere( array( 'entity_id'
=> 'Q42') );
- $this->assertEquals( 3, count( $queryResult ) );
+ $violationQuery->setClaimGuid( 'P13$1-2-3-4' );
+ $violationQuery->setConstraintClaimGuid( 'P667$1-2-3-4' );
- $queryResult = $violationLookup->getWhere( array( 'claim_guid'
=> 'P13$1-2-3-4', 'constraint_claim_guid' => 'P667$1-2-3-4' ) );
+ $queryResult = $violationLookup->getWhere( $violationQuery );
$this->assertEquals( 1, count( $queryResult ) );
$this->assertEquals( 'second', $queryResult[ 0
]->getAdditionalInfo() );
-
- $queryResult = $violationLookup->getWhere( array( 'status' =>
'exception' ) );
- $this->assertNull( $queryResult );
}
- public function testGetWithInvalidArguments() {
+ public function testGetMultiple() {
$violationLookup = new ViolationLookup();
- $this->setExpectedException( 'InvalidArgumentException' );
- $violationLookup->getWhere( array( 'pid' => 'P42',
'constraint_type_entity_id' => 1234 ) );
+ $violationQuery = new ViolationQuery();
+
+ $violationQuery->setEntityId( 'Q42' );
+
+ $queryResult = $violationLookup->getWhere( $violationQuery );
+ $this->assertEquals( 3, count( $queryResult ) );
+ }
+
+ public function testGetNull() {
+ $violationLookup = new ViolationLookup();
+ $violationQuery = new ViolationQuery();
+
+ $violationQuery->setStatus( 'exception' );
+
+ $queryResult = $violationLookup->getWhere( $violationQuery );
+ $this->assertNull( $queryResult );
}
public function addDBData() {
diff --git a/tests/phpunit/Violations/ViolationQueryTest.php
b/tests/phpunit/Violations/ViolationQueryTest.php
new file mode 100644
index 0000000..d42a4a6
--- /dev/null
+++ b/tests/phpunit/Violations/ViolationQueryTest.php
@@ -0,0 +1,103 @@
+<?php
+
+
+namespace WikidataQuality\Tests\Violation;
+
+use WikidataQuality\Violations\ViolationQuery;
+
+
+/**
+ * @covers WikidataQuality\Violations\ViolationQuery
+ *
+ * @author BP2014N1
+ * @license GNU GPL v2+
+ */
+class ViolationQueryTest extends \MediaWikiTestCase {
+
+ public function testSetters() {
+ $queryCondition = new ViolationQuery();
+
+ $queryCondition->setEntityId( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'entity_id="value"', $conditionArray[ 0 ],
"Test EntityIdSetter" );
+
+ $queryCondition->setPropertyId( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'pid="value"', $conditionArray[ 1 ], "Test
PropertyIdSetter" );
+
+ $queryCondition->setConstraintClaimGuid( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'constraint_claim_guid="value"',
$conditionArray[ 2 ], "Test ConstraintClaimGuidSetter" );
+
+ $queryCondition->setConstraintTypeEntityId( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'constraint_type_entity_id="value"',
$conditionArray[ 3 ], "Test ConstraintTypeEntityIdSetter" );
+
+ $queryCondition->setAdditionalInfo( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'additional_info="value"',
$conditionArray[ 4 ], "Test AdditionalInfoSetter" );
+
+ $queryCondition->setUpdatedAt( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'updated_at="value"', $conditionArray[ 5
], "Test UpdatedAtSetter" );
+
+ $queryCondition->setRevisionId( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'revision_id="value"', $conditionArray[ 6
], "Test RevisionIdSetter" );
+
+ $queryCondition->setStatus( 'value' );
+ $conditionArray = $queryCondition->toArray();
+ $this->assertEquals( 'status="value"', $conditionArray[ 7 ],
"Test StatusSetter" );
+ }
+
+ public function testSettersWithInvalidArguments() {
+ $queryCondition = new ViolationQuery();
+
+ $this->setExpectedException( 'InvalidArgumentException' );
+ $queryCondition->setEntityId( 1234 );
+ }
+
+ public function testUnsetters() {
+ $queryCondition = new ViolationQuery();
+ $queryCondition->setEntityId( 'value' );
+ $queryCondition->setPropertyId( 'value' );
+ $queryCondition->setClaimGuid( 'value' );
+ $queryCondition->setConstraintClaimGuid( 'value' );
+ $queryCondition->setConstraintTypeEntityId( 'value' );
+ $queryCondition->setAdditionalInfo( 'value' );
+ $queryCondition->setUpdatedAt( 'value' );
+ $queryCondition->setRevisionId( 'value' );
+ $queryCondition->setStatus( 'value' );
+
+ $count = count( $queryCondition->toArray() );
+
+ $queryCondition->unsetEntityId();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test EntityIdUnsetter" );
+
+ $queryCondition->unsetPropertyId();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test PropertyIdUnsetter" );
+
+ $queryCondition->unsetClaimGuid();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test ClaimGuidUnsetter" );
+
+ $queryCondition->unsetConstraintClaimGuid();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test ConstraintClaimGuidUnsetter" );
+
+ $queryCondition->unsetConstraintTypeEntityId();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test ConstraintTypeEntityIdUnsetter" );
+
+ $queryCondition->unsetAdditionalInfo();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test AdditionalInfoUnsetter" );
+
+ $queryCondition->unsetUpdatedAt();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test UpdatedAtUnsetter" );
+
+ $queryCondition->unsetRevisionId();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test RevisionIdUnsetter" );
+
+ $queryCondition->unsetStatus();
+ $this->assertEquals( --$count, count(
$queryCondition->toArray()), "Test StatusUnsetter" );
+
+ $this->assertEquals( 0, $count );
+ }
+}
diff --git a/tests/phpunit/Violations/ViolationStoreTest.php
b/tests/phpunit/Violations/ViolationStoreTest.php
index 10eca25..1a7a275 100644
--- a/tests/phpunit/Violations/ViolationStoreTest.php
+++ b/tests/phpunit/Violations/ViolationStoreTest.php
@@ -36,19 +36,22 @@
$violationStore->removeViolationWith( 'P13$1-2-3-4',
'P666$1-2-3-4' );
- // Doc: dbSelectRow return
$actual = $this->db->selectRow( VIOLATION_TABLE, array (
'claim_guid',
'constraint_claim_guid'
), array ( 'claim_guid="P13$1-2-3-4"',
'constraint_claim_guid="P666$1-2-3-4"' ) );
$this->assertFalse( $actual );
+ }
+
+ public function testRemoveViolationWithInvalidArguments() {
+ $violationStore = new ViolationStore();
$this->setExpectedException( 'InvalidArgumentException' );
$violationStore->removeViolationWith( '1234', 1234 );
$violationStore->removeViolationWith( 1234, '1234' );
}
- public function testInsertViolation() {
+ public function testInsertNewViolation() {
$violationStore = new ViolationStore();
$pid = new PropertyId( 'P13' );
@@ -71,8 +74,19 @@
'constraint_claim_guid'
), array ( 'claim_guid="P13$1-2-3-4"' ) )->numRows();
$this->assertEquals( $count + 2, $newCount );
+ }
+ public function testUpdateViolation() {
+ $violationStore = new ViolationStore();
+
+ $pid = new PropertyId( 'P13' );
+ $claimGuid = 'P13$1-2-3-4';
+ $snak = new PropertyValueSnak( $pid, new StringValue( 'abcd' )
);
+ $claim = new Claim( $snak );
+ $statement = new Statement( $claim );
+ $statement->setGuid( $claimGuid );
$violation = new Violation( new ItemId( 'Q42' ), $statement,
'P666$1-2-3-4', new ItemId( 'Q666' ), 1234, 'unverified' );
+
$violationStore->insertViolation( array ( $violation ) );
$updated = $this->db->selectRow( VIOLATION_TABLE, array(
'status', 'updated_at' ), array (
@@ -81,6 +95,18 @@
) );
$this->assertEquals( 'unverified', $updated->status );
$this->assertNotEquals( '20141015150000', $updated->updated_at
);
+ }
+
+ public function testInsertViolationWithInvalidArguments() {
+ $violationStore = new ViolationStore();
+
+ $pid = new PropertyId( 'P13' );
+ $claimGuid = 'P13$1-2-3-4';
+ $snak = new PropertyValueSnak( $pid, new StringValue( 'abcd' )
);
+ $claim = new Claim( $snak );
+ $statement = new Statement( $claim );
+ $statement->setGuid( $claimGuid );
+ $violation = new Violation( new ItemId( 'Q42' ), $statement,
'P666$1-2-3-4', new ItemId( 'Q666' ), 1234, 'unverified' );
$this->setExpectedException( 'InvalidArgumentException' );
$violationStore->insertViolation( array ( $violation, 'abcd' )
);
diff --git a/tests/phpunit/Violations/ViolationTest.php
b/tests/phpunit/Violations/ViolationTest.php
index 60b9f4b..6f644e6 100644
--- a/tests/phpunit/Violations/ViolationTest.php
+++ b/tests/phpunit/Violations/ViolationTest.php
@@ -38,7 +38,7 @@
$this->assertEquals( $revisionId, $violation->getRevisionId() );
$this->assertEquals( $status, $violation->getStatus() );
$this->assertEquals( $additionalInfo,
$violation->getAdditionalInfo() );
- if ($updatedAt) {
+ if ( $updatedAt ) {
$this->assertEquals( wfTimestamp( TS_MW, $updatedAt ),
$violation->getUpdatedAt() );
} else {
$this->assertEquals( null, $violation->getUpdatedAt() );
@@ -58,8 +58,8 @@
$revisionId = 1234;
$status = 'verified';
- return array(
- array(
+ return array (
+ array (
$entityId,
$statement,
$constraintClaimGuid,
@@ -69,7 +69,7 @@
'{"type":"JSON", "mandatory":false}',
'2014-10-15T15:00:00Z'
),
- array(
+ array (
$entityId,
$statement,
$constraintClaimGuid,
@@ -79,9 +79,9 @@
null,
null
),
- array(
+ array (
$entityId,
- array( 'pid' => 'P1', 'claimGuid' => $claimGuid
),
+ array ( 'pid' => new PropertyId( 'P1' ),
'claimGuid' => $claimGuid ),
$constraintClaimGuid,
$constraintTypeEntityId,
$revisionId,
@@ -98,7 +98,7 @@
public function testConstructWithInvalidArguments( $entityId,
$statement, $constraintClaimGuid, $constraintTypeEntityId, $revisionId,
$status, $additionalInfo, $updatedAt ) {
$this->setExpectedException( 'InvalidArgumentException' );
- $violation = new Violation( $entityId, $statement,
$constraintClaimGuid, $constraintTypeEntityId, $revisionId, $status,
$additionalInfo, $updatedAt );
+ new Violation( $entityId, $statement, $constraintClaimGuid,
$constraintTypeEntityId, $revisionId, $status, $additionalInfo, $updatedAt );
}
public function invalidArgumentsProvider() {
@@ -114,8 +114,8 @@
$revisionId = 1234;
$status = 'verified';
- return array(
- array(
+ return array (
+ array (
$entityId,
1234,
$constraintClaimGuid,
@@ -125,7 +125,27 @@
null,
null
),
- array(
+ array (
+ $entityId,
+ array( 'pid' => '1234', 'claimGuid' => '1234' ),
+ $constraintClaimGuid,
+ $constraintTypeEntityId,
+ $revisionId,
+ $status,
+ null,
+ null
+ ),
+ array (
+ $entityId,
+ array( 'pid' => new PropertyId( 'P1234' ),
'claimGuid' => 1234 ),
+ $constraintClaimGuid,
+ $constraintTypeEntityId,
+ $revisionId,
+ $status,
+ null,
+ null
+ ),
+ array (
$entityId,
$statement,
1234,
@@ -135,7 +155,7 @@
null,
null
),
- array(
+ array (
$entityId,
$statement,
$constraintClaimGuid,
@@ -145,7 +165,7 @@
null,
null
),
- array(
+ array (
$entityId,
$statement,
$constraintClaimGuid,
@@ -155,7 +175,7 @@
null,
null
),
- array(
+ array (
$entityId,
$statement,
$constraintClaimGuid,
@@ -165,7 +185,7 @@
1234,
null
),
- array(
+ array (
$entityId,
$statement,
$constraintClaimGuid,
--
To view, visit https://gerrit.wikimedia.org/r/203841
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie0de8568b391c27fe9bf0e03b92787cda623ad63
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataQuality
Gerrit-Branch: master
Gerrit-Owner: Tamslo <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits