From 8f17e0dc2ac1b404f8d8f6a96262bd3f0e5aa44d Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 5 Aug 2013 20:15:49 +0200 Subject: [PATCH] Allow different users to login in Api tests Change-Id: I6f79416e4580ed8bf57836b78aa7027ea8f0d280 --- tests/phpunit/includes/api/ApiTestCase.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 1559bef103..bf970da6fa 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -139,11 +139,15 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { } } - protected function doLogin() { + protected function doLogin( $user = 'sysop' ) { + if( !array_key_exists( $user, self::$users ) ){ + throw new MWException( "Can not log in to undefined user $user" ); + } + $data = $this->doApiRequest( array( 'action' => 'login', - 'lgname' => self::$users['sysop']->username, - 'lgpassword' => self::$users['sysop']->password ) ); + 'lgname' => self::$users[ $user ]->username, + 'lgpassword' => self::$users[ $user ]->password ) ); $token = $data[0]['login']['token']; @@ -151,8 +155,8 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { array( 'action' => 'login', 'lgtoken' => $token, - 'lgname' => self::$users['sysop']->username, - 'lgpassword' => self::$users['sysop']->password, + 'lgname' => self::$users[ $user ]->username, + 'lgpassword' => self::$users[ $user ]->password, ), $data[2] ); -- 2.20.1