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
|
|
|
|
2021-02-02 11:13:14 +00:00
|
|
|
public function testPurgePage() {
|
|
|
|
|
$this->getExistingTestPage( 'UTPage' );
|
2021-03-13 02:29:09 +00:00
|
|
|
$this->getNonexistingTestPage( 'UTPage-NotFound' );
|
2011-12-11 21:49:05 +00:00
|
|
|
|
2021-03-13 02:29:09 +00:00
|
|
|
list( $data ) = $this->doApiRequest( [
|
2011-01-02 06:09:58 +00:00
|
|
|
'action' => 'purge',
|
2021-03-13 02:29:09 +00:00
|
|
|
'titles' => 'UTPage|UTPage-NotFound|%5D'
|
2021-02-02 11:13:14 +00:00
|
|
|
] );
|
|
|
|
|
|
2021-03-13 02:29:09 +00:00
|
|
|
$resultByTitle = [];
|
|
|
|
|
foreach ( $data['purge'] as $entry ) {
|
|
|
|
|
$key = $entry['title'];
|
|
|
|
|
// Ignore localised or redundant field
|
|
|
|
|
unset( $entry['invalidreason'] );
|
|
|
|
|
unset( $entry['title'] );
|
|
|
|
|
$resultByTitle[$key] = $entry;
|
2011-12-11 21:49:05 +00:00
|
|
|
}
|
2021-03-13 02:29:09 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
'UTPage' => [ 'purged' => true, 'ns' => 0 ],
|
|
|
|
|
'UTPage-NotFound' => [ 'missing' => true, 'ns' => 0 ],
|
|
|
|
|
'%5D' => [ 'invalid' => true ],
|
|
|
|
|
],
|
|
|
|
|
$resultByTitle,
|
|
|
|
|
'Result'
|
|
|
|
|
);
|
2011-01-02 06:09:58 +00:00
|
|
|
}
|
|
|
|
|
}
|