summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/ApiBlockTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/api/ApiBlockTest.php')
-rw-r--r--tests/phpunit/includes/api/ApiBlockTest.php46
1 files changed, 12 insertions, 34 deletions
diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php
index 5dfceee8..8afb748a 100644
--- a/tests/phpunit/includes/api/ApiBlockTest.php
+++ b/tests/phpunit/includes/api/ApiBlockTest.php
@@ -3,10 +3,10 @@
/**
* @group API
* @group Database
+ * @group medium
*/
class ApiBlockTest extends ApiTestCase {
-
- function setUp() {
+ protected function setUp() {
parent::setUp();
$this->doLogin();
}
@@ -34,9 +34,8 @@ class ApiBlockTest extends ApiTestCase {
* Which made the Block/Unblock API to actually verify the token
* previously always considered valid (bug 34212).
*/
- function testMakeNormalBlock() {
-
- $data = $this->getTokens();
+ public function testMakeNormalBlock() {
+ $tokens = $this->getTokens();
$user = User::newFromName( 'UTApiBlockee' );
@@ -44,44 +43,23 @@ class ApiBlockTest extends ApiTestCase {
$this->markTestIncomplete( "The user UTApiBlockee does not exist" );
}
- if( !isset( $data[0]['query']['pages'] ) ) {
+ if ( !array_key_exists( 'blocktoken', $tokens ) ) {
$this->markTestIncomplete( "No block token found" );
}
- $keys = array_keys( $data[0]['query']['pages'] );
- $key = array_pop( $keys );
- $pageinfo = $data[0]['query']['pages'][$key];
-
- $data = $this->doApiRequest( array(
+ $this->doApiRequest( array(
'action' => 'block',
'user' => 'UTApiBlockee',
'reason' => 'Some reason',
- 'token' => $pageinfo['blocktoken'] ), null, false, self::$users['sysop']->user );
+ 'token' => $tokens['blocktoken'] ), null, false, self::$users['sysop']->user );
- $block = Block::newFromTarget('UTApiBlockee');
+ $block = Block::newFromTarget( 'UTApiBlockee' );
$this->assertTrue( !is_null( $block ), 'Block is valid' );
$this->assertEquals( 'UTApiBlockee', (string)$block->getTarget() );
$this->assertEquals( 'Some reason', $block->mReason );
$this->assertEquals( 'infinity', $block->mExpiry );
-
- }
-
- /**
- * @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"] ) );
}
/**
@@ -92,13 +70,13 @@ class ApiBlockTest extends ApiTestCase {
* @dataProvider provideBlockUnblockAction
* @expectedException UsageException
*/
- function testBlockingActionWithNoToken( $action ) {
+ public function testBlockingActionWithNoToken( $action ) {
$this->doApiRequest(
array(
'action' => $action,
'user' => 'UTApiBlockee',
'reason' => 'Some reason',
- ),
+ ),
null,
false,
self::$users['sysop']->user
@@ -108,9 +86,9 @@ class ApiBlockTest extends ApiTestCase {
/**
* Just provide the 'block' and 'unblock' action to test both API calls
*/
- function provideBlockUnblockAction() {
+ public static function provideBlockUnblockAction() {
return array(
- array( 'block' ),
+ array( 'block' ),
array( 'unblock' ),
);
}