wiki.techinc.nl/tests/phpunit/includes/api/ApiPurgeTest.php
Tim Starling 0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00

40 lines
832 B
PHP

<?php
/**
* @group API
* @group Database
* @group medium
*
* @covers ApiPurge
*/
class ApiPurgeTest extends ApiTestCase {
public function testPurgePage() {
$this->getExistingTestPage( 'UTPage' );
$this->getNonexistingTestPage( 'UTPage-NotFound' );
[ $data ] = $this->doApiRequest( [
'action' => 'purge',
'titles' => 'UTPage|UTPage-NotFound|%5D'
] );
$resultByTitle = [];
foreach ( $data['purge'] as $entry ) {
$key = $entry['title'];
// Ignore localised or redundant field
unset( $entry['invalidreason'] );
unset( $entry['title'] );
$resultByTitle[$key] = $entry;
}
$this->assertEquals(
[
'UTPage' => [ 'purged' => true, 'ns' => 0 ],
'UTPage-NotFound' => [ 'missing' => true, 'ns' => 0 ],
'%5D' => [ 'invalid' => true ],
],
$resultByTitle,
'Result'
);
}
}