Debian Codegraph @

tests/phpunit/includes/api/ApiUndeleteTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Api;
4
5 use MediaWiki\MainConfigNames;
6 use MediaWiki\Title\Title;
7 use Wikimedia\Rdbms\IDBAccessObject;
8
9 /**
10 * Tests for Undelete API.
11 *
12 * @group API
13 * @group Database
14 * @group medium
15 *
16 * @covers MediaWiki\Api\ApiUndelete
17 */
18 class ApiUndeleteTest extends ApiTestCase {
19
20 protected function setUp(): void {
21 parent::setUp();
22
23 $this->overrideConfigValue( MainConfigNames::WatchlistExpiry, true );
24 }
25
26 /**
27 * @covers MediaWiki\Api\ApiUndelete::execute()
28 */
29 public function testUndeleteWithWatch(): void {
30 $title = Title::makeTitle( NS_MAIN, 'TestUndeleteWithWatch' );
31 $sysop = $this->getTestSysop()->getUser();
32 $watchlistManager = $this->getServiceContainer()->getWatchlistManager();
33
34 // Create page.
35 $this->editPage( $title, 'Test', '', NS_MAIN, $sysop );
36
37 // Delete page.
38 $this->doApiRequestWithToken( [
39 'action' => 'delete',
40 'title' => $title->getPrefixedText(),
41 ] );
42
43 // For good measure.
44 $this->assertFalse( $title->exists( IDBAccessObject::READ_LATEST ) );
45 $this->assertFalse( $watchlistManager->isWatched( $sysop, $title ) );
46
47 // Restore page, and watch with expiry.
48 $this->doApiRequestWithToken( [
49 'action' => 'undelete',
50 'title' => $title->getPrefixedText(),
51 'watchlist' => 'watch',
52 'watchlistexpiry' => '99990123000000',
53 ] );
54
55 $this->assertTrue( $title->exists( IDBAccessObject::READ_LATEST ) );
56 $this->assertTrue( $watchlistManager->isTempWatched( $sysop, $title ) );
57 }
58 }