X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiTestCase.php;h=3cec99af90f61b62c857135f0061c65fd857c4b6;hb=8016a0d162e599969704b20560709116d39b6526;hp=3b044ef94ba341d484ea40eb93fa40cd663da76b;hpb=1690388847edcdcb070427365751745f9706dd82;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 3b044ef94b..3cec99af90 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', @@ -85,10 +83,16 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { * This is cheating a bit -- we grab a token in the correct format and then add it to the pseudo-session and to the * request, without actually requesting a "real" edit token * @param $params Array: key-value API params - * @param $session Array: session array + * @param $session Array|null: session array * @param $user User|null A User object for the context */ - protected function doApiRequestWithToken( Array $params, Array $session, User $user = null ) { + protected function doApiRequestWithToken( Array $params, Array $session = null, User $user = null ) { + global $wgRequest; + + if ( $session === null ) { + $session = $wgRequest->getSessionArray(); + } + if ( $session['wsToken'] ) { // add edit token to fake session $session['wsEditToken'] = $session['wsToken'];