wiki.techinc.nl/tests/phpunit/maintenance/UndeleteTest.php
Dreamy Jazz 7e90b87c2b Test undelete.php
Why:
* The maintenance scripts in core are mostly untested and testing
  the less complex scripts will improve the test coverage in core.

What:
* Create UndeleteTest

Bug: T371167
Change-Id: I682df10278f0adc61801e59b1509eb339fc1f400
2024-07-27 07:51:37 +00:00

40 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Tests\Maintenance;
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
use Undelete;
/**
* @covers \Undelete
* @group Database
* @author Dreamy Jazz
*/
class UndeleteTest extends MaintenanceBaseTestCase {
use MockAuthorityTrait;
protected function getMaintenanceClass() {
return Undelete::class;
}
public function testExecute() {
// Create a page and then delete it
$testPage = $this->getExistingTestPage();
$deleteStatus = $this->getServiceContainer()->getDeletePageFactory()
->newDeletePage( $testPage, $this->mockRegisteredUltimateAuthority() )
->deleteIfAllowed( 'test' );
$this->assertStatusGood( $deleteStatus );
$testPage->clear();
$this->assertFalse( $testPage->exists() );
// Call ::execute
$this->maintenance->setArg( 'pagename', $testPage );
$this->maintenance->execute();
// Verify that the page was undeleted.
$testPage->clear();
$this->assertTrue( $testPage->exists() );
$this->expectOutputString(
"Undeleting " . $testPage->getTitle()->getPrefixedDBkey() . "...\n" .
"done\n"
);
}
}