From 59ec5a325ccd42cf02343b4c3203fc9dadbc0719 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 10 Sep 2012 17:07:18 -0700 Subject: [PATCH] Move api/ApiTestUser.php to TestUser.php and make available in MediaWikiTestCase class. * Renamed class ApiTestUser to TestUser. Change-Id: I1c3c659c3ba5c54a314d879132f760008983372d --- tests/TestsAutoLoader.php | 2 +- tests/phpunit/MediaWikiTestCase.php | 5 +++++ tests/phpunit/includes/PreferencesTest.php | 21 ++++++++----------- .../{api/ApiTestUser.php => TestUser.php} | 3 +-- tests/phpunit/includes/api/ApiTestCase.php | 8 ++----- .../includes/upload/UploadStashTest.php | 4 ++-- 6 files changed, 20 insertions(+), 23 deletions(-) rename tests/phpunit/includes/{api/ApiTestUser.php => TestUser.php} (98%) diff --git a/tests/TestsAutoLoader.php b/tests/TestsAutoLoader.php index cb5ca36f13..42f5f68af2 100644 --- a/tests/TestsAutoLoader.php +++ b/tests/TestsAutoLoader.php @@ -17,7 +17,7 @@ $wgAutoloadClasses += array( //API 'ApiFormatTestBase' => "$testFolder/phpunit/includes/api/format/ApiFormatTestBase.php", 'ApiTestCase' => "$testFolder/phpunit/includes/api/ApiTestCase.php", - 'ApiTestUser' => "$testFolder/phpunit/includes/api/ApiTestUser.php", + 'TestUser' => "$testFolder/phpunit/includes/TestUser.php", 'MockApi' => "$testFolder/phpunit/includes/api/ApiTestCase.php", 'RandomImageGenerator' => "$testFolder/phpunit/includes/api/RandomImageGenerator.php", 'UserWrapper' => "$testFolder/phpunit/includes/api/ApiTestCase.php", diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index bfad334e65..5fc4feb9d6 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -5,6 +5,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { public $regex = ''; public $runDisabled = false; + /** + * @var Array of TestUser + */ + public static $users; + /** * @var DatabaseBase */ diff --git a/tests/phpunit/includes/PreferencesTest.php b/tests/phpunit/includes/PreferencesTest.php index 664f04adca..0e12317791 100644 --- a/tests/phpunit/includes/PreferencesTest.php +++ b/tests/phpunit/includes/PreferencesTest.php @@ -1,25 +1,24 @@ users['noemail'] = new User; + $this->prefUsers['noemail'] = new User; - $this->users['notauth'] = new User; - $this->users['notauth'] + $this->prefUsers['notauth'] = new User; + $this->prefUsers['notauth'] ->setEmail( 'noauth@example.org' ); - $this->users['auth'] = new User; - $this->users['auth'] + $this->prefUsers['auth'] = new User; + $this->prefUsers['auth'] ->setEmail( 'noauth@example.org' ); - $this->users['auth'] + $this->prefUsers['auth'] ->setEmailAuthenticationTimestamp( 1330946623 ); $this->context = new RequestContext; @@ -63,16 +62,14 @@ class PreferencesTest extends MediaWikiTestCase { $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] ); } - /** Helper */ function prefsFor( $user_key ) { $preferences = array(); Preferences::profilePreferences( - $this->users[$user_key] + $this->prefUsers[$user_key] , $this->context , $preferences ); return $preferences; } - } diff --git a/tests/phpunit/includes/api/ApiTestUser.php b/tests/phpunit/includes/TestUser.php similarity index 98% rename from tests/phpunit/includes/api/ApiTestUser.php rename to tests/phpunit/includes/TestUser.php index 8d5f61a75f..c4d8945557 100644 --- a/tests/phpunit/includes/api/ApiTestUser.php +++ b/tests/phpunit/includes/TestUser.php @@ -1,7 +1,7 @@ user->saveSettings(); } - } diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index d6c48cbd73..b84292e3cd 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -1,10 +1,6 @@ new ApiTestUser( + 'sysop' => new TestUser( 'Apitestsysop', 'Api Test Sysop', 'api_test_sysop@example.com', array( 'sysop' ) ), - 'uploader' => new ApiTestUser( + 'uploader' => new TestUser( 'Apitestuser', 'Api Test User', 'api_test_user@example.com', diff --git a/tests/phpunit/includes/upload/UploadStashTest.php b/tests/phpunit/includes/upload/UploadStashTest.php index dc1c2ac4fc..66fafaaffe 100644 --- a/tests/phpunit/includes/upload/UploadStashTest.php +++ b/tests/phpunit/includes/upload/UploadStashTest.php @@ -16,13 +16,13 @@ class UploadStashTest extends MediaWikiTestCase { file_put_contents( $this->bug29408File, "\x00" ); self::$users = array( - 'sysop' => new ApiTestUser( + 'sysop' => new TestUser( 'Uploadstashtestsysop', 'Upload Stash Test Sysop', 'upload_stash_test_sysop@example.com', array( 'sysop' ) ), - 'uploader' => new ApiTestUser( + 'uploader' => new TestUser( 'Uploadstashtestuser', 'Upload Stash Test User', 'upload_stash_test_user@example.com', -- 2.20.1