2011-01-02 06:09:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-02 13:33:43 +00:00
|
|
|
* @group API
|
2011-01-02 06:09:58 +00:00
|
|
|
* @group Database
|
2013-01-18 19:02:28 +00:00
|
|
|
* @group medium
|
2013-10-23 16:01:33 +00:00
|
|
|
*
|
|
|
|
|
* @covers ApiPurge
|
2011-01-02 06:09:58 +00:00
|
|
|
*/
|
2011-07-01 16:34:02 +00:00
|
|
|
class ApiPurgeTest extends ApiTestCase {
|
2011-01-02 06:09:58 +00:00
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
protected function setUp() {
|
2011-01-02 06:09:58 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
$this->doLogin();
|
|
|
|
|
}
|
2011-12-11 21:49:05 +00:00
|
|
|
|
2012-01-08 16:40:05 +00:00
|
|
|
/**
|
|
|
|
|
* @group Broken
|
|
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testPurgeMainPage() {
|
2011-01-02 06:09:58 +00:00
|
|
|
if ( !Title::newFromText( 'UTPage' )->exists() ) {
|
|
|
|
|
$this->markTestIncomplete( "The article [[UTPage]] does not exist" );
|
|
|
|
|
}
|
2011-12-11 21:49:05 +00:00
|
|
|
|
2011-01-02 06:09:58 +00:00
|
|
|
$somePage = mt_rand();
|
|
|
|
|
|
|
|
|
|
$data = $this->doApiRequest( array(
|
|
|
|
|
'action' => 'purge',
|
2011-01-02 06:15:32 +00:00
|
|
|
'titles' => 'UTPage|' . $somePage . '|%5D' ) );
|
2011-12-11 21:49:05 +00:00
|
|
|
|
2011-12-12 10:25:29 +00:00
|
|
|
$this->assertArrayHasKey( 'purge', $data[0],
|
|
|
|
|
"Must receive a 'purge' result from API" );
|
|
|
|
|
|
2014-04-24 15:05:10 +00:00
|
|
|
$this->assertEquals(
|
|
|
|
|
3,
|
|
|
|
|
count( $data[0]['purge'] ),
|
|
|
|
|
"Purge request for three articles should give back three results received: "
|
|
|
|
|
. var_export( $data[0]['purge'], true ) );
|
2011-12-11 21:49:05 +00:00
|
|
|
|
|
|
|
|
$pages = array( 'UTPage' => 'purged', $somePage => 'missing', '%5D' => 'invalid' );
|
2013-02-14 11:56:23 +00:00
|
|
|
foreach ( $data[0]['purge'] as $v ) {
|
2011-12-11 21:49:05 +00:00
|
|
|
$this->assertArrayHasKey( $pages[$v['title']], $v );
|
|
|
|
|
}
|
2011-01-02 06:09:58 +00:00
|
|
|
}
|
|
|
|
|
}
|