X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiBlockTest.php;h=01455edcafeff974a41268954ef19ff2de4a0c75;hb=cb15755e92513eb61dcea6d7a0c0930374efdb86;hp=9898e535e0a5eeae4d940bc359deac0572e20f5a;hpb=36de1c7c818b696b06e7f170a1d9d0b943441d05;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index 9898e535e0..01455edcaf 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -1,5 +1,8 @@ [ 'INNER JOIN', 'ct_log_id = log_id' ], - 'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ], + 'change_tag' => [ 'JOIN', 'ct_log_id = log_id' ], + 'change_tag_def' => [ 'JOIN', 'ctd_id = ct_tag_id' ], ] ) ); } @@ -215,6 +218,19 @@ class ApiBlockTest extends ApiTestCase { $this->doBlock( [ 'expiry' => '' ] ); } + public function testBlockWithoutRestrictions() { + $this->setMwGlobals( [ + 'wgEnablePartialBlocks' => true, + ] ); + + $this->doBlock(); + + $block = Block::newFromTarget( $this->mUser->getName() ); + + $this->assertTrue( $block->isSitewide() ); + $this->assertCount( 0, $block->getRestrictions() ); + } + public function testBlockWithRestrictions() { $this->setMwGlobals( [ 'wgEnablePartialBlocks' => true, @@ -222,17 +238,22 @@ class ApiBlockTest extends ApiTestCase { $title = 'Foo'; $page = $this->getExistingTestPage( $title ); + $namespace = NS_TALK; $this->doBlock( [ 'partial' => true, 'pagerestrictions' => $title, + 'namespacerestrictions' => $namespace, ] ); $block = Block::newFromTarget( $this->mUser->getName() ); $this->assertFalse( $block->isSitewide() ); - $this->assertCount( 1, $block->getRestrictions() ); + $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() ); } /** @@ -274,9 +295,10 @@ class ApiBlockTest extends ApiTestCase { /** * @expectedException ApiUsageException - * @expectedExceptionMessage "pagerestrictions" may not be over 10 (set to 11) for bots or sysops. + * @expectedExceptionMessage Too many values supplied for parameter "pagerestrictions". The + * limit is 10. */ - public function testBlockingToManyRestrictions() { + public function testBlockingToManyPageRestrictions() { $this->setMwGlobals( [ 'wgEnablePartialBlocks' => true, ] );