wiki.techinc.nl/tests/phpunit/includes/api/ApiUndeleteTest.php
Atieno b531666770 Remove indirect calls to IDBAccessObject::READ_* constants
We are getting rid of the schema of implementing this interface and
calling self::READ_* constants, it's confusing, inconsistent, prone to
clashes and isn't really useful for non-ORM systems (which we are not)

Bug: T354194
Change-Id: I4c722807b27db4e59f5ba3acc3ddb57fca9140b1
2024-01-29 21:00:03 +03:00

55 lines
1.3 KiB
PHP

<?php
use MediaWiki\MainConfigNames;
use MediaWiki\Title\Title;
/**
* Tests for Undelete API.
*
* @group API
* @group Database
* @group medium
*
* @covers ApiUndelete
*/
class ApiUndeleteTest extends ApiTestCase {
protected function setUp(): void {
parent::setUp();
$this->overrideConfigValue( MainConfigNames::WatchlistExpiry, true );
}
/**
* @covers ApiUndelete::execute()
*/
public function testUndeleteWithWatch(): void {
$title = Title::makeTitle( NS_MAIN, 'TestUndeleteWithWatch' );
$sysop = $this->getTestSysop()->getUser();
$watchlistManager = $this->getServiceContainer()->getWatchlistManager();
// Create page.
$this->editPage( $title, 'Test', '', NS_MAIN, $sysop );
// Delete page.
$this->doApiRequestWithToken( [
'action' => 'delete',
'title' => $title->getPrefixedText(),
] );
// For good measure.
$this->assertFalse( $title->exists( IDBAccessObject::READ_LATEST ) );
$this->assertFalse( $watchlistManager->isWatched( $sysop, $title ) );
// Restore page, and watch with expiry.
$this->doApiRequestWithToken( [
'action' => 'undelete',
'title' => $title->getPrefixedText(),
'watchlist' => 'watch',
'watchlistexpiry' => '99990123000000',
] );
$this->assertTrue( $title->exists( IDBAccessObject::READ_LATEST ) );
$this->assertTrue( $watchlistManager->isTempWatched( $sysop, $title ) );
}
}