Merge "tests related to API block action and its gettoken"

This commit is contained in:
Reedy 2012-04-06 15:38:25 +00:00 committed by Gerrit Code Review
commit a521673dc2

View file

@ -68,4 +68,50 @@ class ApiBlockTest extends ApiTestCase {
}
/**
* @dataProvider provideBlockUnblockAction
*/
function testGetTokenUsingABlockingAction( $action ) {
$data = $this->doApiRequest(
array(
'action' => $action,
'user' => 'UTApiBlockee',
'gettoken' => '' ),
null,
false,
self::$users['sysop']->user
);
$this->assertEquals( 34, strlen( $data[0][$action]["{$action}token"] ) );
}
/**
* Attempting to block without a token should give a UsageException with
* error message:
* "The token parameter must be set"
*
* @dataProvider provideBlockUnblockAction
* @expectedException UsageException
*/
function testBlockingActionWithNoToken( $action ) {
$this->doApiRequest(
array(
'action' => $action,
'user' => 'UTApiBlockee',
'reason' => 'Some reason',
),
null,
false,
self::$users['sysop']->user
);
}
/**
* Just provide the 'block' and 'unblock' action to test both API calls
*/
function provideBlockUnblockAction() {
return array(
array( 'block' ),
array( 'unblock' ),
);
}
}