diff options
Diffstat (limited to 'tests/phpunit/includes/api/ApiTestCase.php')
-rw-r--r-- | tests/phpunit/includes/api/ApiTestCase.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 6506ea4df0b2..a5ee7ddb8c9f 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -121,6 +121,10 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { } if ( $tokenType !== null ) { + if ( $tokenType === 'auto' ) { + $tokenType = ( new ApiMain() )->getModuleManager() + ->getModule( $params['action'], 'action' )->needsToken(); + } $params['token'] = ApiQueryTokens::getToken( $wgUser, $sessionObj, ApiQueryTokens::getTokenTypeSalts()[$tokenType] )->toString(); @@ -164,7 +168,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { * @return array Result of the API call */ protected function doApiRequestWithToken( array $params, array $session = null, - User $user = null, $tokenType = 'csrf' + User $user = null, $tokenType = 'auto' ) { return $this->doApiRequest( $params, $session, false, $user, $tokenType ); } |