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

Change subject: Stop doing $that = $this in Client Tests
......................................................................


Stop doing $that = $this in Client Tests

Closuers support $this as of 5.4

Change-Id: Ib003ca21e6d1554e1ce5bed4df8f1567db14ffb6
Depends-On: I68c5b5d60952418ff8300c163edfe2275571f41f
---
M 
client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
M 
client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
M 
client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
M client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
M client/tests/phpunit/includes/LangLinkHandlerTest.php
M client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
M client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
M client/tests/phpunit/includes/api/PageTermsTest.php
8 files changed, 25 insertions(+), 38 deletions(-)

Approvals:
  Thiemo Mättig (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
 
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
index 3bc40e4..e3fc738 100644
--- 
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
@@ -149,16 +149,15 @@
                $formatterFactory = $this->getMockBuilder( 
'Wikibase\Lib\OutputFormatSnakFormatterFactory' )
                        ->disableOriginalConstructor()
                        ->getMock();
-               $self = $this;
                $formatterFactory->expects( $this->once() )
                        ->method( 'getSnakFormatter' )
                        ->will( $this->returnCallback(
-                               function( $format, FormatterOptions $options ) 
use ( $self, $allowDataAccessInUserLanguage )  {
-                                       $self->assertSame(
+                               function( $format, FormatterOptions $options ) 
use ( $allowDataAccessInUserLanguage )  {
+                                       $this->assertSame(
                                                $allowDataAccessInUserLanguage 
? 'es' : 'de',
                                                $options->getOption( 
ValueFormatter::OPT_LANG )
                                        );
-                                       return $self->getMock( 
'Wikibase\Lib\SnakFormatter' );
+                                       return $this->getMock( 
'Wikibase\Lib\SnakFormatter' );
                                }
                        ) );
 
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
index 11bfc8f..508e34b 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
@@ -160,10 +160,9 @@
                        Parser::OT_HTML
                );
 
-               $self = $this; // PHP 5.3 ...
                $parserOptions->registerWatcher(
-                       function( $optionName ) use ( $self, &$cacheSplit ) {
-                               $self->assertSame( 'userlang', $optionName );
+                       function( $optionName ) use ( &$cacheSplit ) {
+                               $this->assertSame( 'userlang', $optionName );
                                $cacheSplit = true;
                        }
                );
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
index 21582d4..2a3a9f6 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
@@ -319,10 +319,9 @@
                        Parser::OT_HTML
                );
 
-               $self = $this; // PHP 5.3 ...
                $parserOptions->registerWatcher(
-                       function( $optionName ) use ( $self, &$cacheSplit ) {
-                               $self->assertSame( 'userlang', $optionName );
+                       function( $optionName ) use ( &$cacheSplit ) {
+                               $this->assertSame( 'userlang', $optionName );
                                $cacheSplit = true;
                        }
                );
diff --git 
a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php 
b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
index f92a9fb..00a0c4f 100644
--- a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
+++ b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
@@ -140,12 +140,11 @@
                        'href' => 'https://en.wikipedia.org/wiki/Cat',
                        'hreflang' => 'en'
                );
-               $self = $this; // PHP 5.3 :(
 
                return array(
                        'Noop hook, gets the right data' => array(
-                               function( ItemId $itemId, array &$sidebar ) use 
( $wikipediaLink, $wikiquoteLink, $wiktionaryLink, $self ) {
-                                       $self->assertSame(
+                               function( ItemId $itemId, array &$sidebar ) use 
( $wikipediaLink, $wikiquoteLink, $wiktionaryLink ) {
+                                       $this->assertSame(
                                                array(
                                                        'wikiquote' => array( 
'enwikiquote' => $wikiquoteLink ),
                                                        'wikipedia' => array( 
'enwiki' => $wikipediaLink ),
@@ -153,7 +152,7 @@
                                                ),
                                                $sidebar
                                        );
-                                       $self->assertSame( 'Q123', 
$itemId->getSerialization() );
+                                       $this->assertSame( 'Q123', 
$itemId->getSerialization() );
                                },
                                array( 'enwiktionary', 'enwiki', 'enwikiquote' 
),
                                array( $wikipediaLink, $wikiquoteLink, 
$wiktionaryLink )
@@ -166,8 +165,8 @@
                                array( $changedWikipedaLink, $wikiquoteLink, 
$wiktionaryLink )
                        ),
                        'Hook inserts enwiki link' => array(
-                               function( ItemId $itemId, array &$sidebar ) use 
( $changedWikipedaLink, $self ) {
-                                       $self->assertFalse(
+                               function( ItemId $itemId, array &$sidebar ) use 
( $changedWikipedaLink ) {
+                                       $this->assertFalse(
                                                isset( $sidebar['wikipedia'] ),
                                                'No Wikipedia link present yet'
                                        );
@@ -213,10 +212,8 @@
        }
 
        public function 
testBuildProjectLinkSidebar_hookNotCalledIfPageNotConnected() {
-               $self = $this; // We all love PHP 5.3
-
-               $handler = function() use ( $self ) {
-                       $self->assertTrue( false, "Should not get called." );
+               $handler = function() {
+                       $this->assertTrue( false, "Should not get called." );
                };
 
                $this->setMwGlobals( 'wgHooks', array( 
'WikibaseClientOtherProjectsSidebar' => array( $handler ) ) );
@@ -240,12 +237,11 @@
        }
 
        public function 
testBuildProjectLinkSidebar_hookCalledWithEmptySidebar() {
-               $self = $this; // We all love PHP 5.3
                $called = false;
 
-               $handler = function( ItemId $itemId, $sidebar ) use ( $self, 
&$called ) {
-                       $self->assertSame( 'Q123', $itemId->getSerialization() 
);
-                       $self->assertSame( array(), $sidebar );
+               $handler = function( ItemId $itemId, $sidebar ) use ( &$called 
) {
+                       $this->assertSame( 'Q123', $itemId->getSerialization() 
);
+                       $this->assertSame( array(), $sidebar );
                        $called = true;
                };
 
diff --git a/client/tests/phpunit/includes/LangLinkHandlerTest.php 
b/client/tests/phpunit/includes/LangLinkHandlerTest.php
index 4fa922f..c8ccc50 100644
--- a/client/tests/phpunit/includes/LangLinkHandlerTest.php
+++ b/client/tests/phpunit/includes/LangLinkHandlerTest.php
@@ -99,12 +99,10 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $this_ = $this;
-
                $badgeDisplay->expects( $this->any() )
                        ->method( 'attachBadgesToOutput' )
-                       ->will( $this->returnCallback( function ( array 
$siteLinks, ParserOutput $parserOutput ) use ( $this_ ) {
-                               $badges = $this_->linksToBadges( $siteLinks );
+                       ->will( $this->returnCallback( function ( array 
$siteLinks, ParserOutput $parserOutput ) {
+                               $badges = $this->linksToBadges( $siteLinks );
                                $parserOutput->setExtensionData( 
'wikibase_badges', $badges );
                        } ) );
 
diff --git 
a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php 
b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
index 9646820..b2116e4 100644
--- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
+++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
@@ -78,12 +78,11 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $self = $this; // PHP 5.3 compat
                $jobQueueGroupMock->expects( $this->once() )
                        ->method( 'push' )
                        ->will(
-                               $this->returnCallback( function( 
JobSpecification $job ) use( $self ) {
-                                       $self->verifyJob( $job );
+                               $this->returnCallback( function( 
JobSpecification $job ) {
+                                       $this->verifyJob( $job );
                                } )
                        );
 
diff --git a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php 
b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
index fb6872e..dbb190e 100644
--- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
+++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
@@ -82,12 +82,11 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $self = $this; // PHP 5.3 compat
                $jobQueueGroupMock->expects( $this->once() )
                        ->method( 'push' )
                        ->will(
-                               $this->returnCallback( function( 
JobSpecification $job ) use( $self ) {
-                                       $self->verifyJob( $job );
+                               $this->returnCallback( function( 
JobSpecification $job ) {
+                                       $this->verifyJob( $job );
                                } )
                        );
 
diff --git a/client/tests/phpunit/includes/api/PageTermsTest.php 
b/client/tests/phpunit/includes/api/PageTermsTest.php
index d8fbcdd..9487c52 100644
--- a/client/tests/phpunit/includes/api/PageTermsTest.php
+++ b/client/tests/phpunit/includes/api/PageTermsTest.php
@@ -121,14 +121,12 @@
                        $termObjectsByEntityId[$key] = 
$this->makeTermsFromGroups( $entityId, $termGroups );
                }
 
-               $self = $this;
-
                $termIndex = $this->getMock( 'Wikibase\TermIndex' );
                $termIndex->expects( $this->any() )
                        ->method( 'getTermsOfEntities' )
                        ->will( $this->returnCallback(
-                               function( array $entityIds, array $termTypes = 
null, array $languagesCodes = null ) use ( $termObjectsByEntityId, $self ) {
-                                       return $self->getTermsOfEntities( 
$termObjectsByEntityId, $entityIds, $termTypes, $languagesCodes );
+                               function( array $entityIds, array $termTypes = 
null, array $languagesCodes = null ) use ( $termObjectsByEntityId ) {
+                                       return $this->getTermsOfEntities( 
$termObjectsByEntityId, $entityIds, $termTypes, $languagesCodes );
                                }
                        ) );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib003ca21e6d1554e1ce5bed4df8f1567db14ffb6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
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