diff options
author | Thalia <thalia.e.chan@googlemail.com> | 2021-05-04 16:20:14 +0100 |
---|---|---|
committer | Thalia <thalia.e.chan@googlemail.com> | 2021-05-04 17:48:12 +0100 |
commit | c8736c949c1662cac2b89b2dfc43d4dacc8eb07d (patch) | |
tree | 71d1a1c61a6456aa2c92663d5a6da4e5f17f6ec1 /tests/phpunit/includes/api/ApiBlockTest.php | |
parent | 26a6797a7aabc0021429c00679ff7d5b50fd1ae9 (diff) | |
download | mediawikicore-c8736c949c1662cac2b89b2dfc43d4dacc8eb07d.tar.gz mediawikicore-c8736c949c1662cac2b89b2dfc43d4dacc8eb07d.zip |
ApiBlockTest: Separate out page and namespace restrictions tests
Make the assertions per test more focussed and stop relying on
restrictions being in a certain order.
Change-Id: I75e8d8d44eb43b894f72503ead55bd95dc4b72bf
Diffstat (limited to 'tests/phpunit/includes/api/ApiBlockTest.php')
-rw-r--r-- | tests/phpunit/includes/api/ApiBlockTest.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index 534c6ae0464e..f1690504f6be 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -19,7 +19,7 @@ class ApiBlockTest extends ApiTestCase { parent::setUp(); $this->tablesUsed = array_merge( $this->tablesUsed, - [ 'ipblocks', 'change_tag', 'change_tag_def', 'logging' ] + [ 'ipblocks', 'ipblocks_restrictions', 'change_tag', 'change_tag_def', 'logging' ] ); $this->mUser = $this->getMutableTestUser()->getUser(); @@ -253,26 +253,36 @@ class ApiBlockTest extends ApiTestCase { $this->assertSame( [], $block->getRestrictions() ); } - public function testBlockWithRestrictions() { + public function testBlockWithRestrictionsPage() { $title = 'Foo'; $page = $this->getExistingTestPage( $title ); - $namespace = NS_TALK; $this->doBlock( [ 'partial' => true, 'pagerestrictions' => $title, - 'namespacerestrictions' => $namespace, 'allowusertalk' => true, ] ); $block = DatabaseBlock::newFromTarget( $this->mUser->getName() ); $this->assertFalse( $block->isSitewide() ); - $this->assertCount( 2, $block->getRestrictions() ); $this->assertInstanceOf( PageRestriction::class, $block->getRestrictions()[0] ); $this->assertEquals( $title, $block->getRestrictions()[0]->getTitle()->getText() ); - $this->assertInstanceOf( NamespaceRestriction::class, $block->getRestrictions()[1] ); - $this->assertEquals( $namespace, $block->getRestrictions()[1]->getValue() ); + } + + public function testBlockWithRestrictionsNamespace() { + $namespace = NS_TALK; + + $this->doBlock( [ + 'partial' => true, + 'namespacerestrictions' => $namespace, + 'allowusertalk' => true, + ] ); + + $block = DatabaseBlock::newFromTarget( $this->mUser->getName() ); + + $this->assertInstanceOf( NamespaceRestriction::class, $block->getRestrictions()[0] ); + $this->assertEquals( $namespace, $block->getRestrictions()[0]->getValue() ); } public function testBlockingActionWithNoToken() { |