Merge "Add wfWaitForSlaves() to maintenance/migrateComments.php"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiWatchTest.php
index dc86b22..7b91094 100644 (file)
@@ -16,17 +16,15 @@ class ApiWatchTest extends ApiTestCase {
                return $this->getTokenList( self::$users['sysop'] );
        }
 
-       /**
-        */
        public function testWatchEdit() {
                $tokens = $this->getTokens();
 
-               $data = $this->doApiRequest( array(
+               $data = $this->doApiRequest( [
                        'action' => 'edit',
                        'title' => 'Help:UTPage', // Help namespace is hopefully wikitext
                        'text' => 'new text',
                        'token' => $tokens['edittoken'],
-                       'watchlist' => 'watch' ) );
+                       'watchlist' => 'watch' ] );
                $this->assertArrayHasKey( 'edit', $data[0] );
                $this->assertArrayHasKey( 'result', $data[0]['edit'] );
                $this->assertEquals( 'Success', $data[0]['edit']['result'] );
@@ -40,25 +38,25 @@ class ApiWatchTest extends ApiTestCase {
        public function testWatchClear() {
                $tokens = $this->getTokens();
 
-               $data = $this->doApiRequest( array(
+               $data = $this->doApiRequest( [
                        'action' => 'query',
                        'wllimit' => 'max',
-                       'list' => 'watchlist' ) );
+                       'list' => 'watchlist' ] );
 
                if ( isset( $data[0]['query']['watchlist'] ) ) {
                        $wl = $data[0]['query']['watchlist'];
 
                        foreach ( $wl as $page ) {
-                               $data = $this->doApiRequest( array(
+                               $data = $this->doApiRequest( [
                                        'action' => 'watch',
                                        'title' => $page['title'],
                                        'unwatch' => true,
-                                       'token' => $tokens['watchtoken'] ) );
+                                       'token' => $tokens['watchtoken'] ] );
                        }
                }
-               $data = $this->doApiRequest( array(
+               $data = $this->doApiRequest( [
                        'action' => 'query',
-                       'list' => 'watchlist' ), $data );
+                       'list' => 'watchlist' ], $data );
                $this->assertArrayHasKey( 'query', $data[0] );
                $this->assertArrayHasKey( 'watchlist', $data[0]['query'] );
                foreach ( $data[0]['query']['watchlist'] as $index => $item ) {
@@ -74,17 +72,15 @@ class ApiWatchTest extends ApiTestCase {
                return $data;
        }
 
-       /**
-        */
        public function testWatchProtect() {
                $tokens = $this->getTokens();
 
-               $data = $this->doApiRequest( array(
+               $data = $this->doApiRequest( [
                        'action' => 'protect',
                        'token' => $tokens['protecttoken'],
                        'title' => 'Help:UTPage',
                        'protections' => 'edit=sysop',
-                       'watchlist' => 'unwatch' ) );
+                       'watchlist' => 'unwatch' ] );
 
                $this->assertArrayHasKey( 'protect', $data[0] );
                $this->assertArrayHasKey( 'protections', $data[0]['protect'] );
@@ -92,8 +88,6 @@ class ApiWatchTest extends ApiTestCase {
                $this->assertArrayHasKey( 'edit', $data[0]['protect']['protections'][0] );
        }
 
-       /**
-        */
        public function testGetRollbackToken() {
                $this->getTokens();
 
@@ -101,11 +95,11 @@ class ApiWatchTest extends ApiTestCase {
                        $this->markTestSkipped( "The article [[Help:UTPage]] does not exist" ); // TODO: just create it?
                }
 
-               $data = $this->doApiRequest( array(
+               $data = $this->doApiRequest( [
                        'action' => 'query',
                        'prop' => 'revisions',
                        'titles' => 'Help:UTPage',
-                       'rvtoken' => 'rollback' ) );
+                       'rvtoken' => 'rollback' ] );
 
                $this->assertArrayHasKey( 'query', $data[0] );
                $this->assertArrayHasKey( 'pages', $data[0]['query'] );
@@ -137,20 +131,20 @@ class ApiWatchTest extends ApiTestCase {
                $revinfo = $pageinfo['revisions'][0];
 
                try {
-                       $data = $this->doApiRequest( array(
+                       $data = $this->doApiRequest( [
                                'action' => 'rollback',
                                'title' => 'Help:UTPage',
                                'user' => $revinfo['user'],
                                'token' => $pageinfo['rollbacktoken'],
-                               'watchlist' => 'watch' ) );
+                               'watchlist' => 'watch' ] );
 
                        $this->assertArrayHasKey( 'rollback', $data[0] );
                        $this->assertArrayHasKey( 'title', $data[0]['rollback'] );
-               } catch ( UsageException $ue ) {
-                       if ( $ue->getCodeString() == 'onlyauthor' ) {
+               } catch ( ApiUsageException $ue ) {
+                       if ( self::apiExceptionHasCode( $ue, 'onlyauthor' ) ) {
                                $this->markTestIncomplete( "Only one author to 'Help:UTPage', cannot test rollback" );
                        } else {
-                               $this->fail( "Received error '" . $ue->getCodeString() . "'" );
+                               $this->fail( "Received error '" . $ue->getMessage() . "'" );
                        }
                }
        }