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
This commit is contained in:
Ammarpad 2021-02-02 12:13:14 +01:00 committed by DannyS712
parent 36407cb222
commit 5e6cccc3a4

View file

@ -9,29 +9,28 @@
*/
class ApiPurgeTest extends ApiTestCase {
/**
* @group Broken
*/
public function testPurgeMainPage() {
if ( !Title::newFromText( 'UTPage' )->exists() ) {
$this->markTestIncomplete( "The article [[UTPage]] does not exist" );
}
public function testPurgePage() {
// Ensure 'UTPage' existence.
$this->getExistingTestPage( 'UTPage' );
$somePage = mt_rand();
$data = $this->doApiRequest( [
'action' => 'purge',
'titles' => 'UTPage|' . $somePage . '|%5D' ] );
'titles' => 'UTPage|' . $somePage . '|%5D'
] );
$purgeData = $data[0]['purge'];
$this->assertArrayHasKey( 'purge', $data[0],
"Must receive a 'purge' result from API" );
$this->assertCount( 3, $data[0]['purge'],
"Purge request for three articles should give back three results received: "
. var_export( $data[0]['purge'], true ) );
$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 ( $data[0]['purge'] as $v ) {
foreach ( $purgeData as $v ) {
$this->assertArrayHasKey( $pages[$v['title']], $v );
}
}