| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Maintenance; |
| 4 |
|
| 5 |
use RenameRestrictions; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class RenameRestrictionsTest extends MaintenanceBaseTestCase { |
| 13 |
|
| 14 |
protected function getMaintenanceClass() { |
| 15 |
return RenameRestrictions::class; |
| 16 |
} |
| 17 |
|
| 18 |
public function testExecute() { |
| 19 |
|
| 20 |
$existingTestPage = $this->getExistingTestPage(); |
| 21 |
$cascade = false; |
| 22 |
$existingTestPage->doUpdateRestrictions( |
| 23 |
[ 'edit' => 'autoconfirmedb' ], [ 'edit' => 'infinity' ], $cascade, 'Test', |
| 24 |
$this->getTestUser()->getUserIdentity() |
| 25 |
); |
| 26 |
|
| 27 |
$nonExistingTestPage = $this->getNonexistingTestPage(); |
| 28 |
$nonExistingTestPage->doUpdateRestrictions( |
| 29 |
[ 'create' => 'autoconfirmedb' ], [ 'create' => 'infinity' ], $cascade, 'Test', |
| 30 |
$this->getTestUser()->getUserIdentity() |
| 31 |
); |
| 32 |
|
| 33 |
$this->maintenance->setArg( 'oldlevel', 'autoconfirmedb' ); |
| 34 |
$this->maintenance->setArg( 'newlevel', 'autoconfirmed' ); |
| 35 |
$this->maintenance->execute(); |
| 36 |
|
| 37 |
$restrictionStore = $this->getServiceContainer()->getRestrictionStore(); |
| 38 |
$this->assertArrayEquals( |
| 39 |
[ 'autoconfirmed' ], |
| 40 |
$restrictionStore->getRestrictions( $existingTestPage, 'edit' ) |
| 41 |
); |
| 42 |
$this->assertArrayEquals( |
| 43 |
[ 'autoconfirmed' ], |
| 44 |
$restrictionStore->getRestrictions( $nonExistingTestPage, 'create' ) |
| 45 |
); |
| 46 |
} |
| 47 |
} |