Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/59010
Change subject: Remove unused local variables in tests
......................................................................
Remove unused local variables in tests
Change-Id: I71318eb7d8c00bfc1ce6d2fc636b498f7a695f42
---
M tests/phpunit/includes/ArticleTablesTest.php
M tests/phpunit/includes/HooksTest.php
M tests/phpunit/includes/TemplateCategoriesTest.php
M tests/phpunit/includes/TimestampTest.php
M tests/phpunit/includes/api/ApiAccountCreationTest.php
M tests/phpunit/includes/api/ApiBlockTest.php
M tests/phpunit/includes/api/ApiEditPageTest.php
M tests/phpunit/includes/api/ApiParseTest.php
M tests/phpunit/includes/api/ApiUploadTest.php
M tests/phpunit/includes/api/ApiWatchTest.php
M tests/phpunit/includes/cache/ProcessCacheLRUTest.php
M tests/phpunit/includes/filerepo/FileRepoTest.php
M tests/phpunit/includes/upload/UploadFromUrlTest.php
M tests/phpunit/resources/ResourcesTest.php
M tests/selenium/suites/AddContentToNewPageTestCase.php
15 files changed, 31 insertions(+), 43 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/10/59010/1
diff --git a/tests/phpunit/includes/ArticleTablesTest.php
b/tests/phpunit/includes/ArticleTablesTest.php
index 967ffa1..d96a453 100644
--- a/tests/phpunit/includes/ArticleTablesTest.php
+++ b/tests/phpunit/includes/ArticleTablesTest.php
@@ -16,14 +16,14 @@
$wgContLang = Language::factory( 'es' );
$wgLang = Language::factory( 'fr' );
- $status = $page->doEditContent( new WikitextContent(
'{{:{{int:history}}}}' ), 'Test code for bug 14404', 0, false, $user );
+ $page->doEditContent( new WikitextContent(
'{{:{{int:history}}}}' ), 'Test code for bug 14404', 0, false, $user );
$templates1 = $title->getTemplateLinksFrom();
$wgLang = Language::factory( 'de' );
$page->mPreparedEdit = false; // In order to force the
rerendering of the same wikitext
// We need an edit, a purge is not enough to regenerate the
tables
- $status = $page->doEditContent( new WikitextContent(
'{{:{{int:history}}}}' ), 'Test code for bug 14404', EDIT_UPDATE, false, $user
);
+ $page->doEditContent( new WikitextContent(
'{{:{{int:history}}}}' ), 'Test code for bug 14404', EDIT_UPDATE, false, $user
);
$templates2 = $title->getTemplateLinksFrom();
$this->assertEquals( $templates1, $templates2 );
diff --git a/tests/phpunit/includes/HooksTest.php
b/tests/phpunit/includes/HooksTest.php
index 89e789b..7589d31 100644
--- a/tests/phpunit/includes/HooksTest.php
+++ b/tests/phpunit/includes/HooksTest.php
@@ -74,7 +74,6 @@
Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
$this->assertEquals( 'bah', $foo, 'Standard static method' );
- $foo = 'Foo';
Hooks::clear( 'MediaWikiHooksTest001' );
}
diff --git a/tests/phpunit/includes/TemplateCategoriesTest.php
b/tests/phpunit/includes/TemplateCategoriesTest.php
index a793bab..fc15d02 100644
--- a/tests/phpunit/includes/TemplateCategoriesTest.php
+++ b/tests/phpunit/includes/TemplateCategoriesTest.php
@@ -13,14 +13,14 @@
$user = new User();
$user->mRights = array( 'createpage', 'edit', 'purge' );
- $status = $page->doEditContent( new WikitextContent(
'{{Categorising template}}' ), 'Create a page with a template', 0, false, $user
);
+ $page->doEditContent( new WikitextContent( '{{Categorising
template}}' ), 'Create a page with a template', 0, false, $user );
$this->assertEquals(
array()
, $title->getParentCategories()
);
$template = WikiPage::factory( Title::newFromText(
'Template:Categorising template' ) );
- $status = $template->doEditContent( new WikitextContent(
'[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false,
$user );
+ $template->doEditContent( new WikitextContent(
'[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false,
$user );
// Run the job queue
JobQueueGroup::destroySingletons();
diff --git a/tests/phpunit/includes/TimestampTest.php
b/tests/phpunit/includes/TimestampTest.php
index 0690683..aab8aae 100644
--- a/tests/phpunit/includes/TimestampTest.php
+++ b/tests/phpunit/includes/TimestampTest.php
@@ -38,7 +38,7 @@
* @expectedException TimestampException
*/
function testInvalidParse() {
- $timestamp = new MWTimestamp( "This is not a timestamp." );
+ return new MWTimestamp( "This is not a timestamp." );
}
/**
diff --git a/tests/phpunit/includes/api/ApiAccountCreationTest.php
b/tests/phpunit/includes/api/ApiAccountCreationTest.php
index 696b145..02c03a0 100644
--- a/tests/phpunit/includes/api/ApiAccountCreationTest.php
+++ b/tests/phpunit/includes/api/ApiAccountCreationTest.php
@@ -107,7 +107,7 @@
* @expectedException UsageException
*/
function testNoName() {
- $ret = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'createaccount',
'token' => LoginForm::getCreateaccountToken(),
'password' => 'password',
@@ -119,7 +119,7 @@
* @expectedException UsageException
*/
function testNoPassword() {
- $ret = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'createaccount',
'name' => 'testName',
'token' => LoginForm::getCreateaccountToken(),
diff --git a/tests/phpunit/includes/api/ApiBlockTest.php
b/tests/phpunit/includes/api/ApiBlockTest.php
index 8842766..a3d39dd 100644
--- a/tests/phpunit/includes/api/ApiBlockTest.php
+++ b/tests/phpunit/includes/api/ApiBlockTest.php
@@ -6,7 +6,6 @@
* @group medium
*/
class ApiBlockTest extends ApiTestCase {
-
protected function setUp() {
parent::setUp();
$this->doLogin();
@@ -36,7 +35,6 @@
* previously always considered valid (bug 34212).
*/
function testMakeNormalBlock() {
-
$data = $this->getTokens();
$user = User::newFromName( 'UTApiBlockee' );
@@ -53,7 +51,7 @@
$key = array_pop( $keys );
$pageinfo = $data[0]['query']['pages'][$key];
- $data = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'block',
'user' => 'UTApiBlockee',
'reason' => 'Some reason',
@@ -66,7 +64,6 @@
$this->assertEquals( 'UTApiBlockee',
(string)$block->getTarget() );
$this->assertEquals( 'Some reason', $block->mReason );
$this->assertEquals( 'infinity', $block->mExpiry );
-
}
/**
diff --git a/tests/phpunit/includes/api/ApiEditPageTest.php
b/tests/phpunit/includes/api/ApiEditPageTest.php
index 7d8e01f..f3b9a67 100644
--- a/tests/phpunit/includes/api/ApiEditPageTest.php
+++ b/tests/phpunit/includes/api/ApiEditPageTest.php
@@ -161,13 +161,13 @@
if ( $text !== null ) {
if ( $text === '' ) {
// can't create an empty page, so create it
with some content
- list( $re, , ) = $this->doApiRequestWithToken(
array(
+ $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
'text' => '(dummy)', ) );
}
- list( $re, , ) = $this->doApiRequestWithToken( array(
+ list( $re ) = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
'text' => $text, ) );
@@ -176,7 +176,7 @@
}
// -- try append/prepend
--------------------------------------------
- list( $re, , ) = $this->doApiRequestWithToken( array(
+ list( $re ) = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
$op . 'text' => $append, ) );
@@ -224,7 +224,7 @@
// try to save edit, expect conflict
try {
- list( $re, , ) = $this->doApiRequestWithToken( array(
+ $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
'text' => 'nix bar!',
@@ -280,7 +280,7 @@
// try again, without following the redirect. Should fail.
try {
- list( $re, , ) = $this->doApiRequestWithToken( array(
+ $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $rname,
'text' => 'nix bar!',
diff --git a/tests/phpunit/includes/api/ApiParseTest.php
b/tests/phpunit/includes/api/ApiParseTest.php
index a42e5aa..475a2ad 100644
--- a/tests/phpunit/includes/api/ApiParseTest.php
+++ b/tests/phpunit/includes/api/ApiParseTest.php
@@ -16,7 +16,7 @@
$somePage = mt_rand();
try {
- $data = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'parse',
'page' => $somePage ) );
diff --git a/tests/phpunit/includes/api/ApiUploadTest.php
b/tests/phpunit/includes/api/ApiUploadTest.php
index 0d98b04..46be346 100644
--- a/tests/phpunit/includes/api/ApiUploadTest.php
+++ b/tests/phpunit/includes/api/ApiUploadTest.php
@@ -27,7 +27,6 @@
* This is pretty sucky... needs to be prettified.
*/
class ApiUploadTest extends ApiTestCaseUpload {
-
/**
* Testing login
* XXX this is a funny way of getting session context
@@ -298,7 +297,7 @@
$exception = false;
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result, , $session ) =
$this->doApiRequestWithToken( $params, $session,
self::$users['uploader']->user );
} catch ( UsageException $e ) {
$exception = true;
@@ -324,7 +323,7 @@
$exception = false;
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result ) = $this->doApiRequestWithToken(
$params, $session,
self::$users['uploader']->user ); // FIXME:
leaks a temporary file
} catch ( UsageException $e ) {
$exception = true;
@@ -340,7 +339,6 @@
$this->deleteFileByFilename( $fileNames[1] );
unlink( $filePaths[0] );
}
-
/**
* @depends testLogin
@@ -382,7 +380,7 @@
$exception = false;
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result, , $session ) =
$this->doApiRequestWithToken( $params, $session,
self::$users['uploader']->user ); // FIXME:
leaks a temporary file
} catch ( UsageException $e ) {
$exception = true;
@@ -411,7 +409,7 @@
$this->clearFakeUploads();
$exception = false;
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result ) = $this->doApiRequestWithToken(
$params, $session,
self::$users['uploader']->user );
} catch ( UsageException $e ) {
$exception = true;
@@ -482,7 +480,7 @@
if ( !$chunkSessionKey ) {
// Upload fist chunk ( and get the session key )
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result, $session ) =
$this->doApiRequestWithToken( $params, $session,
self::$users['uploader']->user
);
} catch ( UsageException $e ) {
$this->markTestIncomplete(
$e->getMessage() );
@@ -509,7 +507,7 @@
$this->assertEquals( $resultOffset, $params['offset'] );
// Upload current chunk
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result, , $session ) =
$this->doApiRequestWithToken( $params, $session,
self::$users['uploader']->user );
} catch ( UsageException $e ) {
$this->markTestIncomplete( $e->getMessage() );
@@ -548,7 +546,7 @@
$this->clearFakeUploads();
$exception = false;
try {
- list( $result, $request, $session ) =
$this->doApiRequestWithToken( $params, $session,
+ list( $result ) = $this->doApiRequestWithToken(
$params, $session,
self::$users['uploader']->user );
} catch ( UsageException $e ) {
$exception = true;
diff --git a/tests/phpunit/includes/api/ApiWatchTest.php
b/tests/phpunit/includes/api/ApiWatchTest.php
index aefd939..754dc9d 100644
--- a/tests/phpunit/includes/api/ApiWatchTest.php
+++ b/tests/phpunit/includes/api/ApiWatchTest.php
@@ -7,7 +7,6 @@
* @todo This test suite is severly broken and need a full review
*/
class ApiWatchTest extends ApiTestCase {
-
protected function setUp() {
parent::setUp();
$this->doLogin();
@@ -95,8 +94,7 @@
/**
*/
function testGetRollbackToken() {
-
- $pageinfo = $this->getTokens();
+ $this->gebtTokens();
if ( !Title::newFromText( 'Help:UTPage' )->exists() ) {
$this->markTestSkipped( "The article [[Help:UTPage]]
does not exist" ); //TODO: just create it?
@@ -168,7 +166,7 @@
$this->assertArrayHasKey( 'delete', $data[0] );
$this->assertArrayHasKey( 'title', $data[0]['delete'] );
- $data = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'query',
'list' => 'watchlist' ) );
diff --git a/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
b/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
index c7e75d9..c605378 100644
--- a/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
+++ b/tests/phpunit/includes/cache/ProcessCacheLRUTest.php
@@ -70,7 +70,7 @@
* @expectedException MWException
*/
function testConstructorGivenInvalidValue( $maxSize ) {
- $c = new ProcessCacheLRUTestable( $maxSize );
+ return new ProcessCacheLRUTestable( $maxSize );
}
/**
diff --git a/tests/phpunit/includes/filerepo/FileRepoTest.php
b/tests/phpunit/includes/filerepo/FileRepoTest.php
index 7cc25b1..caf2d0e 100644
--- a/tests/phpunit/includes/filerepo/FileRepoTest.php
+++ b/tests/phpunit/includes/filerepo/FileRepoTest.php
@@ -6,21 +6,21 @@
* @expectedException MWException
*/
function testFileRepoConstructionOptionCanNotBeNull() {
- $f = new FileRepo();
+ return new FileRepo();
}
/**
* @expectedException MWException
*/
function testFileRepoConstructionOptionCanNotBeAnEmptyArray() {
- $f = new FileRepo( array() );
+ return new FileRepo( array() );
}
/**
* @expectedException MWException
*/
function testFileRepoConstructionOptionNeedNameKey() {
- $f = new FileRepo( array(
+ return new FileRepo( array(
'backend' => 'foobar'
) );
}
@@ -29,7 +29,7 @@
* @expectedException MWException
*/
function testFileRepoConstructionOptionNeedBackendKey() {
- $f = new FileRepo( array(
+ return new FileRepo( array(
'name' => 'foobar'
) );
}
diff --git a/tests/phpunit/includes/upload/UploadFromUrlTest.php
b/tests/phpunit/includes/upload/UploadFromUrlTest.php
index ac93aa7..ab2b5ee 100644
--- a/tests/phpunit/includes/upload/UploadFromUrlTest.php
+++ b/tests/phpunit/includes/upload/UploadFromUrlTest.php
@@ -6,7 +6,6 @@
* @group Database
*/
class UploadFromUrlTest extends ApiTestCase {
-
protected function setUp() {
parent::setUp();
@@ -236,7 +235,7 @@
$this->assertFalse( (bool)$talk->getArticleID(
Title::GAID_FOR_UPDATE ), 'User talk does not exist' );
- $data = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'upload',
'filename' => 'UploadFromUrlTest.png',
'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
@@ -260,7 +259,7 @@
$exception = false;
try {
- $data = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'upload',
'filename' => 'UploadFromUrlTest.png',
'url' =>
'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png',
@@ -330,7 +329,6 @@
return $data;
}
-
/**
*
diff --git a/tests/phpunit/resources/ResourcesTest.php
b/tests/phpunit/resources/ResourcesTest.php
index 71b8c67..62a6b14 100644
--- a/tests/phpunit/resources/ResourcesTest.php
+++ b/tests/phpunit/resources/ResourcesTest.php
@@ -91,7 +91,7 @@
$property = $reflectedModule->getProperty(
$propName );
$property->setAccessible( true );
$lists = $property->getValue( $module );
- foreach ( $lists as $group => $list ) {
+ foreach ( $lists as $list ) {
foreach ( $list as $key => $value ) {
// We need the same filter as
for 'lists',
// due to 'skinStyles'.
diff --git a/tests/selenium/suites/AddContentToNewPageTestCase.php
b/tests/selenium/suites/AddContentToNewPageTestCase.php
index 2803ff2..1237bb5 100644
--- a/tests/selenium/suites/AddContentToNewPageTestCase.php
+++ b/tests/selenium/suites/AddContentToNewPageTestCase.php
@@ -105,8 +105,6 @@
// Add level 2 headline and verify output in the preview
public function testAddLevel2HeadLine() {
- $blnElementPresent = false;
- $blnTextPresent = false;
$this->getExistingPage();
$this->clickEditLink();
$this->loadWikiEditor();
--
To view, visit https://gerrit.wikimedia.org/r/59010
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I71318eb7d8c00bfc1ce6d2fc636b498f7a695f42
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits