jenkins-bot has submitted this change and it was merged.

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


Stop doing $that = $this in Repo Tests

Closuers support $this as of 5.4

Change-Id: Ie0d5a9adef1db5c4dae892e3062fc58ebc00efa7
Depends-On: I68c5b5d60952418ff8300c163edfe2275571f41f
---
M repo/tests/phpunit/includes/CachingCommonsMediaFileNameLookupTest.php
M repo/tests/phpunit/includes/ChangePrunerTest.php
M repo/tests/phpunit/includes/Dumpers/JsonDumpGeneratorTest.php
M repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php
M repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php
M repo/tests/phpunit/includes/Interactors/RedirectCreationInteractorTest.php
M repo/tests/phpunit/includes/api/CreateRedirectTest.php
M repo/tests/phpunit/includes/api/EntitySearchHelperTest.php
M repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php
M repo/tests/phpunit/includes/specials/SpecialRedirectEntityTest.php
M repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php
11 files changed, 41 insertions(+), 53 deletions(-)

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



diff --git 
a/repo/tests/phpunit/includes/CachingCommonsMediaFileNameLookupTest.php 
b/repo/tests/phpunit/includes/CachingCommonsMediaFileNameLookupTest.php
index f801935..a2dd042 100644
--- a/repo/tests/phpunit/includes/CachingCommonsMediaFileNameLookupTest.php
+++ b/repo/tests/phpunit/includes/CachingCommonsMediaFileNameLookupTest.php
@@ -80,11 +80,10 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $self = $this; // We all love PHP 5.3
                $fileNameLookup->expects( $matcher )
                        ->method( 'normalizePageName' )
-                       ->will( $this->returnCallback( function( $fileName, 
$apiUrl ) use ( $self ) {
-                               $self->assertSame( 
'https://commons.wikimedia.org/w/api.php', $apiUrl );
+                       ->will( $this->returnCallback( function( $fileName, 
$apiUrl ) {
+                               $this->assertSame( 
'https://commons.wikimedia.org/w/api.php', $apiUrl );
 
                                if ( strpos( $fileName, 'NOT-FOUND' ) !== false 
) {
                                        return false;
diff --git a/repo/tests/phpunit/includes/ChangePrunerTest.php 
b/repo/tests/phpunit/includes/ChangePrunerTest.php
index 97d9f3b..455a2f2 100644
--- a/repo/tests/phpunit/includes/ChangePrunerTest.php
+++ b/repo/tests/phpunit/includes/ChangePrunerTest.php
@@ -93,10 +93,9 @@
        private function newMessageReporter() {
                $reporter = new ObservableMessageReporter();
 
-               $self = $this; // evil PHP 5.3 ;)
                $reporter->registerReporterCallback(
-                       function ( $message ) use ( $self ) {
-                               $self->messages[] = $message;
+                       function ( $message ) {
+                               $this->messages[] = $message;
                        }
                );
 
diff --git a/repo/tests/phpunit/includes/Dumpers/JsonDumpGeneratorTest.php 
b/repo/tests/phpunit/includes/Dumpers/JsonDumpGeneratorTest.php
index 70bce76..bb61630 100644
--- a/repo/tests/phpunit/includes/Dumpers/JsonDumpGeneratorTest.php
+++ b/repo/tests/phpunit/includes/Dumpers/JsonDumpGeneratorTest.php
@@ -175,13 +175,12 @@
        public function makeIdPager( array $ids, $entityType = null ) {
                $pager = $this->getMock( 'Wikibase\Repo\Store\EntityIdPager' );
 
-               $self = $this;
                $offset = 0;
 
                $pager->expects( $this->any() )
                        ->method( 'fetchIds' )
-                       ->will( $this->returnCallback( function( $limit ) use ( 
$ids, $entityType, &$offset, $self ) {
-                               return $self->listEntities( $ids, $entityType, 
$limit, $offset );
+                       ->will( $this->returnCallback( function( $limit ) use ( 
$ids, $entityType, &$offset ) {
+                               return $this->listEntities( $ids, $entityType, 
$limit, $offset );
                        } ) );
 
                return $pager;
diff --git a/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php 
b/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php
index 0f1910e..45e861b 100644
--- a/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php
+++ b/repo/tests/phpunit/includes/Hooks/EditFilterHookRunnerTest.php
@@ -154,8 +154,6 @@
                        array( 'EditFilterMergedContent' => array() )
                );
 
-               $testCase = $this;
-
                $hooks['EditFilterMergedContent'][] =
                        function(
                                IContextSource $context,
@@ -164,16 +162,16 @@
                                $summary,
                                User $user,
                                $minoredit
-                       ) use ( $testCase, $expected, $inputStatus )
+                       ) use ( $expected, $inputStatus )
                        {
-                               $testCase->assertEquals( $expected['title'], 
$context->getTitle()->getFullText() );
-                               $testCase->assertSame( $context->getTitle(), 
$context->getWikiPage()->getTitle() );
-                               $testCase->assertEquals( 
$expected['namespace'], $context->getTitle()->getNamespace() );
-                               $testCase->assertEquals( 
ItemContent::newEmpty(), $content );
-                               $testCase->assertTrue( $status->isGood() );
-                               $testCase->assertTrue( is_string( $summary ) );
-                               $testCase->assertEquals( 
'EditFilterHookRunnerTestUser', $user->getName() );
-                               $testCase->assertTrue( is_bool( $minoredit ) );
+                               $this->assertEquals( $expected['title'], 
$context->getTitle()->getFullText() );
+                               $this->assertSame( $context->getTitle(), 
$context->getWikiPage()->getTitle() );
+                               $this->assertEquals( $expected['namespace'], 
$context->getTitle()->getNamespace() );
+                               $this->assertEquals( ItemContent::newEmpty(), 
$content );
+                               $this->assertTrue( $status->isGood() );
+                               $this->assertTrue( is_string( $summary ) );
+                               $this->assertEquals( 
'EditFilterHookRunnerTestUser', $user->getName() );
+                               $this->assertTrue( is_bool( $minoredit ) );
 
                                //Change the status
                                $status->merge( $inputStatus );
diff --git 
a/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php 
b/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php
index ea37bc1..f2f31af 100644
--- a/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php
+++ b/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php
@@ -165,14 +165,13 @@
        private function getMockEntityTitleLookup() {
                $titleLookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
 
-               $testCase = $this;
                $titleLookup->expects( $this->any() )
                        ->method( 'getTitleForID' )
-                       ->will( $this->returnCallback( function( EntityId $id ) 
use ( $testCase ) {
-                               $title = $testCase->getMock( 'Title' );
-                               $title->expects( $testCase->any() )
+                       ->will( $this->returnCallback( function( EntityId $id ) 
{
+                               $title = $this->getMock( 'Title' );
+                               $title->expects( $this->any() )
                                        ->method( 'isDeleted' )
-                                       ->will( $testCase->returnValue( false ) 
);
+                                       ->will( $this->returnValue( false ) );
                                return $title;
                        } ) );
 
diff --git 
a/repo/tests/phpunit/includes/Interactors/RedirectCreationInteractorTest.php 
b/repo/tests/phpunit/includes/Interactors/RedirectCreationInteractorTest.php
index 713bff5..2a860d8 100644
--- a/repo/tests/phpunit/includes/Interactors/RedirectCreationInteractorTest.php
+++ b/repo/tests/phpunit/includes/Interactors/RedirectCreationInteractorTest.php
@@ -155,14 +155,13 @@
        private function getMockEntityTitleLookup() {
                $titleLookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
 
-               $testCase = $this;
                $titleLookup->expects( $this->any() )
                        ->method( 'getTitleForID' )
-                       ->will( $this->returnCallback( function( EntityId $id ) 
use ( $testCase ) {
-                               $title = $testCase->getMock( 'Title' );
-                               $title->expects( $testCase->any() )
+                       ->will( $this->returnCallback( function( EntityId $id ) 
{
+                               $title = $this->getMock( 'Title' );
+                               $title->expects( $this->any() )
                                        ->method( 'isDeleted' )
-                                       ->will( $testCase->returnValue( 
$id->getSerialization() === 'Q666' ) );
+                                       ->will( $this->returnValue( 
$id->getSerialization() === 'Q666' ) );
                                return $title;
                        } ) );
 
diff --git a/repo/tests/phpunit/includes/api/CreateRedirectTest.php 
b/repo/tests/phpunit/includes/api/CreateRedirectTest.php
index 56a6cae..4f6d043 100644
--- a/repo/tests/phpunit/includes/api/CreateRedirectTest.php
+++ b/repo/tests/phpunit/includes/api/CreateRedirectTest.php
@@ -148,14 +148,13 @@
        private function getMockEntityTitleLookup() {
                $titleLookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
 
-               $testCase = $this;
                $titleLookup->expects( $this->any() )
                        ->method( 'getTitleForID' )
-                       ->will( $this->returnCallback( function( EntityId $id ) 
use ( $testCase ) {
-                               $title = $testCase->getMock( 'Title' );
-                               $title->expects( $testCase->any() )
+                       ->will( $this->returnCallback( function( EntityId $id ) 
{
+                               $title = $this->getMock( 'Title' );
+                               $title->expects( $this->any() )
                                        ->method( 'isDeleted' )
-                                       ->will( $testCase->returnValue( false ) 
);
+                                       ->will( $this->returnValue( false ) );
                                return $title;
                        } ) );
 
diff --git a/repo/tests/phpunit/includes/api/EntitySearchHelperTest.php 
b/repo/tests/phpunit/includes/api/EntitySearchHelperTest.php
index 08ef3ae..b567c9d 100644
--- a/repo/tests/phpunit/includes/api/EntitySearchHelperTest.php
+++ b/repo/tests/phpunit/includes/api/EntitySearchHelperTest.php
@@ -31,13 +31,12 @@
         */
        private function getMockTitleLookup() {
                $titleLookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
-               $testCase = $this;
                $titleLookup->expects( $this->any() )->method( 'getTitleForId' )
-                       ->will( $this->returnCallback( function( EntityId $id ) 
use ( $testCase ) {
+                       ->will( $this->returnCallback( function( EntityId $id ) 
{
                                if ( $id->getSerialization() === 'Q111' ) {
-                                       return $testCase->getMockTitle( true );
+                                       return $this->getMockTitle( true );
                                } else {
-                                       return $testCase->getMockTitle( false );
+                                       return $this->getMockTitle( false );
                                }
                        } ) );
                return $titleLookup;
diff --git a/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php 
b/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php
index 7f93104..eaea97a 100644
--- a/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php
@@ -182,14 +182,13 @@
        private function getMockEntityTitleLookup() {
                $titleLookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
 
-               $testCase = $this;
                $titleLookup->expects( $this->any() )
                        ->method( 'getTitleForID' )
-                       ->will( $this->returnCallback( function( EntityId $id ) 
use ( $testCase ) {
-                               $title = $testCase->getMock( 'Title' );
-                               $title->expects( $testCase->any() )
+                       ->will( $this->returnCallback( function( EntityId $id ) 
{
+                               $title = $this->getMock( 'Title' );
+                               $title->expects( $this->any() )
                                        ->method( 'isDeleted' )
-                                       ->will( $testCase->returnValue( false ) 
);
+                                       ->will( $this->returnValue( false ) );
                                return $title;
                        } ) );
 
diff --git a/repo/tests/phpunit/includes/specials/SpecialRedirectEntityTest.php 
b/repo/tests/phpunit/includes/specials/SpecialRedirectEntityTest.php
index 1b812a1..83411b0 100644
--- a/repo/tests/phpunit/includes/specials/SpecialRedirectEntityTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialRedirectEntityTest.php
@@ -88,14 +88,13 @@
        private function getMockEntityTitleLookup() {
                $titleLookup = $this->getMock( 
'Wikibase\Lib\Store\EntityTitleLookup' );
 
-               $testCase = $this;
                $titleLookup->expects( $this->any() )
                        ->method( 'getTitleForID' )
-                       ->will( $this->returnCallback( function( EntityId $id ) 
use ( $testCase ) {
-                               $title = $testCase->getMock( 'Title' );
-                               $title->expects( $testCase->any() )
+                       ->will( $this->returnCallback( function( EntityId $id ) 
{
+                               $title = $this->getMock( 'Title' );
+                               $title->expects( $this->any() )
                                        ->method( 'isDeleted' )
-                                       ->will( $testCase->returnValue( false ) 
);
+                                       ->will( $this->returnValue( false ) );
                                return $title;
                        } ) );
 
diff --git 
a/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php
 
b/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php
index 1667451..a4c2d3f 100644
--- 
a/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php
+++ 
b/repo/tests/phpunit/includes/specials/SpecialSetLabelDescriptionAliasesTest.php
@@ -105,7 +105,6 @@
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $self = $this;
                $detector->expects( $this->any() )
                        ->method( 'detectLabelDescriptionConflicts' )
                        ->will( $this->returnCallback( function(
@@ -113,11 +112,11 @@
                                array $labels,
                                array $descriptions,
                                EntityId $ignoreEntityId = null
-                       ) use ( $self ) {
+                       ) {
                                $errors = array();
 
-                               $errors = array_merge( $errors, 
$self->detectDupes( $labels ) );
-                               $errors = array_merge( $errors, 
$self->detectDupes( $descriptions ) );
+                               $errors = array_merge( $errors, 
$this->detectDupes( $labels ) );
+                               $errors = array_merge( $errors, 
$this->detectDupes( $descriptions ) );
 
                                $result = empty( $errors ) ? 
Result::newSuccess() : Result::newError( $errors );
                                return $result;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie0d5a9adef1db5c4dae892e3062fc58ebc00efa7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[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

Reply via email to