<?php
+use MediaWiki\Block\Restriction\PageRestriction;
+use MediaWiki\Block\Restriction\NamespaceRestriction;
+
/**
* @group API
* @group Database
__METHOD__,
[],
[
- 'change_tag' => [ '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' ],
]
) );
}
$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,
$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() );
}
/**
* @expectedExceptionMessage Too many values supplied for parameter "pagerestrictions". The
* limit is 10.
*/
- public function testBlockingToManyRestrictions() {
+ public function testBlockingToManyPageRestrictions() {
$this->setMwGlobals( [
'wgEnablePartialBlocks' => true,
] );