Test ApiUserrights
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiTestCase.php
index d5078bf..00ef2ea 100644 (file)
@@ -99,6 +99,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();
@@ -142,7 +146,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 );
        }