<?php
+use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\Restriction\PageRestriction;
use MediaWiki\Block\Restriction\NamespaceRestriction;
$ret = $this->doApiRequest( array_merge( $params, $extraParams ), null,
false, $blocker );
- $block = Block::newFromTarget( $this->mUser->getName() );
+ $block = DatabaseBlock::newFromTarget( $this->mUser->getName() );
$this->assertTrue( !is_null( $block ), 'Block is valid' );
$this->assertSame( $this->mUser->getName(), (string)$block->getTarget() );
- $this->assertSame( 'Some reason', $block->mReason );
+ $this->assertSame( 'Some reason', $block->getReason() );
return $ret;
}
'You cannot block or unblock other users because you are yourself blocked.' );
$blocked = $this->getMutableTestUser( [ 'sysop' ] )->getUser();
- $block = new Block( [
+ $block = new DatabaseBlock( [
'address' => $blocked->getName(),
'by' => self::$users['sysop']->getUser()->getId(),
'reason' => 'Capriciousness',
$this->setMwGlobals( 'wgRevokePermissions',
[ 'user' => [ 'applychangetags' => true ] ] );
+ $this->overrideMwServices();
+
$this->doBlock( [ 'tags' => 'custom tag' ] );
}
$this->mergeMwGlobalArrayValue( 'wgGroupPermissions',
[ 'sysop' => $newPermissions ] );
+ $this->overrideMwServices();
$res = $this->doBlock( [ 'hidename' => '' ] );
$dbw = wfGetDB( DB_MASTER );
}
public function testBlockWithEmailBlock() {
+ $this->setMwGlobals( [
+ 'wgEnableEmail' => true,
+ 'wgEnableUserEmail' => true,
+ 'wgSysopEmailBans' => true,
+ ] );
+
$res = $this->doBlock( [ 'noemail' => '' ] );
$dbw = wfGetDB( DB_MASTER );
}
public function testBlockWithProhibitedEmailBlock() {
+ $this->setMwGlobals( [
+ 'wgEnableEmail' => true,
+ 'wgEnableUserEmail' => true,
+ 'wgSysopEmailBans' => true,
+ ] );
+
$this->setExpectedException( ApiUsageException::class,
"You don't have permission to block users from sending email through the wiki." );
$this->setMwGlobals( 'wgRevokePermissions',
[ 'sysop' => [ 'blockemail' => true ] ] );
+ $this->overrideMwServices();
+
$this->doBlock( [ 'noemail' => '' ] );
}
$this->doBlock();
- $block = Block::newFromTarget( $this->mUser->getName() );
+ $block = DatabaseBlock::newFromTarget( $this->mUser->getName() );
$this->assertTrue( $block->isSitewide() );
$this->assertCount( 0, $block->getRestrictions() );
'namespacerestrictions' => $namespace,
] );
- $block = Block::newFromTarget( $this->mUser->getName() );
+ $block = DatabaseBlock::newFromTarget( $this->mUser->getName() );
$this->assertFalse( $block->isSitewide() );
$this->assertCount( 2, $block->getRestrictions() );