Jeroen De Dauw has submitted this change and it was merged.

Change subject: Use ComparableComparer for ClaimDiffer construction
......................................................................


Use ComparableComparer for ClaimDiffer construction

Change-Id: Ida96663d24bcf3250dbbe9dae5aebf4453350e8d
---
M lib/includes/ClaimDiffer.php
M lib/tests/phpunit/claim/ClaimDifferTest.php
M repo/includes/EntityContentDiffView.php
M repo/includes/actions/EditEntityAction.php
M repo/includes/api/SetClaim.php
M repo/tests/phpunit/includes/ClaimSummaryBuilderTest.php
6 files changed, 21 insertions(+), 107 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/ClaimDiffer.php b/lib/includes/ClaimDiffer.php
index c839f32..9a23c38 100644
--- a/lib/includes/ClaimDiffer.php
+++ b/lib/includes/ClaimDiffer.php
@@ -9,25 +9,7 @@
 /**
  * Class for generating a ClaimDifference given two claims.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
  * @since 0.4
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Tobias Gritschacher < [email protected] >
diff --git a/lib/tests/phpunit/claim/ClaimDifferTest.php 
b/lib/tests/phpunit/claim/ClaimDifferTest.php
index 0aed9c3..2bb71dd 100644
--- a/lib/tests/phpunit/claim/ClaimDifferTest.php
+++ b/lib/tests/phpunit/claim/ClaimDifferTest.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Test;
 
+use Diff\Comparer\ComparableComparer;
 use Diff\OrderedListDiffer;
 use Diff\Diff;
 use Diff\DiffOpAdd;
@@ -16,28 +17,7 @@
 use Wikibase\Statement;
 
 /**
- * Tests for the Wikibase\ClaimDiffer class.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @since 0.4
- *
- * @ingroup WikibaseLib
- * @ingroup Test
+ * @covers Wikibase\ClaimDiffer
  *
  * @group Wikibase
  * @group WikibaseLib
@@ -136,11 +116,7 @@
         * @param ClaimDifference $expected
         */
        public function testDiffClaims( Claim $oldClaim, Claim $newClaim, 
ClaimDifference $expected ) {
-               $comparer = function( \Comparable $old, \Comparable $new ) {
-                       return $old->equals( $new );
-               };
-
-               $differ = new ClaimDiffer( new OrderedListDiffer( $comparer ) );
+               $differ = new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) );
                $actual = $differ->diffClaims( $oldClaim, $newClaim );
 
                $this->assertInstanceOf( 'Wikibase\ClaimDifference', $actual );
diff --git a/repo/includes/EntityContentDiffView.php 
b/repo/includes/EntityContentDiffView.php
index c889e81..7968141 100644
--- a/repo/includes/EntityContentDiffView.php
+++ b/repo/includes/EntityContentDiffView.php
@@ -2,9 +2,11 @@
 
 namespace Wikibase;
 
+use Diff\Comparer\ComparableComparer;
 use Diff\OrderedListDiffer;
 use Diff\ListDiffer;
-use Content, Html;
+use Content;
+use Html;
 use ValueFormatters\FormatterOptions;
 use ValueFormatters\ValueFormatter;
 use Wikibase\Lib\EntityIdLabelFormatter;
@@ -14,25 +16,7 @@
 /**
  * Difference view for Wikibase entities.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
  * @since 0.1
- *
- * @file
- * @ingroup WikibaseRepo
  *
  * @licence GNU GPL v2+
  * @author Daniel Kinzler
@@ -146,14 +130,10 @@
                 */
                $diff = $old->getEntity()->getDiff( $new->getEntity() );
 
-               $comparer = function( \Comparable $old, \Comparable $new ) {
-                       return $old->equals( $new );
-               };
-
-               // TODO: deep inject the EntityDiffVisualizer
+               // TODO: derp inject the EntityDiffVisualizer
                $diffVisualizer = new EntityDiffVisualizer(
                        $this->getContext(),
-                       new ClaimDiffer( new OrderedListDiffer( $comparer ) ),
+                       new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) ),
                        new ClaimDifferenceVisualizer(
                                $this->propertyNameFormatter,
                                $this->snakValueFormatter
diff --git a/repo/includes/actions/EditEntityAction.php 
b/repo/includes/actions/EditEntityAction.php
index 7389d80..03112a5 100644
--- a/repo/includes/actions/EditEntityAction.php
+++ b/repo/includes/actions/EditEntityAction.php
@@ -2,8 +2,13 @@
 
 namespace Wikibase;
 
+use Diff\Comparer\ComparableComparer;
 use Diff\OrderedListDiffer;
-use Html, Linker, Skin, Status, Revision;
+use Html;
+use Linker;
+use Skin;
+use Status;
+use Revision;
 use ValueFormatters\FormatterOptions;
 use ValueFormatters\ValueFormatter;
 use Wikibase\Lib\EntityIdLabelFormatter;
@@ -451,14 +456,10 @@
 
                $langCode = $this->getContext()->getLanguage()->getCode();
 
-               $comparer = function( \Comparable $old, \Comparable $new ) {
-                       return $old->equals( $new );
-               };
-
-               // TODO: deep inject the EntityDiffVisualizer
+               // TODO: derp inject the EntityDiffVisualizer
                $diffVisualizer = new EntityDiffVisualizer(
                        $this->getContext(),
-                       new ClaimDiffer( new OrderedListDiffer( $comparer ) ),
+                       new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) ),
                        new ClaimDifferenceVisualizer(
                                $this->propertyNameFormatter,
                                $this->snakValueFormatter
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index af91f03..beb29ba 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -4,6 +4,7 @@
 
 use DataValues\IllegalValueException;
 use ApiMain;
+use Diff\Comparer\ComparableComparer;
 use Diff\OrderedListDiffer;
 use MWException;
 use ApiBase;
@@ -23,21 +24,6 @@
 
 /**
  * API module for creating or updating an entire Claim.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
  *
  * @since 0.4
  *
@@ -83,11 +69,7 @@
 
                $this->snakValidation->validateClaimSnaks( $claim );
 
-               $comparer = function( \Comparable $old, \Comparable $new ) {
-                       return $old->equals( $new );
-               };
-
-               $claimDiffer = new ClaimDiffer( new OrderedListDiffer( 
$comparer ) );
+               $claimDiffer = new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) );
 
                $options = new FormatterOptions( array(
                        //TODO: fallback chain
diff --git a/repo/tests/phpunit/includes/ClaimSummaryBuilderTest.php 
b/repo/tests/phpunit/includes/ClaimSummaryBuilderTest.php
index b76ffdf..1fcd681 100644
--- a/repo/tests/phpunit/includes/ClaimSummaryBuilderTest.php
+++ b/repo/tests/phpunit/includes/ClaimSummaryBuilderTest.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Test;
 
+use Diff\Comparer\ComparableComparer;
 use Diff\OrderedListDiffer;
 use Diff\ListDiffer;
 use Wikibase\ClaimDiffer;
@@ -148,13 +149,9 @@
                        ->method( 'getFormat' )
                        ->will( $this->returnValue( SnakFormatter::FORMAT_PLAIN 
) );
 
-               $comparer = function( \Comparable $old, \Comparable $new ) {
-                       return $old->equals( $new );
-               };
-
                $claimSummaryBuilder = new ClaimSummaryBuilder(
                        'wbsetclaim',
-                       new ClaimDiffer( new OrderedListDiffer( $comparer ) ),
+                       new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) ),
                        $snakFormatter
                );
 
@@ -186,13 +183,9 @@
                        ->method( 'getFormat' )
                        ->will( $this->returnValue( SnakFormatter::FORMAT_PLAIN 
) );
 
-               $comparer = function( \Comparable $old, \Comparable $new ) {
-                       return $old->equals( $new );
-               };
-
                $claimSummaryBuilder = new ClaimSummaryBuilder(
                        'wbsetclaim',
-                       new ClaimDiffer( new OrderedListDiffer( $comparer ) ),
+                       new ClaimDiffer( new OrderedListDiffer( new 
ComparableComparer() ) ),
                        $snakFormatter
                );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ida96663d24bcf3250dbbe9dae5aebf4453350e8d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to