}
+ /**
+ * @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' ),
+ );
+ }
}