wiki.techinc.nl/tests/phpunit/includes/api/ApiPurgeTest.php
Ammarpad 5e6cccc3a4 Re-enable the lone test in ApiPurgeTest
This was disabled 10 years ago because Jenkins was not happy.
We should reenable it and see whether it's happy now, otherwise
the test should be deleted.

Use MediaWikiTestCase::getExistingTestPage() to make sure the page
exists which is another reason given for skipping the test even if
not broken in whole.

Change the test name to more correct 'testPurgePage'

See https://phabricator.wikimedia.org/rMW7a0353b01080

Bug: T273603
Change-Id: Ief2017751256c683c8e4e4df375d5a82bcb4849c
2021-02-02 22:24:59 +00:00

37 lines
849 B
PHP

<?php
/**
* @group API
* @group Database
* @group medium
*
* @covers ApiPurge
*/
class ApiPurgeTest extends ApiTestCase {
public function testPurgePage() {
// Ensure 'UTPage' existence.
$this->getExistingTestPage( 'UTPage' );
$somePage = mt_rand();
$data = $this->doApiRequest( [
'action' => 'purge',
'titles' => 'UTPage|' . $somePage . '|%5D'
] );
$purgeData = $data[0]['purge'];
$this->assertArrayHasKey( 'purge', $data[0],
"Must receive a 'purge' result from API" );
$this->assertCount( 3, $purgeData,
'Purge request for three articles should give back three '
. 'results; received: ' . var_export( $purgeData, true ) );
$pages = [ 'UTPage' => 'purged', $somePage => 'missing', '%5D' => 'invalid' ];
foreach ( $purgeData as $v ) {
$this->assertArrayHasKey( $pages[$v['title']], $v );
}
}
}