Bene has uploaded a new change for review.
https://gerrit.wikimedia.org/r/268950
Change subject: Revert "Stop doing $that = $this in Client Tests"
......................................................................
Revert "Stop doing $that = $this in Client Tests"
This reverts commit afa336358a547baf0e3d6d9bcc0c7792113e2da8.
Change-Id: Ice118f395e7832fd4ea79f4fcca97870b59c83b8
---
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, 38 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/50/268950/1
diff --git
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
index e3fc738..3bc40e4 100644
---
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
+++
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/StatementGroupRendererFactoryTest.php
@@ -149,15 +149,16 @@
$formatterFactory = $this->getMockBuilder(
'Wikibase\Lib\OutputFormatSnakFormatterFactory' )
->disableOriginalConstructor()
->getMock();
+ $self = $this;
$formatterFactory->expects( $this->once() )
->method( 'getSnakFormatter' )
->will( $this->returnCallback(
- function( $format, FormatterOptions $options )
use ( $allowDataAccessInUserLanguage ) {
- $this->assertSame(
+ function( $format, FormatterOptions $options )
use ( $self, $allowDataAccessInUserLanguage ) {
+ $self->assertSame(
$allowDataAccessInUserLanguage
? 'es' : 'de',
$options->getOption(
ValueFormatter::OPT_LANG )
);
- return $this->getMock(
'Wikibase\Lib\SnakFormatter' );
+ return $self->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 508e34b..11bfc8f 100644
---
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
+++
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseEntityLibraryTest.php
@@ -160,9 +160,10 @@
Parser::OT_HTML
);
+ $self = $this; // PHP 5.3 ...
$parserOptions->registerWatcher(
- function( $optionName ) use ( &$cacheSplit ) {
- $this->assertSame( 'userlang', $optionName );
+ function( $optionName ) use ( $self, &$cacheSplit ) {
+ $self->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 2a3a9f6..21582d4 100644
---
a/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
+++
b/client/tests/phpunit/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibraryTest.php
@@ -319,9 +319,10 @@
Parser::OT_HTML
);
+ $self = $this; // PHP 5.3 ...
$parserOptions->registerWatcher(
- function( $optionName ) use ( &$cacheSplit ) {
- $this->assertSame( 'userlang', $optionName );
+ function( $optionName ) use ( $self, &$cacheSplit ) {
+ $self->assertSame( 'userlang', $optionName );
$cacheSplit = true;
}
);
diff --git
a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
index 00a0c4f..f92a9fb 100644
--- a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
+++ b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php
@@ -140,11 +140,12 @@
'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 ) {
- $this->assertSame(
+ function( ItemId $itemId, array &$sidebar ) use
( $wikipediaLink, $wikiquoteLink, $wiktionaryLink, $self ) {
+ $self->assertSame(
array(
'wikiquote' => array(
'enwikiquote' => $wikiquoteLink ),
'wikipedia' => array(
'enwiki' => $wikipediaLink ),
@@ -152,7 +153,7 @@
),
$sidebar
);
- $this->assertSame( 'Q123',
$itemId->getSerialization() );
+ $self->assertSame( 'Q123',
$itemId->getSerialization() );
},
array( 'enwiktionary', 'enwiki', 'enwikiquote'
),
array( $wikipediaLink, $wikiquoteLink,
$wiktionaryLink )
@@ -165,8 +166,8 @@
array( $changedWikipedaLink, $wikiquoteLink,
$wiktionaryLink )
),
'Hook inserts enwiki link' => array(
- function( ItemId $itemId, array &$sidebar ) use
( $changedWikipedaLink ) {
- $this->assertFalse(
+ function( ItemId $itemId, array &$sidebar ) use
( $changedWikipedaLink, $self ) {
+ $self->assertFalse(
isset( $sidebar['wikipedia'] ),
'No Wikipedia link present yet'
);
@@ -212,8 +213,10 @@
}
public function
testBuildProjectLinkSidebar_hookNotCalledIfPageNotConnected() {
- $handler = function() {
- $this->assertTrue( false, "Should not get called." );
+ $self = $this; // We all love PHP 5.3
+
+ $handler = function() use ( $self ) {
+ $self->assertTrue( false, "Should not get called." );
};
$this->setMwGlobals( 'wgHooks', array(
'WikibaseClientOtherProjectsSidebar' => array( $handler ) ) );
@@ -237,11 +240,12 @@
}
public function
testBuildProjectLinkSidebar_hookCalledWithEmptySidebar() {
+ $self = $this; // We all love PHP 5.3
$called = false;
- $handler = function( ItemId $itemId, $sidebar ) use ( &$called
) {
- $this->assertSame( 'Q123', $itemId->getSerialization()
);
- $this->assertSame( array(), $sidebar );
+ $handler = function( ItemId $itemId, $sidebar ) use ( $self,
&$called ) {
+ $self->assertSame( 'Q123', $itemId->getSerialization()
);
+ $self->assertSame( array(), $sidebar );
$called = true;
};
diff --git a/client/tests/phpunit/includes/LangLinkHandlerTest.php
b/client/tests/phpunit/includes/LangLinkHandlerTest.php
index c8ccc50..4fa922f 100644
--- a/client/tests/phpunit/includes/LangLinkHandlerTest.php
+++ b/client/tests/phpunit/includes/LangLinkHandlerTest.php
@@ -99,10 +99,12 @@
->disableOriginalConstructor()
->getMock();
+ $this_ = $this;
+
$badgeDisplay->expects( $this->any() )
->method( 'attachBadgesToOutput' )
- ->will( $this->returnCallback( function ( array
$siteLinks, ParserOutput $parserOutput ) {
- $badges = $this->linksToBadges( $siteLinks );
+ ->will( $this->returnCallback( function ( array
$siteLinks, ParserOutput $parserOutput ) use ( $this_ ) {
+ $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 b2116e4..9646820 100644
--- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
+++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnDeleteTest.php
@@ -78,11 +78,12 @@
->disableOriginalConstructor()
->getMock();
+ $self = $this; // PHP 5.3 compat
$jobQueueGroupMock->expects( $this->once() )
->method( 'push' )
->will(
- $this->returnCallback( function(
JobSpecification $job ) {
- $this->verifyJob( $job );
+ $this->returnCallback( function(
JobSpecification $job ) use( $self ) {
+ $self->verifyJob( $job );
} )
);
diff --git a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
index dbb190e..fb6872e 100644
--- a/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
+++ b/client/tests/phpunit/includes/UpdateRepo/UpdateRepoOnMoveTest.php
@@ -82,11 +82,12 @@
->disableOriginalConstructor()
->getMock();
+ $self = $this; // PHP 5.3 compat
$jobQueueGroupMock->expects( $this->once() )
->method( 'push' )
->will(
- $this->returnCallback( function(
JobSpecification $job ) {
- $this->verifyJob( $job );
+ $this->returnCallback( function(
JobSpecification $job ) use( $self ) {
+ $self->verifyJob( $job );
} )
);
diff --git a/client/tests/phpunit/includes/api/PageTermsTest.php
b/client/tests/phpunit/includes/api/PageTermsTest.php
index 9487c52..d8fbcdd 100644
--- a/client/tests/phpunit/includes/api/PageTermsTest.php
+++ b/client/tests/phpunit/includes/api/PageTermsTest.php
@@ -121,12 +121,14 @@
$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 ) {
- return $this->getTermsOfEntities(
$termObjectsByEntityId, $entityIds, $termTypes, $languagesCodes );
+ function( array $entityIds, array $termTypes =
null, array $languagesCodes = null ) use ( $termObjectsByEntityId, $self ) {
+ return $self->getTermsOfEntities(
$termObjectsByEntityId, $entityIds, $termTypes, $languagesCodes );
}
) );
--
To view, visit https://gerrit.wikimedia.org/r/268950
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice118f395e7832fd4ea79f4fcca97870b59c83b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits