class ApiCreateAccountTest extends ApiTestCase {
protected function setUp() {
parent::setUp();
- $this->setMwGlobals( array( 'wgEnableEmail' => true ) );
+ $this->setMwGlobals( [ 'wgEnableEmail' => true ] );
}
/**
$password = PasswordFactory::generateRandomPasswordString();
- $ret = $this->doApiRequest( array(
+ $ret = $this->doApiRequest( [
'action' => 'createaccount',
'name' => 'Apitestnew',
'password' => $password,
'email' => 'test@domain.test',
'realname' => 'Test Name'
- ) );
+ ] );
$result = $ret[0];
$this->assertNotInternalType( 'bool', $result );
// Finally create the account
$ret = $this->doApiRequest(
- array(
+ [
'action' => 'createaccount',
'name' => 'Apitestnew',
'password' => $password,
'token' => $token,
'email' => 'test@domain.test',
'realname' => 'Test Name'
- ),
+ ],
$ret[2]
);
$this->assertEquals( 'Success', $result['createaccount']['result'] );
// Try logging in with the new user.
- $ret = $this->doApiRequest( array(
+ $ret = $this->doApiRequest( [
'action' => 'login',
'lgname' => 'Apitestnew',
'lgpassword' => $password,
- ) );
+ ] );
$result = $ret[0];
$this->assertNotInternalType( 'bool', $result );
$token = $result['login']['token'];
$ret = $this->doApiRequest(
- array(
+ [
'action' => 'login',
'lgtoken' => $token,
'lgname' => 'Apitestnew',
'lgpassword' => $password,
- ),
+ ],
$ret[2]
);
// log out to destroy the session
$ret = $this->doApiRequest(
- array(
+ [
'action' => 'logout',
- ),
+ ],
$ret[2]
);
- $this->assertEquals( array(), $ret[0] );
+ $this->assertEquals( [], $ret[0] );
}
/**
* @expectedException UsageException
*/
public function testNoName() {
- $this->doApiRequest( array(
+ $this->doApiRequest( [
'action' => 'createaccount',
'token' => LoginForm::getCreateaccountToken()->toString(),
'password' => 'password',
- ) );
+ ] );
}
/**
* @expectedException UsageException
*/
public function testNoPassword() {
- $this->doApiRequest( array(
+ $this->doApiRequest( [
'action' => 'createaccount',
'name' => 'testName',
'token' => LoginForm::getCreateaccountToken()->toString(),
- ) );
+ ] );
}
/**
* @expectedException UsageException
*/
public function testExistingUser() {
- $this->doApiRequest( array(
+ $this->doApiRequest( [
'action' => 'createaccount',
'name' => 'Apitestsysop',
'token' => LoginForm::getCreateaccountToken()->toString(),
'password' => 'password',
'email' => 'test@domain.test',
- ) );
+ ] );
}
/**
* @expectedException UsageException
*/
public function testInvalidEmail() {
- $this->doApiRequest( array(
+ $this->doApiRequest( [
'action' => 'createaccount',
'name' => 'Test User',
'token' => LoginForm::getCreateaccountToken()->toString(),
'password' => 'password',
'email' => 'invalid',
- ) );
+ ] );
}
}