Merge "Watch user page and user talk page by default"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiWatchTest.php
index 78bb151..e49c6c0 100644 (file)
@@ -18,7 +18,7 @@ class ApiWatchTest extends ApiTestCase {
 
        /**
         */
-       function testWatchEdit() {
+       public function testWatchEdit() {
                $tokens = $this->getTokens();
 
                $data = $this->doApiRequest( array(
@@ -37,11 +37,12 @@ class ApiWatchTest extends ApiTestCase {
        /**
         * @depends testWatchEdit
         */
-       function testWatchClear() {
+       public function testWatchClear() {
                $tokens = $this->getTokens();
 
                $data = $this->doApiRequest( array(
                        'action' => 'query',
+                       'wllimit' => 'max',
                        'list' => 'watchlist' ) );
 
                if ( isset( $data[0]['query']['watchlist'] ) ) {
@@ -60,6 +61,14 @@ class ApiWatchTest extends ApiTestCase {
                        'list' => 'watchlist' ), $data );
                $this->assertArrayHasKey( 'query', $data[0] );
                $this->assertArrayHasKey( 'watchlist', $data[0]['query'] );
+               foreach ( $data[0]['query']['watchlist'] as $index => $item ) {
+                       // Previous tests may insert an invalid title
+                       // like ":ApiEditPageTest testNonTextEdit", which
+                       // can't be cleared.
+                       if ( strpos( $item['title'], ':' ) === 0 ) {
+                               unset( $data[0]['query']['watchlist'][$index] );
+                       }
+               }
                $this->assertEquals( 0, count( $data[0]['query']['watchlist'] ) );
 
                return $data;
@@ -67,7 +76,7 @@ class ApiWatchTest extends ApiTestCase {
 
        /**
         */
-       function testWatchProtect() {
+       public function testWatchProtect() {
                $tokens = $this->getTokens();
 
                $data = $this->doApiRequest( array(
@@ -85,7 +94,7 @@ class ApiWatchTest extends ApiTestCase {
 
        /**
         */
-       function testGetRollbackToken() {
+       public function testGetRollbackToken() {
                $this->getTokens();
 
                if ( !Title::newFromText( 'Help:UTPage' )->exists() ) {
@@ -121,7 +130,7 @@ class ApiWatchTest extends ApiTestCase {
         *
         * @depends testGetRollbackToken
         */
-       function testWatchRollback( $data ) {
+       public function testWatchRollback( $data ) {
                $keys = array_keys( $data[0]['query']['pages'] );
                $key = array_pop( $keys );
                $pageinfo = $data[0]['query']['pages'][$key];
@@ -145,23 +154,4 @@ class ApiWatchTest extends ApiTestCase {
                        }
                }
        }
-
-       /**
-        */
-       function testWatchDelete() {
-               $tokens = $this->getTokens();
-
-               $data = $this->doApiRequest( array(
-                       'action' => 'delete',
-                       'token' => $tokens['deletetoken'],
-                       'title' => 'Help:UTPage' ) );
-               $this->assertArrayHasKey( 'delete', $data[0] );
-               $this->assertArrayHasKey( 'title', $data[0]['delete'] );
-
-               $this->doApiRequest( array(
-                       'action' => 'query',
-                       'list' => 'watchlist' ) );
-
-               $this->markTestIncomplete( 'This test needs to verify the deleted article was added to the users watchlist' );
-       }
 }