Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / RenameRestrictionsTest.php
blob6dadd47cab56feb3192a58d1abda560ebf64ac43
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use RenameRestrictions;
7 /**
8 * @covers \RenameRestrictions
9 * @group Database
10 * @author Dreamy Jazz
12 class RenameRestrictionsTest extends MaintenanceBaseTestCase {
14 protected function getMaintenanceClass() {
15 return RenameRestrictions::class;
18 public function testExecute() {
19 // Create an existing test page that is protected with the wrong 'autoconfirmedb' protection level
20 $existingTestPage = $this->getExistingTestPage();
21 $cascade = false;
22 $existingTestPage->doUpdateRestrictions(
23 [ 'edit' => 'autoconfirmedb' ], [ 'edit' => 'infinity' ], $cascade, 'Test',
24 $this->getTestUser()->getUserIdentity()
26 // Salt an non-existing page with the wrong 'autoconfirmedb' protection level
27 $nonExistingTestPage = $this->getNonexistingTestPage();
28 $nonExistingTestPage->doUpdateRestrictions(
29 [ 'create' => 'autoconfirmedb' ], [ 'create' => 'infinity' ], $cascade, 'Test',
30 $this->getTestUser()->getUserIdentity()
32 // Run the maintenance script to rename 'autoconfirmedb' to 'autoconfirmed'
33 $this->maintenance->setArg( 'oldlevel', 'autoconfirmedb' );
34 $this->maintenance->setArg( 'newlevel', 'autoconfirmed' );
35 $this->maintenance->execute();
36 // Verify that the protection restriction has been appropriately renamed.
37 $restrictionStore = $this->getServiceContainer()->getRestrictionStore();
38 $this->assertArrayEquals(
39 [ 'autoconfirmed' ],
40 $restrictionStore->getRestrictions( $existingTestPage, 'edit' )
42 $this->assertArrayEquals(
43 [ 'autoconfirmed' ],
44 $restrictionStore->getRestrictions( $nonExistingTestPage, 'create' )