From ea5e92ba474b46882d98f23ae8492f7ac8450b00 Mon Sep 17 00:00:00 2001 From: addshore Date: Fri, 6 May 2016 16:11:08 +0100 Subject: [PATCH] Make deprecated TestUser properties private Change-Id: I18d6299bad773d16c04b6ea79331c81af8f538bc Depends-On: I5317616f99f1344557fd818d0b00073a82197d05 Depends-On: I15be3de63b2ce13e0ea07b235efd7756c97cebfc Depends-On: I80a50e50493ad04f20cab3a1e094a5c3ecb1c19f --- tests/phpunit/includes/TestUser.php | 12 +++--------- tests/phpunit/includes/api/ApiTestCase.php | 6 +++--- tests/phpunit/includes/api/ApiTokensTest.php | 4 ++-- tests/phpunit/includes/upload/UploadStashTest.php | 4 ++-- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/includes/TestUser.php b/tests/phpunit/includes/TestUser.php index 8b8cbcd4d9..86f4ae789d 100644 --- a/tests/phpunit/includes/TestUser.php +++ b/tests/phpunit/includes/TestUser.php @@ -6,25 +6,19 @@ */ class TestUser { /** - * @deprecated Since 1.25. Use TestUser::getUser()->getName() - * @private * @var string */ - public $username; + private $username; /** - * @deprecated Since 1.25. Use TestUser::getPassword() - * @private * @var string */ - public $password; + private $password; /** - * @deprecated Since 1.25. Use TestUser::getUser() - * @private * @var User */ - public $user; + private $user; private function assertNotReal() { global $wgDBprefix; diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 31f3daa6c9..ac4d2c92ca 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -24,7 +24,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { $this->setMwGlobals( [ 'wgAuth' => $wgDisableAuthManager ? new AuthPlugin : new MediaWiki\Auth\AuthManagerAuthPlugin, 'wgRequest' => new FauxRequest( [] ), - 'wgUser' => self::$users['sysop']->user, + 'wgUser' => self::$users['sysop']->getUser(), ] ); $this->apiContext = new ApiTestContext(); @@ -183,11 +183,11 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { return $data; } - protected function getTokenList( $user, $session = null ) { + protected function getTokenList( TestUser $user, $session = null ) { $data = $this->doApiRequest( [ 'action' => 'tokens', 'type' => 'edit|delete|protect|move|block|unblock|watch' - ], $session, false, $user->user ); + ], $session, false, $user->getUser() ); if ( !array_key_exists( 'tokens', $data[0] ) ) { throw new MWException( 'Api failed to return a token list' ); diff --git a/tests/phpunit/includes/api/ApiTokensTest.php b/tests/phpunit/includes/api/ApiTokensTest.php index fbe97893d8..1f7c00b0a8 100644 --- a/tests/phpunit/includes/api/ApiTokensTest.php +++ b/tests/phpunit/includes/api/ApiTokensTest.php @@ -15,10 +15,10 @@ class ApiTokensTest extends ApiTestCase { } } - protected function runTokenTest( $user ) { + protected function runTokenTest( TestUser $user ) { $tokens = $this->getTokenList( $user ); - $rights = $user->user->getRights(); + $rights = $user->getUser()->getRights(); $this->assertArrayHasKey( 'edittoken', $tokens ); $this->assertArrayHasKey( 'movetoken', $tokens ); diff --git a/tests/phpunit/includes/upload/UploadStashTest.php b/tests/phpunit/includes/upload/UploadStashTest.php index e0b57a797b..9b25505c68 100644 --- a/tests/phpunit/includes/upload/UploadStashTest.php +++ b/tests/phpunit/includes/upload/UploadStashTest.php @@ -7,7 +7,7 @@ */ class UploadStashTest extends MediaWikiTestCase { /** - * @var array Array of UploadStashTestUser + * @var TestUser[] Array of UploadStashTestUser */ public static $users; @@ -55,7 +55,7 @@ class UploadStashTest extends MediaWikiTestCase { * @todo give this test a real name explaining what is being tested here */ public function testBug29408() { - $this->setMwGlobals( 'wgUser', self::$users['uploader']->user ); + $this->setMwGlobals( 'wgUser', self::$users['uploader']->getUser() ); $repo = RepoGroup::singleton()->getLocalRepo(); $stash = new UploadStash( $repo ); -- 2.20.1