From be3176e75ac0880f84b8f1728969ba361fa96213 Mon Sep 17 00:00:00 2001 From: addshore Date: Thu, 4 Feb 2016 22:09:07 +0100 Subject: [PATCH] Stop doing $that = $this in Tests Closures support $this as of 5.4 Change-Id: Ibe73c789d093ef994b61bed23b4c76f7ef057a33 --- tests/phpunit/includes/libs/ArrayUtilsTest.php | 9 ++++----- tests/phpunit/includes/site/CachingSiteStoreTest.php | 9 +++------ tests/phpunit/includes/site/SiteImporterTest.php | 5 ++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/includes/libs/ArrayUtilsTest.php b/tests/phpunit/includes/libs/ArrayUtilsTest.php index 32b150c7e6..3efc4c3062 100644 --- a/tests/phpunit/includes/libs/ArrayUtilsTest.php +++ b/tests/phpunit/includes/libs/ArrayUtilsTest.php @@ -23,11 +23,10 @@ class ArrayUtilsTest extends PHPUnit_Framework_TestCase { } function provideFindLowerBound() { - $that = $this; - $indexValueCallback = function ( $size ) use ( $that ) { - return function ( $val ) use ( $that, $size ) { - $that->assertTrue( $val >= 0 ); - $that->assertTrue( $val < $size ); + $indexValueCallback = function ( $size ) { + return function ( $val ) use ( $size ) { + $this->assertTrue( $val >= 0 ); + $this->assertTrue( $val < $size ); return $val; }; }; diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php index 4305ceb94c..dd62074f9c 100644 --- a/tests/phpunit/includes/site/CachingSiteStoreTest.php +++ b/tests/phpunit/includes/site/CachingSiteStoreTest.php @@ -95,18 +95,15 @@ class CachingSiteStoreTest extends MediaWikiTestCase { ->disableOriginalConstructor() ->getMock(); - // php 5.3 compatibility! - $that = $this; - $dbSiteStore->expects( $this->any() ) ->method( 'getSite' ) - ->will( $this->returnValue( $that->getTestSite() ) ); + ->will( $this->returnValue( $this->getTestSite() ) ); $dbSiteStore->expects( $this->any() ) ->method( 'getSites' ) - ->will( $this->returnCallback( function() use ( $that ) { + ->will( $this->returnCallback( function() { $siteList = new SiteList(); - $siteList->setSite( $that->getTestSite() ); + $siteList->setSite( $this->getTestSite() ); return $siteList; } ) ); diff --git a/tests/phpunit/includes/site/SiteImporterTest.php b/tests/phpunit/includes/site/SiteImporterTest.php index b11b1a9f6b..a49f06cfed 100644 --- a/tests/phpunit/includes/site/SiteImporterTest.php +++ b/tests/phpunit/includes/site/SiteImporterTest.php @@ -34,11 +34,10 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase { private function newSiteImporter( array $expectedSites, $errorCount ) { $store = $this->getMock( 'SiteStore' ); - $that = $this; $store->expects( $this->once() ) ->method( 'saveSites' ) - ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites, $that ) { - $that->assertSitesEqual( $expectedSites, $sites ); + ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites ) { + $this->assertSitesEqual( $expectedSites, $sites ); } ) ); $store->expects( $this->any() ) -- 2.20.1