jenkins-bot has submitted this change and it was merged.
Change subject: Remove carriage returns
......................................................................
Remove carriage returns
Change-Id: If21904603bd95ce5c2fbe7f1a6b1a8ae6aca38fa
---
M includes/ConstraintReportFactory.php
M tests/phpunit/ConstraintReportFactoryTest.php
M tests/phpunit/DelegatingConstraintCheckerTest.php
3 files changed, 475 insertions(+), 475 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/ConstraintReportFactory.php
b/includes/ConstraintReportFactory.php
index 7301281..b789700 100755
--- a/includes/ConstraintReportFactory.php
+++ b/includes/ConstraintReportFactory.php
@@ -1,163 +1,163 @@
-<?php
-
-namespace WikibaseQuality\ConstraintReport;
-
-use Wikibase\DataModel\Services\Lookup\EntityLookup;
-use Wikibase\Repo\WikibaseRepo;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\CommonsLinkChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\FormatChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\OneOfChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifierChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TypeChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ConflictsWithChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifiersChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TargetRequiredClaimChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ItemChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MandatoryQualifiersChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SymmetricChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\InverseChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\DiffWithinRangeChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\UniqueValueChecker;
-use
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper;
-use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper;
-
-
-class ConstraintReportFactory {
-
- /**
- * @var constraintRepository
- */
- private $constraintRepository;
-
- /**
- * @var array
- */
- private $constraintCheckerMap;
-
- /**
- * @var DelegatingConstraintChecker
- */
- private $delegatingConstraintChecker;
-
- /**
- * @var EntityLookup
- */
- private $lookup;
-
- /**
- * @var array
- */
- private $constraintParameterMap;
-
- /**
- * Returns the default instance.
- * IMPORTANT: Use only when it is not feasible to inject an instance
properly.
- *
- * @return ConstraintReportFactory
- */
- public static function getDefaultInstance() {
- static $instance = null;
-
- if ( $instance === null ) {
- $instance = new self(
WikibaseRepo::getDefaultInstance()->getEntityLookup() );
- }
-
- return $instance;
- }
-
- /**
- * @param EntityLookup $lookup
- */
- public function __construct( EntityLookup $lookup ) {
- $this->lookup = $lookup;
- }
-
- /**
- * @return DelegatingConstraintChecker
- */
- public function getConstraintChecker() {
- if ( $this->delegatingConstraintChecker === null ) {
- $this->delegatingConstraintChecker = new
DelegatingConstraintChecker( $this->lookup, $this->getConstraintCheckerMap(
$this->lookup ) );
- }
-
- return $this->delegatingConstraintChecker;
- }
-
- /**
- * @return array
- */
- private function getConstraintCheckerMap(){
- if ( $this->constraintCheckerMap === null ) {
- $constraintParameterParser = new
ConstraintParameterParser();
- $connectionCheckerHelper = new
ConnectionCheckerHelper();
- $rangeCheckerHelper = new RangeCheckerHelper();
- $typeCheckerHelper = new TypeCheckerHelper(
$this->lookup );
-
- $this->constraintCheckerMap = array(
- 'Conflicts with' => new ConflictsWithChecker(
$this->lookup, $constraintParameterParser, $connectionCheckerHelper ),
- 'Item' => new ItemChecker( $this->lookup,
$constraintParameterParser, $connectionCheckerHelper ),
- 'Target required claim' => new
TargetRequiredClaimChecker( $this->lookup, $constraintParameterParser,
$connectionCheckerHelper ),
- 'Symmetric' => new SymmetricChecker(
$this->lookup, $constraintParameterParser, $connectionCheckerHelper ),
- 'Inverse' => new InverseChecker( $this->lookup,
$constraintParameterParser, $connectionCheckerHelper ),
- 'Qualifier' => new QualifierChecker(
$constraintParameterParser ),
- 'Qualifiers' => new QualifiersChecker(
$constraintParameterParser ),
- 'Mandatory qualifiers' => new
MandatoryQualifiersChecker( $constraintParameterParser ),
- 'Range' => new RangeChecker(
$constraintParameterParser, $rangeCheckerHelper ),
- 'Diff within range' => new
DiffWithinRangeChecker( $constraintParameterParser, $rangeCheckerHelper ),
- 'Type' => new TypeChecker( $this->lookup,
$constraintParameterParser, $typeCheckerHelper ),
- 'Value type' => new ValueTypeChecker(
$this->lookup, $constraintParameterParser, $typeCheckerHelper ),
- 'Single value' => new SingleValueChecker(),
- 'Multi value' => new MultiValueChecker(),
- 'Unique value' => new UniqueValueChecker(),
- 'Format' => new FormatChecker(
$constraintParameterParser ),
- 'Commons link' => new CommonsLinkChecker(
$constraintParameterParser ),
- 'One of' => new OneOfChecker(
$constraintParameterParser ),
- );
- }
-
- return $this->constraintCheckerMap;
- }
-
- public function getConstraintParameterMap() {
- if ( $this->constraintParameterMap === null ) {
- $this->constraintParameterMap = array(
- 'Commons link' => array( 'namespace' ),
- 'Conflicts with' => array( 'property', 'item' ),
- 'Diff within range' => array( 'property',
'minimum_quantity', 'maximum_quantity' ),
- 'Format' => array( 'pattern' ),
- 'Inverse' => array( 'property' ),
- 'Item' => array( 'property', 'item' ),
- 'Mandatory qualifiers' => array( 'property' ),
- 'Multi value' => array(),
- 'One of' => array( 'item' ),
- 'Qualifier' => array(),
- 'Qualifiers' => array( 'property' ),
- 'Range' => array( 'minimum_quantity',
'maximum_quantity', 'minimum_date', 'maximum_date' ),
- 'Single value' => array(),
- 'Symmetric' => array(),
- 'Target required claim' => array( 'property',
'item' ),
- 'Type' => array( 'class', 'relation' ),
- 'Unique value' => array(),
- 'Value type' => array( 'class', 'relation' )
- );
- }
-
- return $this->constraintParameterMap;
- }
-
- public function getConstraintRepository() {
- if ( $this->constraintRepository === null ) {
- $this->constraintRepository = new ConstraintRepository(
CONSTRAINT_TABLE );
- }
-
- return $this->constraintRepository;
- }
-
+<?php
+
+namespace WikibaseQuality\ConstraintReport;
+
+use Wikibase\DataModel\Services\Lookup\EntityLookup;
+use Wikibase\Repo\WikibaseRepo;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\CommonsLinkChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\FormatChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\OneOfChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifierChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TypeChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ConflictsWithChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifiersChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TargetRequiredClaimChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ItemChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MandatoryQualifiersChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SymmetricChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\InverseChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\DiffWithinRangeChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\UniqueValueChecker;
+use
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper;
+use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\TypeCheckerHelper;
+
+
+class ConstraintReportFactory {
+
+ /**
+ * @var constraintRepository
+ */
+ private $constraintRepository;
+
+ /**
+ * @var array
+ */
+ private $constraintCheckerMap;
+
+ /**
+ * @var DelegatingConstraintChecker
+ */
+ private $delegatingConstraintChecker;
+
+ /**
+ * @var EntityLookup
+ */
+ private $lookup;
+
+ /**
+ * @var array
+ */
+ private $constraintParameterMap;
+
+ /**
+ * Returns the default instance.
+ * IMPORTANT: Use only when it is not feasible to inject an instance
properly.
+ *
+ * @return ConstraintReportFactory
+ */
+ public static function getDefaultInstance() {
+ static $instance = null;
+
+ if ( $instance === null ) {
+ $instance = new self(
WikibaseRepo::getDefaultInstance()->getEntityLookup() );
+ }
+
+ return $instance;
+ }
+
+ /**
+ * @param EntityLookup $lookup
+ */
+ public function __construct( EntityLookup $lookup ) {
+ $this->lookup = $lookup;
+ }
+
+ /**
+ * @return DelegatingConstraintChecker
+ */
+ public function getConstraintChecker() {
+ if ( $this->delegatingConstraintChecker === null ) {
+ $this->delegatingConstraintChecker = new
DelegatingConstraintChecker( $this->lookup, $this->getConstraintCheckerMap(
$this->lookup ) );
+ }
+
+ return $this->delegatingConstraintChecker;
+ }
+
+ /**
+ * @return array
+ */
+ private function getConstraintCheckerMap(){
+ if ( $this->constraintCheckerMap === null ) {
+ $constraintParameterParser = new
ConstraintParameterParser();
+ $connectionCheckerHelper = new
ConnectionCheckerHelper();
+ $rangeCheckerHelper = new RangeCheckerHelper();
+ $typeCheckerHelper = new TypeCheckerHelper(
$this->lookup );
+
+ $this->constraintCheckerMap = array(
+ 'Conflicts with' => new ConflictsWithChecker(
$this->lookup, $constraintParameterParser, $connectionCheckerHelper ),
+ 'Item' => new ItemChecker( $this->lookup,
$constraintParameterParser, $connectionCheckerHelper ),
+ 'Target required claim' => new
TargetRequiredClaimChecker( $this->lookup, $constraintParameterParser,
$connectionCheckerHelper ),
+ 'Symmetric' => new SymmetricChecker(
$this->lookup, $constraintParameterParser, $connectionCheckerHelper ),
+ 'Inverse' => new InverseChecker( $this->lookup,
$constraintParameterParser, $connectionCheckerHelper ),
+ 'Qualifier' => new QualifierChecker(
$constraintParameterParser ),
+ 'Qualifiers' => new QualifiersChecker(
$constraintParameterParser ),
+ 'Mandatory qualifiers' => new
MandatoryQualifiersChecker( $constraintParameterParser ),
+ 'Range' => new RangeChecker(
$constraintParameterParser, $rangeCheckerHelper ),
+ 'Diff within range' => new
DiffWithinRangeChecker( $constraintParameterParser, $rangeCheckerHelper ),
+ 'Type' => new TypeChecker( $this->lookup,
$constraintParameterParser, $typeCheckerHelper ),
+ 'Value type' => new ValueTypeChecker(
$this->lookup, $constraintParameterParser, $typeCheckerHelper ),
+ 'Single value' => new SingleValueChecker(),
+ 'Multi value' => new MultiValueChecker(),
+ 'Unique value' => new UniqueValueChecker(),
+ 'Format' => new FormatChecker(
$constraintParameterParser ),
+ 'Commons link' => new CommonsLinkChecker(
$constraintParameterParser ),
+ 'One of' => new OneOfChecker(
$constraintParameterParser ),
+ );
+ }
+
+ return $this->constraintCheckerMap;
+ }
+
+ public function getConstraintParameterMap() {
+ if ( $this->constraintParameterMap === null ) {
+ $this->constraintParameterMap = array(
+ 'Commons link' => array( 'namespace' ),
+ 'Conflicts with' => array( 'property', 'item' ),
+ 'Diff within range' => array( 'property',
'minimum_quantity', 'maximum_quantity' ),
+ 'Format' => array( 'pattern' ),
+ 'Inverse' => array( 'property' ),
+ 'Item' => array( 'property', 'item' ),
+ 'Mandatory qualifiers' => array( 'property' ),
+ 'Multi value' => array(),
+ 'One of' => array( 'item' ),
+ 'Qualifier' => array(),
+ 'Qualifiers' => array( 'property' ),
+ 'Range' => array( 'minimum_quantity',
'maximum_quantity', 'minimum_date', 'maximum_date' ),
+ 'Single value' => array(),
+ 'Symmetric' => array(),
+ 'Target required claim' => array( 'property',
'item' ),
+ 'Type' => array( 'class', 'relation' ),
+ 'Unique value' => array(),
+ 'Value type' => array( 'class', 'relation' )
+ );
+ }
+
+ return $this->constraintParameterMap;
+ }
+
+ public function getConstraintRepository() {
+ if ( $this->constraintRepository === null ) {
+ $this->constraintRepository = new ConstraintRepository(
CONSTRAINT_TABLE );
+ }
+
+ return $this->constraintRepository;
+ }
+
}
\ No newline at end of file
diff --git a/tests/phpunit/ConstraintReportFactoryTest.php
b/tests/phpunit/ConstraintReportFactoryTest.php
index 24a147a..9d48b9c 100755
--- a/tests/phpunit/ConstraintReportFactoryTest.php
+++ b/tests/phpunit/ConstraintReportFactoryTest.php
@@ -1,44 +1,44 @@
-<?php
-
-namespace WikibaseQuality\ConstraintReport\Test;
-
-use WikibaseQuality\ConstraintReport\ConstraintReportFactory;
-
-
-/**
- * @covers WikibaseQuality\ConstraintReport\ConstraintReportFactory
- *
- * @group WikibaseQualityConstraints
- *
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class ConstraintReportFactoryTest extends \MediaWikiTestCase {
-
- public function testGetMap() {
- $map =
ConstraintReportFactory::getDefaultInstance()->getConstraintParameterMap();
- $this->assertEquals( array( 'pattern' ), $map['Format'] );
- }
-
- public function testGetDefaultInstance() {
- $this->assertInstanceOf(
-
'WikibaseQuality\ConstraintReport\ConstraintReportFactory',
- ConstraintReportFactory::getDefaultInstance()
- );
- }
-
- public function testGetConstraintRepository() {
- $this->assertInstanceOf(
- 'WikibaseQuality\ConstraintReport\ConstraintRepository',
-
ConstraintReportFactory::getDefaultInstance()->getConstraintRepository()
- );
- }
-
- public function testGetConstraintChecker() {
- $this->assertInstanceOf(
-
'WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker',
-
ConstraintReportFactory::getDefaultInstance()->getConstraintChecker()
- );
- }
-
+<?php
+
+namespace WikibaseQuality\ConstraintReport\Test;
+
+use WikibaseQuality\ConstraintReport\ConstraintReportFactory;
+
+
+/**
+ * @covers WikibaseQuality\ConstraintReport\ConstraintReportFactory
+ *
+ * @group WikibaseQualityConstraints
+ *
+ * @author BP2014N1
+ * @license GNU GPL v2+
+ */
+class ConstraintReportFactoryTest extends \MediaWikiTestCase {
+
+ public function testGetMap() {
+ $map =
ConstraintReportFactory::getDefaultInstance()->getConstraintParameterMap();
+ $this->assertEquals( array( 'pattern' ), $map['Format'] );
+ }
+
+ public function testGetDefaultInstance() {
+ $this->assertInstanceOf(
+
'WikibaseQuality\ConstraintReport\ConstraintReportFactory',
+ ConstraintReportFactory::getDefaultInstance()
+ );
+ }
+
+ public function testGetConstraintRepository() {
+ $this->assertInstanceOf(
+ 'WikibaseQuality\ConstraintReport\ConstraintRepository',
+
ConstraintReportFactory::getDefaultInstance()->getConstraintRepository()
+ );
+ }
+
+ public function testGetConstraintChecker() {
+ $this->assertInstanceOf(
+
'WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker',
+
ConstraintReportFactory::getDefaultInstance()->getConstraintChecker()
+ );
+ }
+
}
\ No newline at end of file
diff --git a/tests/phpunit/DelegatingConstraintCheckerTest.php
b/tests/phpunit/DelegatingConstraintCheckerTest.php
index 3ec2e6b..b04e6aa 100755
--- a/tests/phpunit/DelegatingConstraintCheckerTest.php
+++ b/tests/phpunit/DelegatingConstraintCheckerTest.php
@@ -1,271 +1,271 @@
-<?php
-
-namespace WikibaseQuality\ConstraintReport\Test\ConstraintChecker;
-
-use Wikibase\DataModel\Entity\ItemId;
-use WikibaseQuality\ConstraintReport\ConstraintReportFactory;
-use WikibaseQuality\Tests\Helper\JsonFileEntityLookup;
-
-
-/**
- * @covers
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker
- *
- * @group WikibaseQualityConstraints
- * @group Database
- *
- * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\DiffWithinRangeChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\UniqueValueChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\OneOfChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\CommonsLinkChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TargetRequiredClaimChecker
- * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ItemChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ConflictsWithChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SymmetricChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\InverseChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\FormatChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifierChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifiersChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MandatoryQualifiersChecker
- * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TypeChecker
- * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker
- *
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class DelegatingConstraintCheckerTest extends \MediaWikiTestCase {
-
- private $constraintChecker;
- private $lookup;
-
- protected function setUp() {
- parent::setUp();
- $this->lookup = new JsonFileEntityLookup( __DIR__ );
- $factory = new ConstraintReportFactory( $this->lookup );
- $this->constraintChecker = $factory->getConstraintChecker();
-
- // specify database tables used by this test
- $this->tablesUsed[ ] = CONSTRAINT_TABLE;
- }
-
- protected function tearDown() {
- unset( $this->lookup );
- unset( $this->constraintChecker );
- parent::tearDown();
- }
-
- /**
- * Adds temporary test data to database.
- *
- * @throws \DBUnexpectedError
- */
- public function addDBData() {
- $this->db->delete(
- CONSTRAINT_TABLE,
- '*'
- );
-
- $this->db->insert(
- CONSTRAINT_TABLE,
- array (
- array (
- 'constraint_guid' => '13',
- 'pid' => 1,
- 'constraint_type_qid' => 'Commons link',
- 'constraint_parameters' => json_encode(
- array ( 'namespace' => 'File' )
)
- ),
- array (
- 'constraint_guid' => '19',
- 'pid' => 10,
- 'constraint_type_qid' => 'Commons link',
- 'constraint_parameters' => json_encode(
- array (
- 'namespace' => 'File',
- 'known_exception' =>
'Q5'
- ) )
- ),
- array (
- 'constraint_guid' => '20',
- 'pid' => 1,
- 'constraint_type_qid' => 'Mandatory
qualifiers',
- 'constraint_parameters' => json_encode(
- array ( 'property' => 'P2' ) )
- ),
- array (
- 'constraint_guid' => '14',
- 'pid' => 1,
- 'constraint_type_qid' => 'Conflicts
with',
- 'constraint_parameters' => json_encode(
- array ( 'property' => 'P2' ) )
- ),
- array (
- 'constraint_guid' => '15',
- 'pid' => 1,
- 'constraint_type_qid' => 'Inverse',
- 'constraint_parameters' => json_encode(
- array ( 'property' => 'P2' ) )
- ),
- array (
- 'constraint_guid' => '16',
- 'pid' => 1,
- 'constraint_type_qid' => 'Qualifiers',
- 'constraint_parameters' => json_encode(
- array ( 'property' => 'P2,P3' )
)
- ),
- array (
- 'constraint_guid' => '17',
- 'pid' => 1,
- 'constraint_type_qid' => 'Diff within
range',
- 'constraint_parameters' => json_encode(
- array (
- 'property' => 'P2',
- 'minimum_quantity' => 0,
- 'maximum_quantity' =>
150
- ) )
- ),
- array (
- 'constraint_guid' => '18',
- 'pid' => 1,
- 'constraint_type_qid' => 'Format',
- 'constraint_parameters' => json_encode(
- array ( 'pattern' => '[0-9]' ) )
- ),
- array (
- 'constraint_guid' => '1',
- 'pid' => 1,
- 'constraint_type_qid' => 'Multi value',
- 'constraint_parameters' => '{}'
- ),
- array (
- 'constraint_guid' => '2',
- 'pid' => 1,
- 'constraint_type_qid' => 'Unique value',
- 'constraint_parameters' => '{}'
- ),
- array (
- 'constraint_guid' => '3',
- 'pid' => 1,
- 'constraint_type_qid' => 'Single value',
- 'constraint_parameters' => '{}'
- ),
- array (
- 'constraint_guid' => '4',
- 'pid' => 1,
- 'constraint_type_qid' => 'Symmetric',
- 'constraint_parameters' => '{}'
- ),
- array (
- 'constraint_guid' => '5',
- 'pid' => 1,
- 'constraint_type_qid' => 'Qualifier',
- 'constraint_parameters' => '{}'
- ),
- array (
- 'constraint_guid' => '6',
- 'pid' => 1,
- 'constraint_type_qid' => 'One of',
- 'constraint_parameters' => json_encode(
- array ( 'item' => 'Q2,Q3' ) )
- ),
- array (
- 'constraint_guid' => '7',
- 'pid' => 1,
- 'constraint_type_qid' => 'Range',
- 'constraint_parameters' => json_encode(
- array (
- 'minimum_quantity' => 0,
- 'maximum_quantity' =>
2015
- ) )
- ),
- array (
- 'constraint_guid' => '8',
- 'pid' => 1,
- 'constraint_type_qid' => 'Target
required claim',
- 'constraint_parameters' => json_encode(
- array (
- 'property' => 'P2',
- 'item' => 'Q2'
- ) )
- ),
- array (
- 'constraint_guid' => '9',
- 'pid' => 1,
- 'constraint_type_qid' => 'Item',
- 'constraint_parameters' => json_encode(
- array (
- 'property' => 'P2',
- 'item' => 'Q2,Q3'
- ) )
- ),
- array (
- 'constraint_guid' => '10',
- 'pid' => 1,
- 'constraint_type_qid' => 'Type',
- 'constraint_parameters' => json_encode(
- array (
- 'class' => 'Q2,Q3',
- 'relation' => 'instance'
- ) )
- ),
- array (
- 'constraint_guid' => '11',
- 'pid' => 1,
- 'constraint_type_qid' => 'Value type',
- 'constraint_parameters' => json_encode(
- array (
- 'class' => 'Q2,Q3',
- 'relation' => 'instance'
- ) )
- ),
- array (
- 'constraint_guid' => '12',
- 'pid' => 3,
- 'constraint_type_qid' => 'Is not
inside',
- 'constraint_parameters' => '{}'
- )
- )
- );
- }
-
- public function testCheckAgainstConstraints() {
- $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) );
- $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
- $this->assertEquals( 18, count( $result ), 'Every constraint
should be represented by one result' );
- }
-
- public function testCheckAgainstConstraintsWithoutEntity() {
- $result = $this->constraintChecker->checkAgainstConstraints(
null );
- $this->assertEquals( null, $result, 'Should return null' );
- }
-
- public function
testCheckAgainstConstraintsDoesNotCrashWhenResultIsEmpty() {
- $entity = $this->lookup->getEntity( new ItemId( 'Q2' ) );
- $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
- $this->assertEquals( 0, count( $result ), 'Should be empty' );
- }
-
- public function
testCheckAgainstConstraintsWithConstraintThatDoesNotBelongToCheckedConstraints()
{
- $entity = $this->lookup->getEntity( new ItemId( 'Q3' ) );
- $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
- $this->assertEquals( 1, count( $result ), 'Should be one
result' );
- $this->assertEquals( 'todo', $result[ 0 ]->getStatus(), 'Should
be marked as a todo' );
- }
-
- public function
testCheckAgainstConstraintsDoesNotCrashWhenStatementHasNovalue() {
- $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) );
- $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
- $this->assertEquals( 0, count( $result ), 'Should be empty' );
- }
-
- public function testCheckAgainstConstraintsWithKnownException() {
- $entity = $this->lookup->getEntity( new ItemId( 'Q5' ) );
- $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
- $this->assertEquals( 'exception', $result[ 0 ]->getStatus(),
'Should be an exception' );
- }
-
+<?php
+
+namespace WikibaseQuality\ConstraintReport\Test\ConstraintChecker;
+
+use Wikibase\DataModel\Entity\ItemId;
+use WikibaseQuality\ConstraintReport\ConstraintReportFactory;
+use WikibaseQuality\Tests\Helper\JsonFileEntityLookup;
+
+
+/**
+ * @covers
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker
+ *
+ * @group WikibaseQualityConstraints
+ * @group Database
+ *
+ * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\RangeChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\DiffWithinRangeChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SingleValueChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MultiValueChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\UniqueValueChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\OneOfChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\CommonsLinkChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TargetRequiredClaimChecker
+ * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ItemChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ConflictsWithChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\SymmetricChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\InverseChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\FormatChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifierChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\QualifiersChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\MandatoryQualifiersChecker
+ * @uses WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\TypeChecker
+ * @uses
WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker
+ *
+ * @author BP2014N1
+ * @license GNU GPL v2+
+ */
+class DelegatingConstraintCheckerTest extends \MediaWikiTestCase {
+
+ private $constraintChecker;
+ private $lookup;
+
+ protected function setUp() {
+ parent::setUp();
+ $this->lookup = new JsonFileEntityLookup( __DIR__ );
+ $factory = new ConstraintReportFactory( $this->lookup );
+ $this->constraintChecker = $factory->getConstraintChecker();
+
+ // specify database tables used by this test
+ $this->tablesUsed[ ] = CONSTRAINT_TABLE;
+ }
+
+ protected function tearDown() {
+ unset( $this->lookup );
+ unset( $this->constraintChecker );
+ parent::tearDown();
+ }
+
+ /**
+ * Adds temporary test data to database.
+ *
+ * @throws \DBUnexpectedError
+ */
+ public function addDBData() {
+ $this->db->delete(
+ CONSTRAINT_TABLE,
+ '*'
+ );
+
+ $this->db->insert(
+ CONSTRAINT_TABLE,
+ array (
+ array (
+ 'constraint_guid' => '13',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Commons link',
+ 'constraint_parameters' => json_encode(
+ array ( 'namespace' => 'File' )
)
+ ),
+ array (
+ 'constraint_guid' => '19',
+ 'pid' => 10,
+ 'constraint_type_qid' => 'Commons link',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'namespace' => 'File',
+ 'known_exception' =>
'Q5'
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '20',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Mandatory
qualifiers',
+ 'constraint_parameters' => json_encode(
+ array ( 'property' => 'P2' ) )
+ ),
+ array (
+ 'constraint_guid' => '14',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Conflicts
with',
+ 'constraint_parameters' => json_encode(
+ array ( 'property' => 'P2' ) )
+ ),
+ array (
+ 'constraint_guid' => '15',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Inverse',
+ 'constraint_parameters' => json_encode(
+ array ( 'property' => 'P2' ) )
+ ),
+ array (
+ 'constraint_guid' => '16',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Qualifiers',
+ 'constraint_parameters' => json_encode(
+ array ( 'property' => 'P2,P3' )
)
+ ),
+ array (
+ 'constraint_guid' => '17',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Diff within
range',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'property' => 'P2',
+ 'minimum_quantity' => 0,
+ 'maximum_quantity' =>
150
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '18',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Format',
+ 'constraint_parameters' => json_encode(
+ array ( 'pattern' => '[0-9]' ) )
+ ),
+ array (
+ 'constraint_guid' => '1',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Multi value',
+ 'constraint_parameters' => '{}'
+ ),
+ array (
+ 'constraint_guid' => '2',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Unique value',
+ 'constraint_parameters' => '{}'
+ ),
+ array (
+ 'constraint_guid' => '3',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Single value',
+ 'constraint_parameters' => '{}'
+ ),
+ array (
+ 'constraint_guid' => '4',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Symmetric',
+ 'constraint_parameters' => '{}'
+ ),
+ array (
+ 'constraint_guid' => '5',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Qualifier',
+ 'constraint_parameters' => '{}'
+ ),
+ array (
+ 'constraint_guid' => '6',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'One of',
+ 'constraint_parameters' => json_encode(
+ array ( 'item' => 'Q2,Q3' ) )
+ ),
+ array (
+ 'constraint_guid' => '7',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Range',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'minimum_quantity' => 0,
+ 'maximum_quantity' =>
2015
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '8',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Target
required claim',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'property' => 'P2',
+ 'item' => 'Q2'
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '9',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Item',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'property' => 'P2',
+ 'item' => 'Q2,Q3'
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '10',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Type',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'class' => 'Q2,Q3',
+ 'relation' => 'instance'
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '11',
+ 'pid' => 1,
+ 'constraint_type_qid' => 'Value type',
+ 'constraint_parameters' => json_encode(
+ array (
+ 'class' => 'Q2,Q3',
+ 'relation' => 'instance'
+ ) )
+ ),
+ array (
+ 'constraint_guid' => '12',
+ 'pid' => 3,
+ 'constraint_type_qid' => 'Is not
inside',
+ 'constraint_parameters' => '{}'
+ )
+ )
+ );
+ }
+
+ public function testCheckAgainstConstraints() {
+ $entity = $this->lookup->getEntity( new ItemId( 'Q1' ) );
+ $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
+ $this->assertEquals( 18, count( $result ), 'Every constraint
should be represented by one result' );
+ }
+
+ public function testCheckAgainstConstraintsWithoutEntity() {
+ $result = $this->constraintChecker->checkAgainstConstraints(
null );
+ $this->assertEquals( null, $result, 'Should return null' );
+ }
+
+ public function
testCheckAgainstConstraintsDoesNotCrashWhenResultIsEmpty() {
+ $entity = $this->lookup->getEntity( new ItemId( 'Q2' ) );
+ $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
+ $this->assertEquals( 0, count( $result ), 'Should be empty' );
+ }
+
+ public function
testCheckAgainstConstraintsWithConstraintThatDoesNotBelongToCheckedConstraints()
{
+ $entity = $this->lookup->getEntity( new ItemId( 'Q3' ) );
+ $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
+ $this->assertEquals( 1, count( $result ), 'Should be one
result' );
+ $this->assertEquals( 'todo', $result[ 0 ]->getStatus(), 'Should
be marked as a todo' );
+ }
+
+ public function
testCheckAgainstConstraintsDoesNotCrashWhenStatementHasNovalue() {
+ $entity = $this->lookup->getEntity( new ItemId( 'Q4' ) );
+ $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
+ $this->assertEquals( 0, count( $result ), 'Should be empty' );
+ }
+
+ public function testCheckAgainstConstraintsWithKnownException() {
+ $entity = $this->lookup->getEntity( new ItemId( 'Q5' ) );
+ $result = $this->constraintChecker->checkAgainstConstraints(
$entity );
+ $this->assertEquals( 'exception', $result[ 0 ]->getStatus(),
'Should be an exception' );
+ }
+
}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/231518
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If21904603bd95ce5c2fbe7f1a6b1a8ae6aca38fa
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: v1
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits