Stop doing $that = $this in Tests
authoraddshore <addshorewiki@gmail.com>
Thu, 4 Feb 2016 21:09:07 +0000 (22:09 +0100)
committerMax Semenik <maxsem.wiki@gmail.com>
Wed, 10 Feb 2016 07:27:25 +0000 (23:27 -0800)
Closures support $this as of 5.4

Change-Id: Ibe73c789d093ef994b61bed23b4c76f7ef057a33

tests/phpunit/includes/libs/ArrayUtilsTest.php
tests/phpunit/includes/site/CachingSiteStoreTest.php
tests/phpunit/includes/site/SiteImporterTest.php

index 32b150c..3efc4c3 100644 (file)
@@ -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;
                        };
                };
index 4305ceb..dd62074 100644 (file)
@@ -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;
                        } ) );
index b11b1a9..a49f06c 100644 (file)
@@ -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() )