MediaWiki  REL1_19
ApiPurgeTest.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class ApiPurgeTest extends ApiTestCase {
00007 
00008         function setUp() {
00009                 parent::setUp();
00010                 $this->doLogin();
00011         }
00012 
00016         function testPurgeMainPage() {
00017                 if ( !Title::newFromText( 'UTPage' )->exists() ) {
00018                         $this->markTestIncomplete( "The article [[UTPage]] does not exist" );
00019                 }
00020 
00021                 $somePage = mt_rand();
00022 
00023                 $data = $this->doApiRequest( array(
00024                         'action' => 'purge',
00025                         'titles' => 'UTPage|' . $somePage . '|%5D' ) );
00026 
00027                 $this->assertArrayHasKey( 'purge', $data[0],
00028                         "Must receive a 'purge' result from API" );
00029 
00030                 $this->assertEquals( 3, count( $data[0]['purge'] ),
00031                         "Purge request for three articles should give back three results received: " . var_export( $data[0]['purge'], true ) );
00032 
00033                 $pages = array( 'UTPage' => 'purged', $somePage => 'missing', '%5D' => 'invalid' );
00034                 foreach( $data[0]['purge'] as $v ) {
00035                         $this->assertArrayHasKey( $pages[$v['title']], $v );
00036                 }
00037         }
00038 
00039 }