From: X! Date: Sun, 2 Jan 2011 06:09:58 +0000 (+0000) Subject: Add API purge test (mainly as proof of concept for how API tests should be written) X-Git-Tag: 1.31.0-rc.0~32889 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/%40%20%27info_date_publication_anterieure%27%20=%3E%20%27Previously%20published%20on:%27%2C%20%27info_date_referencement%27%20=%3E%20%27THIS%20SITE%20REFERENCED%20ON:%27%2C%20%27info_derniere_etape%27%20=%3E%20%27Done%21%27%2C-%27info_derniers_articles_publies%27%20=%3E%20%27Your%20most%20recently%20published%20articles%27%2C-%27info_desactiver_messagerie_personnelle%27%20=%3E%20%27You%20can%20enable%20or%20disable%20your%20personal%20messaging%20on%20this%20site.%27%2C%20%27info_descriptif%27%20=%3E%20%27Description:%27%2C%20%27info_desinstaller_plugin%27%20=%3E%20%27%20deactivates%20the%20plugin%20and%20deletes%20the%20data%27%2C%20%27info_discussion_cours%27%20=%3E%20%27Current%20discussions%27%2C%40%40%20-332%2C7%20%20284%2C6%20%40%40%20Do%20not%20submit%20this%20import%20request.%3Cp%3EFor%20more%20information%2C%20please%20see%20%3Ca%20href=?a=commitdiff_plain;h=cbca0769b749b66a3c0333d4cb21741b488f031f;p=lhc%2Fweb%2Fwiklou.git Add API purge test (mainly as proof of concept for how API tests should be written) --- diff --git a/tests/phpunit/includes/api/ApiPurgeTest.php b/tests/phpunit/includes/api/ApiPurgeTest.php new file mode 100644 index 0000000000..8db882033f --- /dev/null +++ b/tests/phpunit/includes/api/ApiPurgeTest.php @@ -0,0 +1,38 @@ +doLogin(); + } + + function testPurgeMainPage() { + + if ( !Title::newFromText( 'UTPage' )->exists() ) { + $this->markTestIncomplete( "The article [[UTPage]] does not exist" ); + } + + $somePage = mt_rand(); + + $data = $this->doApiRequest( array( + 'action' => 'purge', + 'titles' => 'UTPage|' . $somePage ) ); + + $this->assertArrayHasKey( 'purge', $data[0] ); + $this->assertArrayHasKey( 0, $data[0]['purge'] ); + $this->assertArrayHasKey( 'purged', $data[0]['purge'][0] ); + $this->assertEquals( 'UTPage', $data[0]['purge'][0]['title'] ); + + $this->assertArrayHasKey( 1, $data[0]['purge'] ); + $this->assertArrayHasKey( 'missing', $data[0]['purge'][1] ); + $this->assertEquals( $somePage, $data[0]['purge'][1]['title'] ); + + } + +}