X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiWatchTest.php;h=e49c6c0e4e0e48eabe0ff168ec44fab93adb0f75;hb=aa5e15357aab7365815c154fd86bdaa6f968b97a;hp=78bb1515f87ff07d9b2f86ab373fb41b7ba34cf6;hpb=edba2e008c079f4d51abc70f2c98c1dc8009a900;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiWatchTest.php b/tests/phpunit/includes/api/ApiWatchTest.php index 78bb1515f8..e49c6c0e4e 100644 --- a/tests/phpunit/includes/api/ApiWatchTest.php +++ b/tests/phpunit/includes/api/ApiWatchTest.php @@ -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' ); - } }