This introduces an ApiWatchlistTrait that refactors out common code across APIs that allow you to watch pages. Some methods have been migrated from ApiBase and changed completely, but codesearch suggests they aren't being used outside the API modules in this patch. Bug: T248512 Bug: T248514 Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Tests for Undelete API.
|
|
*
|
|
* @group API
|
|
* @group Database
|
|
* @group medium
|
|
*
|
|
* @covers ApiUndelete
|
|
*/
|
|
class ApiUndeleteTest extends ApiTestCase {
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->tablesUsed = array_merge(
|
|
$this->tablesUsed,
|
|
[ 'logging', 'watchlist', 'watchlist_expiry' ]
|
|
);
|
|
|
|
$this->setMwGlobals( [
|
|
'wgWatchlistExpiry' => true,
|
|
] );
|
|
}
|
|
|
|
/**
|
|
* @covers ApiUndelete::execute()
|
|
*/
|
|
public function testUndeleteWithWatch(): void {
|
|
$name = ucfirst( __FUNCTION__ );
|
|
$title = Title::newFromText( $name );
|
|
$sysop = $this->getTestSysop()->getUser();
|
|
|
|
// Create page.
|
|
$this->editPage( $name, 'Test' );
|
|
|
|
// Delete page.
|
|
$this->doApiRequestWithToken( [
|
|
'action' => 'delete',
|
|
'title' => $name,
|
|
] );
|
|
|
|
// For good measure.
|
|
$this->assertFalse( $title->exists() );
|
|
$this->assertFalse( $sysop->isWatched( $title ) );
|
|
|
|
// Restore page, and watch with expiry.
|
|
$this->doApiRequestWithToken( [
|
|
'action' => 'undelete',
|
|
'title' => $name,
|
|
'watchlist' => 'watch',
|
|
'watchlistexpiry' => '99990123000000',
|
|
] );
|
|
|
|
$this->assertTrue( $title->exists() );
|
|
$this->assertTrue( $sysop->isTempWatched( $title ) );
|
|
}
|
|
}
|