/**
* @var array
*/
- protected $tablesUsed = array( 'user', 'user_groups', 'user_properties' );
+ protected $tablesUsed = [ 'user', 'user_groups', 'user_properties' ];
protected function setUp() {
global $wgServer;
ApiQueryInfo::resetTokenCache(); // tokens are invalid because we cleared the session
- self::$users = array(
+ self::$users = [
'sysop' => new TestUser(
'Apitestsysop',
'Api Test Sysop',
'api_test_sysop@example.com',
- array( 'sysop' )
+ [ 'sysop' ]
),
'uploader' => new TestUser(
'Apitestuser',
'Api Test User',
'api_test_user@example.com',
- array()
+ []
)
- );
+ ];
- $this->setMwGlobals( array(
- 'wgAuth' => new StubObject( 'wgAuth', 'AuthPlugin' ),
- 'wgRequest' => new FauxRequest( array() ),
+ $this->setMwGlobals( [
+ 'wgAuth' => new AuthPlugin,
+ 'wgRequest' => new FauxRequest( [] ),
'wgUser' => self::$users['sysop']->user,
- ) );
+ ] );
$this->apiContext = new ApiTestContext();
}
$module->execute();
// construct result
- $results = array(
- $module->getResult()->getResultData( null, array( 'Strip' => 'all' ) ),
+ $results = [
+ $module->getResult()->getResultData( null, [ 'Strip' => 'all' ] ),
$context->getRequest(),
$context->getRequest()->getSessionArray()
- );
+ ];
if ( $appendModule ) {
$results[] = $module;
if ( isset( $session['wsToken'] ) && $session['wsToken'] ) {
// @todo Why does this directly mess with the session? Fix that.
// add edit token to fake session
- $session['wsEditToken'] = $session['wsToken'];
+ $session['wsTokenSecrets']['default'] = $session['wsToken'];
// add token to request parameters
$timestamp = wfTimestamp();
$params['token'] = hash_hmac( 'md5', $timestamp, $session['wsToken'] ) .
dechex( $timestamp ) .
- User::EDIT_TOKEN_SUFFIX;
+ MediaWiki\Session\Token::SUFFIX;
return $this->doApiRequest( $params, $session, false, $user );
} else {
throw new MWException( "Can not log in to undefined user $user" );
}
- $data = $this->doApiRequest( array(
+ $data = $this->doApiRequest( [
'action' => 'login',
'lgname' => self::$users[$user]->username,
- 'lgpassword' => self::$users[$user]->password ) );
+ 'lgpassword' => self::$users[$user]->password ] );
$token = $data[0]['login']['token'];
$data = $this->doApiRequest(
- array(
+ [
'action' => 'login',
'lgtoken' => $token,
'lgname' => self::$users[$user]->username,
'lgpassword' => self::$users[$user]->password,
- ),
+ ],
$data[2]
);
}
protected function getTokenList( $user, $session = null ) {
- $data = $this->doApiRequest( array(
+ $data = $this->doApiRequest( [
'action' => 'tokens',
'type' => 'edit|delete|protect|move|block|unblock|watch'
- ), $session, false, $user->user );
+ ], $session, false, $user->user );
if ( !array_key_exists( 'tokens', $data[0] ) ) {
throw new MWException( 'Api failed to return a token list' );