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