Add API purge test (mainly as proof of concept for how API tests should be written)
authorX! <soxred93@users.mediawiki.org>
Sun, 2 Jan 2011 06:09:58 +0000 (06:09 +0000)
committerX! <soxred93@users.mediawiki.org>
Sun, 2 Jan 2011 06:09:58 +0000 (06:09 +0000)
tests/phpunit/includes/api/ApiPurgeTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/includes/api/ApiPurgeTest.php b/tests/phpunit/includes/api/ApiPurgeTest.php
new file mode 100644 (file)
index 0000000..8db8820
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+require_once dirname( __FILE__ ) . '/ApiSetup.php';
+
+/**
+ * @group Database
+ */
+class ApiPurgeTest extends ApiTestSetup {
+
+       function setUp() {
+               parent::setUp();
+               $this->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'] );
+               
+       }
+
+}