Page MenuHomeWickedGov Phorge

ApiProtectTest.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ApiProtectTest.php

<?php
namespace MediaWiki\Tests\Api;
use MediaWiki\MainConfigNames;
use MediaWiki\Title\Title;
/**
* Tests for protect API.
*
* @group API
* @group Database
* @group medium
*
* @covers MediaWiki\Api\ApiProtect
*/
class ApiProtectTest extends ApiTestCase {
protected function setUp(): void {
parent::setUp();
$this->overrideConfigValue( MainConfigNames::WatchlistExpiry, true );
}
/**
* @covers MediaWiki\Api\ApiProtect::execute()
*/
public function testProtectWithWatch(): void {
$title = Title::makeTitle( NS_MAIN, 'TestProtectWithWatch' );
$this->editPage( $title, 'Some text' );
$apiResult = $this->doApiRequestWithToken( [
'action' => 'protect',
'title' => $title->getPrefixedText(),
'protections' => 'edit=sysop',
'expiry' => '55550123000000',
'watchlist' => 'watch',
'watchlistexpiry' => '99990123000000',
] )[0];
$this->assertArrayHasKey( 'protect', $apiResult );
$this->assertSame( $title->getPrefixedText(), $apiResult['protect']['title'] );
$this->assertTrue( $this->getServiceContainer()->getRestrictionStore()->isProtected( $title, 'edit' ) );
$this->assertTrue( $this->getServiceContainer()->getWatchlistManager()->isTempWatched(
$this->getTestSysop()->getUser(),
$title
) );
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 20 2026, 07:34 (11 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
3e/b2/28c7ccc109481bc30ebfc6c6e2e9
Default Alt Text
ApiProtectTest.php (1 KB)

Event Timeline