From: addshore Date: Fri, 6 May 2016 15:06:46 +0000 (+0100) Subject: Remove uses of deprecated TestUser properties X-Git-Tag: 1.31.0-rc.0~6529^2~1 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=f48f94dfcc1f0b03154752fd4b31ca37938cb01e;p=lhc%2Fweb%2Fwiklou.git Remove uses of deprecated TestUser properties Change-Id: Ib44c66492e27516dfe205a5e428ebfd6b0fcdfd9 --- diff --git a/tests/phpunit/includes/api/ApiLoginTest.php b/tests/phpunit/includes/api/ApiLoginTest.php index 2f8ffcc353..155a9dd982 100644 --- a/tests/phpunit/includes/api/ApiLoginTest.php +++ b/tests/phpunit/includes/api/ApiLoginTest.php @@ -19,7 +19,7 @@ class ApiLoginTest extends ApiTestCase { 'wsTokenSecrets' => [ 'login' => 'foobar' ], ]; $data = $this->doApiRequest( [ 'action' => 'login', - 'lgname' => '', 'lgpassword' => self::$users['sysop']->password, + 'lgname' => '', 'lgpassword' => self::$users['sysop']->getPassword(), 'lgtoken' => (string)( new MediaWiki\Session\Token( 'foobar', '' ) ) ], $session ); $this->assertEquals( $wgDisableAuthManager ? 'NoName' : 'Failed', $data[0]['login']['result'] ); @@ -29,6 +29,7 @@ class ApiLoginTest extends ApiTestCase { global $wgServer, $wgDisableAuthManager; $user = self::$users['sysop']; + $userName = $user->getUser()->getName(); $user->getUser()->logout(); if ( !isset( $wgServer ) ) { @@ -36,7 +37,7 @@ class ApiLoginTest extends ApiTestCase { } $ret = $this->doApiRequest( [ "action" => "login", - "lgname" => $user->username, + "lgname" => $userName, "lgpassword" => "bad", ] ); @@ -52,7 +53,7 @@ class ApiLoginTest extends ApiTestCase { [ "action" => "login", "lgtoken" => $token, - "lgname" => $user->username, + "lgname" => $userName, "lgpassword" => "badnowayinhell", ], $ret[2] @@ -74,12 +75,14 @@ class ApiLoginTest extends ApiTestCase { } $user = self::$users['sysop']; + $userName = $user->getUser()->getName(); + $password = $user->getPassword(); $user->getUser()->logout(); $ret = $this->doApiRequest( [ "action" => "login", - "lgname" => $user->username, - "lgpassword" => $user->password, + "lgname" => $userName, + "lgpassword" => $password, ] ); @@ -95,8 +98,8 @@ class ApiLoginTest extends ApiTestCase { [ "action" => "login", "lgtoken" => $token, - "lgname" => $user->username, - "lgpassword" => $user->password, + "lgname" => $userName, + "lgpassword" => $password, ], $ret[2] ); @@ -122,12 +125,14 @@ class ApiLoginTest extends ApiTestCase { $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); } $user = self::$users['sysop']; + $userName = $user->getUser()->getName(); + $password = $user->getPassword(); $req = MWHttpRequest::factory( self::$apiUrl . "?action=login&format=xml", [ "method" => "POST", "postData" => [ - "lgname" => $user->username, - "lgpassword" => $user->password + "lgname" => $userName, + "lgpassword" => $password ] ], __METHOD__ @@ -146,8 +151,8 @@ class ApiLoginTest extends ApiTestCase { $req->setData( [ "lgtoken" => $token, - "lgname" => $user->username, - "lgpassword" => $user->password ] ); + "lgname" => $userName, + "lgpassword" => $password ] ); $req->execute(); $cj = $req->getCookieJar(); @@ -162,11 +167,14 @@ class ApiLoginTest extends ApiTestCase { } public function testRunLogin() { - $sysopUser = self::$users['sysop']; + $user = self::$users['sysop']; + $userName = $user->getUser()->getName(); + $password = $user->getPassword(); + $data = $this->doApiRequest( [ 'action' => 'login', - 'lgname' => $sysopUser->username, - 'lgpassword' => $sysopUser->password ] ); + 'lgname' => $userName, + 'lgpassword' => $password ] ); $this->assertArrayHasKey( "login", $data[0] ); $this->assertArrayHasKey( "result", $data[0]['login'] ); @@ -176,8 +184,8 @@ class ApiLoginTest extends ApiTestCase { $data = $this->doApiRequest( [ 'action' => 'login', "lgtoken" => $token, - "lgname" => $sysopUser->username, - "lgpassword" => $sysopUser->password ], $data[2] ); + "lgname" => $userName, + "lgpassword" => $password ], $data[2] ); $this->assertArrayHasKey( "login", $data[0] ); $this->assertArrayHasKey( "result", $data[0]['login'] ); @@ -244,7 +252,7 @@ class ApiLoginTest extends ApiTestCase { __METHOD__ ); - $lgName = $user->username . BotPassword::getSeparator() . 'foo'; + $lgName = $user->getUser()->getName() . BotPassword::getSeparator() . 'foo'; $ret = $this->doApiRequest( [ 'action' => 'login', diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index e90b46faa3..31f3daa6c9 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -158,8 +158,8 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { $data = $this->doApiRequest( [ 'action' => 'login', - 'lgname' => $testUser->username, - 'lgpassword' => $testUser->password ] ); + 'lgname' => $testUser->getUser()->getName(), + 'lgpassword' => $testUser->getPassword() ] ); $token = $data[0]['login']['token']; @@ -167,8 +167,8 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { [ 'action' => 'login', 'lgtoken' => $token, - 'lgname' => $testUser->username, - 'lgpassword' => $testUser->password, + 'lgname' => $testUser->getUser()->getName(), + 'lgpassword' => $testUser->getPassword(), ], $data[2] ); diff --git a/tests/phpunit/includes/api/ApiUploadTest.php b/tests/phpunit/includes/api/ApiUploadTest.php index 873917e8ec..de2b56bde3 100644 --- a/tests/phpunit/includes/api/ApiUploadTest.php +++ b/tests/phpunit/includes/api/ApiUploadTest.php @@ -27,11 +27,13 @@ class ApiUploadTest extends ApiTestCaseUpload { */ public function testLogin() { $user = self::$users['uploader']; + $userName = $user->getUser()->getName(); + $password = $user->getPassword(); $params = [ 'action' => 'login', - 'lgname' => $user->username, - 'lgpassword' => $user->password + 'lgname' => $userName, + 'lgpassword' => $password ]; list( $result, , $session ) = $this->doApiRequest( $params ); $this->assertArrayHasKey( "login", $result ); @@ -42,8 +44,8 @@ class ApiUploadTest extends ApiTestCaseUpload { $params = [ 'action' => 'login', 'lgtoken' => $token, - 'lgname' => $user->username, - 'lgpassword' => $user->password + 'lgname' => $userName, + 'lgpassword' => $password ]; list( $result, , $session ) = $this->doApiRequest( $params, $session ); $this->assertArrayHasKey( "login", $result ); diff --git a/tests/phpunit/includes/user/BotPasswordTest.php b/tests/phpunit/includes/user/BotPasswordTest.php index 1ef50824f0..cfd5f7890a 100644 --- a/tests/phpunit/includes/user/BotPasswordTest.php +++ b/tests/phpunit/includes/user/BotPasswordTest.php @@ -290,7 +290,7 @@ class BotPasswordTest extends MediaWikiTestCase { // Wrong password $status = BotPassword::login( - "{$this->testUserName}@BotPassword", $this->testUser->password, new FauxRequest ); + "{$this->testUserName}@BotPassword", $this->testUser->getPassword(), new FauxRequest ); $this->assertEquals( Status::newFatal( 'wrongpassword' ), $status ); // Success!