X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiTestCase.php;h=a5ee7ddb8c9f4c84ab83bd4273524e1f2072d727;hp=6506ea4df0b27fb41c41257633f24c95f0c078c3;hb=54d50ef3921dc9f30dc4d863ddc471dc564998e9;hpb=9a3e888d65e886cf7f88957aaebd3d10d7856728 diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 6506ea4df0..a5ee7ddb8c 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 ); }