<?php
use MediaWiki\Auth\AuthManager;
+use MediaWiki\Block\SystemBlock;
/**
+ * @covers PasswordReset
* @group Database
*/
class PasswordResetTest extends MediaWikiTestCase {
'enableEmail' => true,
'allowsAuthenticationDataChange' => true,
'canEditPrivate' => true,
- 'block' => new Block( [ 'systemBlock' => 'proxy' ] ),
+ 'block' => new SystemBlock(
+ [ 'systemBlock' => 'proxy' ]
+ ),
'globalBlock' => null,
'isAllowed' => false,
],
- 'globally blocked with account creation disabled' => [
+ 'globally blocked with account creation not disabled' => [
'passwordResetRoutes' => [ 'username' => true ],
'enableEmail' => true,
'allowsAuthenticationDataChange' => true,
'canEditPrivate' => true,
'block' => null,
- 'globalBlock' => new Block( [ 'systemBlock' => 'global-block', 'createAccount' => true ] ),
- 'isAllowed' => false,
+ 'globalBlock' => new SystemBlock(
+ [ 'systemBlock' => 'global-block' ]
+ ),
+ 'isAllowed' => true,
],
- 'globally blocked with account creation not disabled' => [
+ 'blocked via wgSoftBlockRanges' => [
'passwordResetRoutes' => [ 'username' => true ],
'enableEmail' => true,
'allowsAuthenticationDataChange' => true,
'canEditPrivate' => true,
- 'block' => null,
- 'globalBlock' => new Block( [ 'systemBlock' => 'global-block', 'createAccount' => false ] ),
+ 'block' => new SystemBlock(
+ [ 'systemBlock' => 'wgSoftBlockRanges', 'anonOnly' => true ]
+ ),
+ 'globalBlock' => null,
'isAllowed' => true,
],
- 'blocked via wgSoftBlockRanges' => [
+ 'blocked with an unknown system block type' => [
'passwordResetRoutes' => [ 'username' => true ],
'enableEmail' => true,
'allowsAuthenticationDataChange' => true,
'canEditPrivate' => true,
- 'block' => new Block( [ 'systemBlock' => 'wgSoftBlockRanges', 'anonOnly' => true ] ),
+ 'block' => new SystemBlock( [ 'systemBlock' => 'unknown' ] ),
'globalBlock' => null,
- 'isAllowed' => true,
+ 'isAllowed' => false,
],
'all OK' => [
'passwordResetRoutes' => [ 'username' => true ],
$performingUser = $this->getMockBuilder( User::class )->getMock();
$performingUser->expects( $this->any() )->method( 'getRequest' )->willReturn( $request );
$performingUser->expects( $this->any() )->method( 'isAllowed' )->willReturn( true );
+ $performingUser->expects( $this->any() )->method( 'getName' )->willReturn( 'Performer' );
$targetUser1 = $this->getMockBuilder( User::class )->getMock();
$targetUser2 = $this->getMockBuilder( User::class )->getMock();