jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/326918 )

Change subject: Inline trivial PHPUnit::returnCallback as Closures
......................................................................


Inline trivial PHPUnit::returnCallback as Closures

This patch also tries to get rid of duplicate and unused code, as well
as adds some missing comments and newlines. The goal of everything in
here is to strip unnecesarry complexity, make the code simpler, easier to
read and to maintain.

Change-Id: I9fc91859847cd14448484798a900ecf11c28baa3
---
M 
client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php
M client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
M client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
M client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
M lib/tests/phpunit/Formatters/EntityIdLinkFormatterTest.php
M lib/tests/phpunit/Formatters/EntityIdPlainLinkFormatterTest.php
M lib/tests/phpunit/Formatters/EntityIdTitleFormatterTest.php
M repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
M repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php
M repo/tests/phpunit/includes/Api/SearchEntitiesTest.php
M repo/tests/phpunit/includes/ChangeDispatcherTest.php
M repo/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
M repo/tests/phpunit/includes/SummaryFormatterTest.php
13 files changed, 140 insertions(+), 188 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php
 
b/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php
index 813aa51..a41ffc1 100644
--- 
a/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/StatementTransclusionInteractorTest.php
@@ -176,18 +176,16 @@
                $lookup->expects( $this->any() )
                        ->method( 'getEntityRevision' )
                        ->will( $this->returnCallback( function( EntityId 
$entityId ) {
-                               if ( $entityId->getSerialization() === 'Q42' ) {
-                                       return new EntityRevision(
-                                               new Item( new ItemId( 'Q42' ) )
-                                       );
-                               } elseif ( $entityId->getSerialization() === 
'Q43' ) {
-                                       // Unresolved redirect, derived from 
EntityLookupException
-                                       throw new 
RevisionedUnresolvedRedirectException(
-                                               $entityId,
-                                               new ItemId( 'Q404' )
-                                       );
-                               } else {
-                                       return null;
+                               switch ( $entityId->getSerialization() ) {
+                                       case 'Q42':
+                                               return new EntityRevision( new 
Item( new ItemId( 'Q42' ) ) );
+                                       case 'Q43':
+                                               throw new 
RevisionedUnresolvedRedirectException(
+                                                       $entityId,
+                                                       new ItemId( 'Q404' )
+                                               );
+                                       default:
+                                               return null;
                                }
                        } )
                );
diff --git a/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php 
b/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
index 42cb906..57c206d 100644
--- a/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
+++ b/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
@@ -102,7 +102,16 @@
 
                $repoLinker->expects( $this->any() )
                        ->method( 'buildEntityLink' )
-                       ->will( $this->returnCallback( [ $this, 
'buildEntityLink' ] ) );
+                       ->will( $this->returnCallback( function (
+                               EntityId $entityId,
+                               array $classes = [],
+                               $text = null
+                       ) {
+                               return Html::rawElement( 'a', [
+                                       'href' => 
'https://www.wikidata.org/wiki/' . $entityId,
+                                       'class' => implode( ' ', $classes ),
+                               ], $text ?: $entityId );
+                       } ) );
 
                $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class )
                        ->disableOriginalConstructor()
@@ -137,7 +146,9 @@
 
                $idParser->expects( $this->any() )
                        ->method( 'parse' )
-                       ->will( $this->returnCallback( [ $this, 'parse' ] ) );
+                       ->will( $this->returnCallback( function ( 
$idSerialization ) {
+                               return new ItemId( $idSerialization );
+                       } ) );
 
                $hookHandler = new EditActionHookHandler(
                        $repoLinker,
@@ -174,54 +185,16 @@
 
                $lookup->expects( $this->any() )
                        ->method( 'getLabel' )
-                       ->will( $this->returnCallback( [ $this, 'getLabel' ] ) 
);
+                       ->will( $this->returnCallback( function ( EntityId 
$entityId ) {
+                               switch ( $entityId->getSerialization() ) {
+                                       case 'Q4':
+                                               return new Term( 'en', 'Berlin' 
);
+                                       default:
+                                               return null;
+                               }
+                       } ) );
 
                return $lookup;
-       }
-
-       /**
-        * @param EntityId $entity
-        *
-        * @return Term|null
-        */
-       public function getLabel( EntityId $entity ) {
-               $labelMap = [ 'Q4' => 'Berlin' ];
-               $idSerialization = $entity->getSerialization();
-               if ( !isset( $labelMap[$idSerialization] ) ) {
-                       return null;
-               }
-               $term = new Term( 'en', $labelMap[$idSerialization] );
-               return $term;
-       }
-
-       /**
-        * @param string $entity
-        *
-        * @return ItemId
-        */
-       public function parse( $entity ) {
-               // TODO: Let properties be tested too
-               return new ItemId( $entity );
-       }
-
-       /**
-        * @param string $entityId
-        * @param string[] $classes
-        * @param string|null $text
-        *
-        * @return string HTML
-        */
-       public function buildEntityLink( $entityId, array $classes, $text = 
null ) {
-               if ( $text === null ) {
-                       $text = $entityId;
-               }
-
-               $attr = [
-                       'href' => 'https://www.wikidata.org/wiki/' . $entityId,
-                       'class' => implode( ' ', $classes )
-               ];
-
-               return Html::rawElement( 'a', $attr, $text );
        }
 
        /**
diff --git a/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php 
b/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
index 0230e8c..f2e8ed5 100644
--- a/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
+++ b/client/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
@@ -9,6 +9,7 @@
 use Wikibase\Client\Hooks\InfoActionHookHandler;
 use Wikibase\Client\RepoLinker;
 use Wikibase\Client\Usage\Sql\SqlUsageTracker;
+use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Entity\EntityIdParser;
 use Wikibase\DataModel\Entity\ItemId;
 use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup;
@@ -42,9 +43,9 @@
 
        public function handleProvider() {
                $context = $this->getContext();
-               $labeledLink = '<a href="https://www.wikidata.org/wiki/Q4"; 
classes="external">Berlin</a>';
-               $unLabeledLink = '<a href="https://www.wikidata.org/wiki/Q4"; 
classes="external">Q4</a>';
-               $q5Link = '<a href="https://www.wikidata.org/wiki/Q5"; 
classes="external">Q5</a>';
+               $labeledLink = '<a href="https://www.wikidata.org/wiki/Q4"; 
class="external">Berlin</a>';
+               $unLabeledLink = '<a href="https://www.wikidata.org/wiki/Q4"; 
class="external">Q4</a>';
+               $q5Link = '<a href="https://www.wikidata.org/wiki/Q5"; 
class="external">Q5</a>';
                $cases = [];
 
                $cases[] = [
@@ -134,7 +135,16 @@
 
                $repoLinker->expects( $this->any() )
                        ->method( 'buildEntityLink' )
-                       ->will( $this->returnCallback( [ $this, 
'buildEntityLink' ] ) );
+                       ->will( $this->returnCallback( function (
+                               EntityId $entityId,
+                               array $classes = [],
+                               $text = null
+                       ) {
+                               return Html::rawElement( 'a', [
+                                       'href' => 
'https://www.wikidata.org/wiki/' . $entityId,
+                                       'class' => implode( ' ', $classes ),
+                               ], $text ?: $entityId );
+                       } ) );
 
                $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class )
                        ->disableOriginalConstructor()
@@ -171,7 +181,9 @@
 
                $idParser->expects( $this->any() )
                        ->method( 'parse' )
-                       ->will( $this->returnCallback( [ $this, 'parse' ] ) );
+                       ->will( $this->returnCallback( function ( 
$idSerialization ) {
+                               return new ItemId( $idSerialization );
+                       } ) );
 
                $hookHandler = new InfoActionHookHandler(
                        $namespaceChecker,
@@ -224,54 +236,16 @@
 
                $lookup->expects( $this->any() )
                        ->method( 'getLabel' )
-                       ->will( $this->returnCallback( [ $this, 'getLabel' ] ) 
);
+                       ->will( $this->returnCallback( function ( EntityId 
$entityId ) {
+                               switch ( $entityId->getSerialization() ) {
+                                       case 'Q4':
+                                               return new Term( 'en', 'Berlin' 
);
+                                       default:
+                                               return null;
+                               }
+                       } ) );
 
                return $lookup;
-       }
-
-       /**
-        * @param EntityId $entity
-        *
-        * @return Term|null
-        */
-       public function getLabel( $entity ) {
-               $labelMap = [ 'Q4' => 'Berlin' ];
-               $entityId = $entity->getSerialization();
-               if ( !isset( $labelMap[$entityId] ) ) {
-                       return null;
-               }
-               $term = new Term( 'en', $labelMap[$entityId] );
-               return $term;
-       }
-
-       /**
-        * @param string $entity
-        *
-        * @return ItemId
-        */
-       public function parse( $entity ) {
-               // TODO: Let properties be tested too
-               return new ItemId( $entity );
-       }
-
-       /**
-        * @param string $entityId
-        * @param string[] $classes
-        * @param string $text
-        *
-        * @return string HTML
-        */
-       public function buildEntityLink( $entityId, array $classes, $text = 
null ) {
-               if ( $text === null ) {
-                       $text = $entityId;
-               }
-
-               $attr = [
-                       'href' => 'https://www.wikidata.org/wiki/' . $entityId,
-                       'classes' => implode( ' ', $classes )
-               ];
-
-               return Html::rawElement( 'a', $attr, $text );
        }
 
 }
diff --git 
a/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php 
b/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
index 979457a..25951e7 100644
--- a/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
+++ b/client/tests/phpunit/includes/Hooks/LanguageLinkBadgeDisplayTest.php
@@ -39,13 +39,14 @@
                $labelLookup->expects( $this->any() )
                        ->method( 'getLabel' )
                        ->will( $this->returnCallback( function( EntityId 
$entityId ) {
-                               if ( $entityId->getSerialization() === 'Q3' ) {
-                                       return new Term( 'de', 'Lesenswerter 
Artikel' );
-                               } elseif ( $entityId->getSerialization() === 
'Q4' ) {
-                                       return new Term( 'de', 'Exzellenter 
Artikel' );
+                               switch ( $entityId->getSerialization() ) {
+                                       case 'Q3':
+                                               return new Term( 'de', 
'Lesenswerter Artikel' );
+                                       case 'Q4':
+                                               return new Term( 'de', 
'Exzellenter Artikel' );
+                                       default:
+                                               return null;
                                }
-
-                               return null;
                        } ) );
 
                $badgeClassNames = array( 'Q4' => 'foo', 'Q3' => 'bar' );
diff --git a/lib/tests/phpunit/Formatters/EntityIdLinkFormatterTest.php 
b/lib/tests/phpunit/Formatters/EntityIdLinkFormatterTest.php
index 0038233..d0a7379 100644
--- a/lib/tests/phpunit/Formatters/EntityIdLinkFormatterTest.php
+++ b/lib/tests/phpunit/Formatters/EntityIdLinkFormatterTest.php
@@ -44,7 +44,7 @@
                $formatter = $this->newEntityIdLinkFormatter();
 
                $actual = $formatter->formatEntityId( $id );
-               $this->assertEquals( $expected, $actual );
+               $this->assertSame( $expected, $actual );
        }
 
        public function getTitleForId( EntityId $entityId ) {
@@ -60,7 +60,8 @@
 
        private function newEntityIdLinkFormatter() {
                $titleLookup = $this->getMock( EntityTitleLookup::class );
-               $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
+               $titleLookup->expects( $this->any() )
+                       ->method( 'getTitleForId' )
                        ->will( $this->returnCallback( array( $this, 
'getTitleForId' ) ) );
 
                $formatter = new EntityIdLinkFormatter( $titleLookup );
diff --git a/lib/tests/phpunit/Formatters/EntityIdPlainLinkFormatterTest.php 
b/lib/tests/phpunit/Formatters/EntityIdPlainLinkFormatterTest.php
index 3d0ce51..7ac4971 100644
--- a/lib/tests/phpunit/Formatters/EntityIdPlainLinkFormatterTest.php
+++ b/lib/tests/phpunit/Formatters/EntityIdPlainLinkFormatterTest.php
@@ -45,7 +45,7 @@
                $formatter = $this->newEntityIdLinkFormatter();
 
                $actual = $formatter->formatEntityId( $id );
-               $this->assertEquals( $expected, $actual );
+               $this->assertSame( $expected, $actual );
        }
 
        public function getTitleForId( EntityId $entityId ) {
@@ -61,7 +61,8 @@
 
        private function newEntityIdLinkFormatter() {
                $titleLookup = $this->getMock( EntityTitleLookup::class );
-               $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
+               $titleLookup->expects( $this->any() )
+                       ->method( 'getTitleForId' )
                        ->will( $this->returnCallback( array( $this, 
'getTitleForId' ) ) );
 
                $formatter = new EntityIdPlainLinkFormatter( $titleLookup );
diff --git a/lib/tests/phpunit/Formatters/EntityIdTitleFormatterTest.php 
b/lib/tests/phpunit/Formatters/EntityIdTitleFormatterTest.php
index 3efc09d..727c843 100644
--- a/lib/tests/phpunit/Formatters/EntityIdTitleFormatterTest.php
+++ b/lib/tests/phpunit/Formatters/EntityIdTitleFormatterTest.php
@@ -46,7 +46,7 @@
                $formatter = $this->newEntityIdTitleFormatter();
 
                $actual = $formatter->formatEntityId( $id );
-               $this->assertEquals( $expected, $actual );
+               $this->assertSame( $expected, $actual );
        }
 
        public function getTitleForId( EntityId $entityId ) {
@@ -62,7 +62,8 @@
 
        protected function newEntityIdTitleFormatter() {
                $titleLookup = $this->getMock( EntityTitleLookup::class );
-               $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
+               $titleLookup->expects( $this->any() )
+                       ->method( 'getTitleForId' )
                        ->will( $this->returnCallback( array( $this, 
'getTitleForId' ) ) );
 
                $formatter = new EntityIdTitleFormatter( $titleLookup );
diff --git a/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php 
b/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
index eb297fe..2face6e 100644
--- a/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
+++ b/repo/tests/phpunit/includes/Api/EntitySearchHelperTest.php
@@ -31,13 +31,11 @@
         */
        private function getMockTitleLookup() {
                $titleLookup = $this->getMock( EntityTitleLookup::class );
-               $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
+               $titleLookup->expects( $this->any() )
+                       ->method( 'getTitleForId' )
                        ->will( $this->returnCallback( function( EntityId $id ) 
{
-                               if ( $id->getSerialization() === 'Q111' ) {
-                                       return $this->getMockTitle( true );
-                               } else {
-                                       return $this->getMockTitle( false );
-                               }
+                               $exists = $id->getSerialization() === 'Q111';
+                               return $this->getMockTitle( $exists );
                        } ) );
                return $titleLookup;
        }
diff --git a/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php 
b/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php
index 887c618..7e73765 100644
--- a/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php
+++ b/repo/tests/phpunit/includes/Api/QuerySearchEntitiesTest.php
@@ -49,7 +49,8 @@
         */
        private function getMockTitleLookup() {
                $titleLookup = $this->getMock( EntityTitleLookup::class );
-               $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
+               $titleLookup->expects( $this->any() )
+                       ->method( 'getTitleForId' )
                        ->will( $this->returnValue( $this->getMockTitle() ) );
 
                return $titleLookup;
diff --git a/repo/tests/phpunit/includes/Api/SearchEntitiesTest.php 
b/repo/tests/phpunit/includes/Api/SearchEntitiesTest.php
index a32017b..ae46296 100644
--- a/repo/tests/phpunit/includes/Api/SearchEntitiesTest.php
+++ b/repo/tests/phpunit/includes/Api/SearchEntitiesTest.php
@@ -50,7 +50,8 @@
         */
        private function getMockTitleLookup() {
                $titleLookup = $this->getMock( EntityTitleLookup::class );
-               $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
+               $titleLookup->expects( $this->any() )
+                       ->method( 'getTitleForId' )
                        ->will( $this->returnValue( $this->getMockTitle() ) );
 
                return $titleLookup;
diff --git a/repo/tests/phpunit/includes/ChangeDispatcherTest.php 
b/repo/tests/phpunit/includes/ChangeDispatcherTest.php
index 110fb3a..c173e37 100644
--- a/repo/tests/phpunit/includes/ChangeDispatcherTest.php
+++ b/repo/tests/phpunit/includes/ChangeDispatcherTest.php
@@ -7,6 +7,7 @@
 use Diff\DiffOp\DiffOpAdd;
 use Diff\DiffOp\DiffOpChange;
 use Diff\DiffOp\DiffOpRemove;
+use PHPUnit_Framework_MockObject_Matcher_Invocation;
 use Wikibase\Change;
 use Wikibase\ChunkAccess;
 use Wikibase\DataModel\Entity\EntityId;
@@ -60,7 +61,7 @@
                $dispatcher = new ChangeDispatcher(
                        $coordinator,
                        $this->getNotificationSender( $notifications ),
-                       $this->getChunkedChangesAccess(),
+                       $this->getChunkedChangesAccess( $this->any() ),
                        $this->getSubscriptionLookup()
                );
 
@@ -86,14 +87,20 @@
        }
 
        /**
+        * @param PHPUnit_Framework_MockObject_Matcher_Invocation|null 
$expectedLoadChunkCalls
+        *
         * @return ChunkAccess Guaranteed to only return Change objects from 
loadChunk.
         */
-       private function getChunkedChangesAccess() {
+       private function getChunkedChangesAccess(
+               PHPUnit_Framework_MockObject_Matcher_Invocation 
$expectedLoadChunkCalls = null
+       ) {
                $chunkedAccess = $this->getMock( ChunkAccess::class );
 
-               $chunkedAccess->expects( $this->any() )
+               $chunkedAccess->expects( $expectedLoadChunkCalls ?: 
$this->never() )
                        ->method( 'loadChunk' )
-                       ->will( $this->returnCallback( array( $this, 
'getChanges' ) ) );
+                       ->will( $this->returnCallback( function ( $fromId, 
$limit ) {
+                               return array_slice( $this->changes, $fromId, 
$limit );
+                       } ) );
 
                $chunkedAccess->expects( $this->any() )
                        ->method( 'getRecordId' )
@@ -112,21 +119,13 @@
 
                $lookup->expects( $this->any() )
                        ->method( 'getSubscriptions' )
-                       ->will( $this->returnCallback( array( $this, 
'getSubscriptions' ) ) );
+                       ->will( $this->returnCallback( function ( $siteId, 
array $entityIds ) {
+                               return isset( $this->subscriptions[$siteId] )
+                                       ? array_intersect( 
$this->subscriptions[$siteId], $entityIds )
+                                       : [];
+                       } ) );
 
                return $lookup;
-       }
-
-       public function getChanges( $fromId, $limit ) {
-               return array_slice( $this->changes, max( $fromId, 1 ), $limit );
-       }
-
-       public function getSubscriptions( $siteId, array $entityIds ) {
-               if ( !isset( $this->subscriptions[$siteId] ) ) {
-                       return array();
-               }
-
-               return array_intersect( $this->subscriptions[$siteId], 
$entityIds );
        }
 
        /**
@@ -341,26 +340,14 @@
                $pending = $dispatcher->getPendingChanges( $siteId, $afterId );
 
                $this->assertChanges( $expectedChanges, $pending[0] );
-               $this->assertEquals( $expectedSeen, $pending[1] );
+               $this->assertSame( $expectedSeen, $pending[1] );
        }
 
        public function testGetPendingChanges_maxChunks() {
-               $chunkAccess = $this->getMock( ChunkAccess::class );
-
-               $chunkAccess->expects( $this->exactly( 1 ) )
-                       ->method( 'loadChunk' )
-                       ->will( $this->returnCallback( array( $this, 
'getChanges' ) ) );
-
-               $chunkAccess->expects( $this->any() )
-                       ->method( 'getRecordId' )
-                       ->will( $this->returnCallback( function ( Change 
$change ) {
-                               return $change->getId();
-                       } ) );
-
                $dispatcher = new ChangeDispatcher(
                        $this->getMock( ChangeDispatchCoordinator::class ),
                        $this->getNotificationSender(),
-                       $chunkAccess,
+                       $this->getChunkedChangesAccess( $this->exactly( 1 ) ),
                        $this->getSubscriptionLookup()
                );
 
@@ -460,12 +447,21 @@
                $this->assertNotifications( $expectedNotifications, 
$notifications );
        }
 
+       /**
+        * @param Change[] $changes
+        *
+        * @return int[]
+        */
        private function getChangeIds( array $changes ) {
                return array_map( function( Change $change ) {
                        return $change->getId();
                }, $changes );
        }
 
+       /**
+        * @param Change[] $expected
+        * @param Change[] $actual
+        */
        private function assertChanges( array $expected, $actual ) {
                $expected = $this->getChangeIds( $expected );
                $actual = $this->getChangeIds( $actual );
@@ -473,6 +469,10 @@
                $this->assertEquals( $expected, $actual );
        }
 
+       /**
+        * @param array[] $expected
+        * @param array[] $notifications
+        */
        private function assertNotifications( array $expected, array 
$notifications ) {
                foreach ( $notifications as &$n ) {
                        $n[1] = $this->getChangeIds( $n[1] );
diff --git a/repo/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php 
b/repo/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
index bebb80a..847da7f 100644
--- a/repo/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
+++ b/repo/tests/phpunit/includes/Hooks/InfoActionHookHandlerTest.php
@@ -114,7 +114,12 @@
 
                $siteLookup->expects( $this->any() )
                        ->method( 'getSite' )
-                       ->will( $this->returnCallback( [ $this, 'getSite' ] ) );
+                       ->will( $this->returnCallback( function () {
+                               $site = new Site();
+                               $site->addInterwikiId( 'en' );
+                               $site->setLinkPath( 
'https://en.wikipedia.org/wiki/$1' );
+                               return $site;
+                       } ) );
 
                $entityIdLookup = $this->getMockBuilder( 
PagePropsEntityIdLookup::class )
                        ->disableOriginalConstructor()
@@ -166,16 +171,6 @@
                $context->setLanguage( 'en' );
 
                return $context;
-       }
-
-       /**
-        * @return Site
-        */
-       public function getSite() {
-               $site = new Site();
-               $site->addInterwikiId( 'en' );
-               $site->setLinkPath( 'https://en.wikipedia.org/wiki/$1' );
-               return $site;
        }
 
 }
diff --git a/repo/tests/phpunit/includes/SummaryFormatterTest.php 
b/repo/tests/phpunit/includes/SummaryFormatterTest.php
index 2a5c014..e8eceb7 100644
--- a/repo/tests/phpunit/includes/SummaryFormatterTest.php
+++ b/repo/tests/phpunit/includes/SummaryFormatterTest.php
@@ -73,8 +73,7 @@
         */
        public function formatSnak( Snak $snak ) {
                if ( $snak instanceof PropertyValueSnak ) {
-                       $value = $snak->getDataValue();
-                       return $this->formatValue( $value );
+                       return $this->formatValue( $snak->getDataValue() );
                } else {
                        return $snak->getType();
                }
@@ -85,19 +84,24 @@
         */
        private function newFormatter() {
                $idFormatter = $this->getMock( EntityIdFormatter::class );
-               $idFormatter->expects( $this->any() )->method( 'formatEntityId' 
)
+               $idFormatter->expects( $this->any() )
+                       ->method( 'formatEntityId' )
                        ->will( $this->returnCallback( array( $this, 'formatId' 
) ) );
 
                $valueFormatter = $this->getMock( ValueFormatter::class );
-               $valueFormatter->expects( $this->any() )->method( 'format' )
+               $valueFormatter->expects( $this->any() )
+                       ->method( 'format' )
                        ->will( $this->returnCallback( array( $this, 
'formatValue' ) ) );
-               $valueFormatter->expects( $this->any() )->method( 'getFormat' )
+               $valueFormatter->expects( $this->any() )
+                       ->method( 'getFormat' )
                        ->will( $this->returnValue( SnakFormatter::FORMAT_PLAIN 
) );
 
                $snakFormatter = $this->getMock( SnakFormatter::class );
-               $snakFormatter->expects( $this->any() )->method( 'formatSnak' )
+               $snakFormatter->expects( $this->any() )
+                       ->method( 'formatSnak' )
                        ->will( $this->returnCallback( array( $this, 
'formatSnak' ) ) );
-               $snakFormatter->expects( $this->any() )->method( 'getFormat' )
+               $snakFormatter->expects( $this->any() )
+                       ->method( 'getFormat' )
                        ->will( $this->returnValue( SnakFormatter::FORMAT_PLAIN 
) );
 
                $language = Language::factory( 'en' );
@@ -128,7 +132,7 @@
 
                $formatter = $this->newFormatter();
                $result = $formatter->formatAutoComment( $summary );
-               $this->assertEquals( $expected, $result, 'Not the expected 
result' );
+               $this->assertSame( $expected, $result, 'Not the expected 
result' );
        }
 
        public function providerFormatAutoComment() {
@@ -210,7 +214,7 @@
 
                $formatter = $this->newFormatter();
                $result = $formatter->formatAutoSummary( $summary );
-               $this->assertEquals( $expected, $result, 'Not the expected 
result' );
+               $this->assertSame( $expected, $result, 'Not the expected 
result' );
        }
 
        public function providerFormatAutoSummary() {
@@ -244,7 +248,7 @@
                $summary->addAutoSummaryArgs( $summaryArgs );
 
                $formatter = $this->newFormatter();
-               $this->assertEquals( $expected, $formatter->formatSummary( 
$summary ) );
+               $this->assertSame( $expected, $formatter->formatSummary( 
$summary ) );
        }
 
        public function provideToStringArgs() {
@@ -324,7 +328,7 @@
                }
 
                $formatter = $this->newFormatter();
-               $this->assertEquals( $expected, $formatter->formatSummary( 
$summary ) );
+               $this->assertSame( $expected, $formatter->formatSummary( 
$summary ) );
        }
 
        public function provideFormatSummary() {
@@ -449,16 +453,20 @@
         */
        public function testOnFormat( $type, $root, $pre, $auto, $post, $title, 
$local, $expected ) {
                $itemTitle = $this->getMock( $title );
-               $itemTitle->expects( $this->once() )->method( 'getNamespace' 
)->will( $this->returnValue(
-                       
WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup()->getEntityNamespace(
 $type )
-               ) );
+               $itemTitle->expects( $this->once() )
+                       ->method( 'getNamespace' )
+                       ->will( $this->returnValue(
+                               WikibaseRepo::getDefaultInstance()
+                                       ->getEntityNamespaceLookup()
+                                       ->getEntityNamespace( $type )
+                       ) );
 
                $comment = null;
 
                RepoHooks::onFormat( $comment, $pre, $auto, $post, $itemTitle, 
$local );
 
                if ( is_null( $expected ) ) {
-                       $this->assertEquals( $expected, $comment, "Didn't find 
the expected null" );
+                       $this->assertNull( $comment, 'Didn\'t find the expected 
null' );
                } else {
                        $this->assertRegExp( $expected, $comment, "Didn't find 
the expected final comment" );
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9fc91859847cd14448484798a900ecf11c28baa3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to