Soeren.oldag has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/219260

Change subject: Refactored special page dependency injection. Adopted table on 
special page to solve escaping issue.
......................................................................

Refactored special page dependency injection. Adopted table on special page to 
solve escaping issue.

Change-Id: I3a739d454005c23d0ee5f137d3e3bb8d54d26db0
---
M WikibaseQualityConstraints.php
D includes/SpecialPageFactory.php
M specials/SpecialConstraintReport.php
D tests/phpunit/SpecialPageFactoryTest.php
4 files changed, 33 insertions(+), 170 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/60/219260/1

diff --git a/WikibaseQualityConstraints.php b/WikibaseQualityConstraints.php
index 6a64371..a4338d7 100755
--- a/WikibaseQualityConstraints.php
+++ b/WikibaseQualityConstraints.php
@@ -26,7 +26,7 @@
        $GLOBALS['wgHooks']['UnitTestsList'][] = 
'WikibaseQualityConstraintsHooks::onUnitTestsList';
 
        // Initialize special pages
-       $GLOBALS['wgSpecialPages']['ConstraintReport'] = array( 
'WikibaseQuality\ConstraintReport\SpecialPageFactory', 
'newSpecialConstraintReport' );
+       $GLOBALS['wgSpecialPages']['ConstraintReport'] = 
'WikibaseQuality\ConstraintReport\Specials\SpecialConstraintReport::newFromGlobalState';
 
        // Define modules
     $remoteExtPathParts = explode(
diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php
deleted file mode 100644
index b81b12f..0000000
--- a/includes/SpecialPageFactory.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-
-namespace WikibaseQuality\ConstraintReport;
-
-use Wikibase\DataModel\Entity\EntityIdParser;
-use Wikibase\Lib\OutputFormatValueFormatterFactory;
-use Wikibase\Lib\Store\EntityLookup;
-use Wikibase\Lib\Store\EntityTitleLookup;
-use Wikibase\Lib\Store\TermLookup;
-use Wikibase\Repo\WikibaseRepo;
-use 
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
-use WikibaseQuality\ConstraintReport\Specials\SpecialConstraintReport;
-use WikibaseQuality\ExternalValidation\Specials\SpecialCrossCheck;
-
-
-/**
- * Class SpecialPageFactory
- * @package WikibaseQuality\ConstraintReport
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class SpecialPageFactory {
-
-       /**
-        * @var EntityLookup
-        */
-       private $entityLookup;
-
-       /**
-        * @var EntityTitleLookup
-        */
-       private $entityTitleLookup;
-
-       /**
-        * @var TermLookup
-        */
-       private $termLookup;
-
-       /**
-        * @var EntityIdParser
-        */
-       private $entityIdParser;
-
-       /**
-        * @var OutputFormatValueFormatterFactory
-        */
-       private $valueFormatterFactory;
-
-       /**
-        * @var DelegatingConstraintChecker
-        */
-       private $constraintChecker;
-
-
-       private static function newFromGlobalState() {
-               $constraintReportFactory = 
ConstraintReportFactory::getDefaultInstance();
-               $wikibaseRepo = WikibaseRepo::getDefaultInstance();
-
-               return new self(
-                       $wikibaseRepo->getEntityLookup(),
-                       $wikibaseRepo->getTermLookup(),
-                       $wikibaseRepo->getEntityTitleLookup(),
-                       $wikibaseRepo->getEntityIdParser(),
-                       $wikibaseRepo->getValueFormatterFactory(),
-                       $constraintReportFactory->getConstraintChecker()
-               );
-       }
-
-       /**
-        * @return SpecialCrossCheck
-        */
-       public static function newSpecialConstraintReport() {
-               return 
self::newFromGlobalState()->createSpecialConstraintReport();
-       }
-
-       /**
-        * @param EntityLookup $entityLookup
-        * @param TermLookup $termLookup
-        * @param EntityTitleLookup $entityTitleLookup
-        * @param EntityIdParser $entityIdParser
-        * @param OutputFormatValueFormatterFactory $valueFormatterFactory
-        * @param DelegatingConstraintChecker $constraintChecker
-        */
-       public function __construct( EntityLookup $entityLookup, TermLookup 
$termLookup, EntityTitleLookup $entityTitleLookup,
-                                                                EntityIdParser 
$entityIdParser, OutputFormatValueFormatterFactory $valueFormatterFactory,
-                                                                
DelegatingConstraintChecker $constraintChecker ) {
-               $this->entityLookup = $entityLookup;
-               $this->termLookup = $termLookup;
-               $this->entityTitleLookup = $entityTitleLookup;
-               $this->entityIdParser = $entityIdParser;
-               $this->valueFormatterFactory = $valueFormatterFactory;
-               $this->constraintChecker = $constraintChecker;
-       }
-
-       /**
-        * @return SpecialCrossCheck
-        */
-       public function createSpecialConstraintReport() {
-               return new SpecialConstraintReport(
-                       $this->entityLookup,
-                       $this->termLookup,
-                       $this->entityTitleLookup,
-                       $this->entityIdParser,
-                       $this->valueFormatterFactory,
-                       $this->constraintChecker
-               );
-       }
-}
\ No newline at end of file
diff --git a/specials/SpecialConstraintReport.php 
b/specials/SpecialConstraintReport.php
index 011aa65..8fbffc1 100755
--- a/specials/SpecialConstraintReport.php
+++ b/specials/SpecialConstraintReport.php
@@ -20,8 +20,6 @@
 use DataValues;
 use DataValues\DataValue;
 use Html;
-use Doctrine\Instantiator\Exception\InvalidArgumentException;
-use Doctrine\Instantiator\Exception\UnexpectedValueException;
 use Wikibase\DataModel\Entity\Entity;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParsingException;
@@ -30,10 +28,13 @@
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\Lib\Store\EntityTitleLookup;
+use Wikibase\Repo\WikibaseRepo;
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker;
+use WikibaseQuality\ConstraintReport\ConstraintReportFactory;
 use WikibaseQuality\ConstraintReport\EvaluateConstraintReportJob;
 use WikibaseQuality\ConstraintReport\EvaluateConstraintReportJobService;
 use WikibaseQuality\Html\HtmlTableBuilder;
+use WikibaseQuality\Html\HtmlTableCellBuilder;
 use WikibaseQuality\Html\HtmlTableHeaderBuilder;
 
 
@@ -92,6 +93,20 @@
         * @var DelegatingConstraintChecker
         */
        private $constraintChecker;
+
+       public static function newFromGlobalState()     {
+               $constraintReportFactory = 
ConstraintReportFactory::getDefaultInstance();
+               $wikibaseRepo = WikibaseRepo::getDefaultInstance();
+
+               return new self(
+                       $wikibaseRepo->getEntityLookup(),
+                       $wikibaseRepo->getTermLookup(),
+                       $wikibaseRepo->getEntityTitleLookup(),
+                       $wikibaseRepo->getEntityIdParser(),
+                       $wikibaseRepo->getValueFormatterFactory(),
+                       $constraintReportFactory->getConstraintChecker()
+               );
+       }
 
        /**
         * @param EntityLookup $entityLookup
@@ -374,9 +389,21 @@
                // Append cells
                $table->appendRow(
                        array (
-                               $statusColumn,
-                               $claimColumn,
-                               $constraintColumn
+                               new HtmlTableCellBuilder(
+                                       $statusColumn,
+                                       array(),
+                                       true
+                               ),
+                               new HtmlTableCellBuilder(
+                                       $claimColumn,
+                                       array(),
+                                       true
+                               ),
+                               new HtmlTableCellBuilder(
+                                       $constraintColumn,
+                                       array(),
+                                       true
+                               )
                        )
                );
 
diff --git a/tests/phpunit/SpecialPageFactoryTest.php 
b/tests/phpunit/SpecialPageFactoryTest.php
deleted file mode 100644
index 7666189..0000000
--- a/tests/phpunit/SpecialPageFactoryTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-namespace WikibaseQuality\ConstraintReport\Tests;
-
-
-use WikibaseQuality\ConstraintReport\SpecialPageFactory;
-
-
-/**
- * @covers WikibaseQuality\ConstraintReport\SpecialPageFactory
- *
- * @group WikibaseQuality
- *
- * @author BP2014N1
- * @license GNU GPL v2+
- */
-class SpecialPageFactoryTest extends \MediaWikiTestCase {
-
-       public function testNewSpecialConstraintReport() {
-               $specialPage = SpecialPageFactory::newSpecialConstraintReport();
-
-               $this->assertInstanceOf( 
'WikibaseQuality\ConstraintReport\Specials\SpecialConstraintReport', 
$specialPage );
-       }
-
-       public function testCreateSpecialConstraintReport() {
-               $specialPage = 
$this->getFactory()->createSpecialConstraintReport();
-
-               $this->assertInstanceOf( 
'WikibaseQuality\ConstraintReport\Specials\SpecialConstraintReport', 
$specialPage );
-       }
-
-       /**
-        * @return SpecialPageFactory
-        */
-       private function getFactory() {
-               $entityLookup = $this->getMockForAbstractClass( 
'Wikibase\Lib\Store\EntityLookup' );
-               $termLookup = $this->getMockForAbstractClass( 
'Wikibase\Lib\Store\TermLookup' );
-               $entityTitleLookup = $this->getMockForAbstractClass( 
'Wikibase\Lib\Store\EntityTitleLookup' );
-               $entityIdParser = $this->getMockForAbstractClass( 
'Wikibase\DataModel\Entity\EntityIdParser' );
-               $valueFormatterFactory = $this->getMockBuilder( 
'Wikibase\Lib\OutputFormatValueFormatterFactory' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $constraintChecker = $this->getMockBuilder( 
'WikibaseQuality\ConstraintReport\ConstraintCheck\DelegatingConstraintChecker' )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-
-               return new SpecialPageFactory(
-                       $entityLookup,
-                       $termLookup,
-                       $entityTitleLookup,
-                       $entityIdParser,
-                       $valueFormatterFactory,
-                       $constraintChecker
-               );
-       }
-}

-- 
To view, visit https://gerrit.wikimedia.org/r/219260
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a739d454005c23d0ee5f137d3e3bb8d54d26db0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: v1
Gerrit-Owner: Soeren.oldag <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to