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