Use action=tokens for api test tokens
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiBlockTest.php
index 8842766..3c18968 100644 (file)
@@ -6,7 +6,6 @@
  * @group medium
  */
 class ApiBlockTest extends ApiTestCase {
-
        protected function setUp() {
                parent::setUp();
                $this->doLogin();
@@ -36,8 +35,7 @@ class ApiBlockTest extends ApiTestCase {
         * previously always considered valid (bug 34212).
         */
        function testMakeNormalBlock() {
-
-               $data = $this->getTokens();
+               $tokens = $this->getTokens();
 
                $user = User::newFromName( 'UTApiBlockee' );
 
@@ -45,19 +43,15 @@ 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' );
 
@@ -66,7 +60,6 @@ class ApiBlockTest extends ApiTestCase {
                $this->assertEquals( 'UTApiBlockee', (string)$block->getTarget() );
                $this->assertEquals( 'Some reason', $block->mReason );
                $this->assertEquals( 'infinity', $block->mExpiry );
-
        }
 
        /**