13 $allowsAuthenticationDataChange, $canEditPrivate, $canSeePassword,
14 $userIsBlocked, $isAllowed
17 'PasswordResetRoutes' => $passwordResetRoutes,
18 'EnableEmail' => $enableEmail,
21 $authManager = $this->getMockBuilder(
AuthManager::class )->disableOriginalConstructor()
23 $authManager->expects( $this->
any() )->method(
'allowsAuthenticationDataChange' )
27 $user->expects( $this->
any() )->method(
'getName' )->willReturn(
'Foo' );
28 $user->expects( $this->
any() )->method(
'isBlocked' )->willReturn( $userIsBlocked );
29 $user->expects( $this->
any() )->method(
'isAllowed' )
30 ->will( $this->returnCallback(
function ( $perm )
use ( $canEditPrivate, $canSeePassword ) {
31 if ( $perm ===
'editmyprivateinfo' ) {
32 return $canEditPrivate;
33 } elseif ( $perm ===
'passwordreset' ) {
34 return $canSeePassword;
36 $this->fail(
'Unexpected permission check' );
42 $this->assertSame( $isAllowed, $passwordReset->isAllowed(
$user )->isGood() );
48 'passwordResetRoutes' => [],
49 'enableEmail' =>
true,
50 'allowsAuthenticationDataChange' =>
true,
51 'canEditPrivate' =>
true,
52 'canSeePassword' =>
true,
53 'userIsBlocked' =>
false,
57 'passwordResetRoutes' => [
'username' =>
true ],
58 'enableEmail' =>
false,
59 'allowsAuthenticationDataChange' =>
true,
60 'canEditPrivate' =>
true,
61 'canSeePassword' =>
true,
62 'userIsBlocked' =>
false,
66 'passwordResetRoutes' => [
'username' =>
true ],
67 'enableEmail' =>
true,
68 'allowsAuthenticationDataChange' =>
false,
69 'canEditPrivate' =>
true,
70 'canSeePassword' =>
true,
71 'userIsBlocked' =>
false,
75 'passwordResetRoutes' => [
'username' =>
true ],
76 'enableEmail' =>
true,
77 'allowsAuthenticationDataChange' =>
true,
78 'canEditPrivate' =>
false,
79 'canSeePassword' =>
true,
80 'userIsBlocked' =>
false,
84 'passwordResetRoutes' => [
'username' =>
true ],
85 'enableEmail' =>
true,
86 'allowsAuthenticationDataChange' =>
true,
87 'canEditPrivate' =>
true,
88 'canSeePassword' =>
true,
89 'userIsBlocked' =>
true,
93 'passwordResetRoutes' => [
'username' =>
true ],
94 'enableEmail' =>
true,
95 'allowsAuthenticationDataChange' =>
true,
96 'canEditPrivate' =>
true,
97 'canSeePassword' =>
false,
98 'userIsBlocked' =>
false,
102 'passwordResetRoutes' => [
'username' =>
true ],
103 'enableEmail' =>
true,
104 'allowsAuthenticationDataChange' =>
true,
105 'canEditPrivate' =>
true,
106 'canSeePassword' =>
true,
107 'userIsBlocked' =>
false,
115 'PasswordResetRoutes' => [
'username' =>
true,
'email' =>
true ],
116 'EnableEmail' =>
true,
119 $authManager = $this->getMockBuilder(
AuthManager::class )->disableOriginalConstructor()
121 $authManager->expects( $this->
any() )->method(
'allowsAuthenticationDataChange' )
123 $authManager->expects( $this->exactly( 2 ) )->method(
'changeAuthenticationData' );
127 $performingUser = $this->getMockBuilder(
User::class )->getMock();
128 $performingUser->expects( $this->
any() )->method(
'getRequest' )->willReturn(
$request );
129 $performingUser->expects( $this->
any() )->method(
'isAllowed' )->willReturn(
true );
131 $targetUser1 = $this->getMockBuilder(
User::class )->getMock();
132 $targetUser2 = $this->getMockBuilder(
User::class )->getMock();
133 $targetUser1->expects( $this->
any() )->method(
'getName' )->willReturn(
'User1' );
134 $targetUser2->expects( $this->
any() )->method(
'getName' )->willReturn(
'User2' );
135 $targetUser1->expects( $this->
any() )->method(
'getId' )->willReturn( 1 );
136 $targetUser2->expects( $this->
any() )->method(
'getId' )->willReturn( 2 );
137 $targetUser1->expects( $this->
any() )->method(
'getEmail' )->willReturn(
'foo@bar.baz' );
138 $targetUser2->expects( $this->
any() )->method(
'getEmail' )->willReturn(
'foo@bar.baz' );
141 ->setMethods( [
'getUsersByEmail' ] )->setConstructorArgs( [ $config, $authManager ] )
143 $passwordReset->expects( $this->
any() )->method(
'getUsersByEmail' )->with(
'foo@bar.baz' )
144 ->willReturn( [ $targetUser1, $targetUser2 ] );
146 $status = $passwordReset->isAllowed( $performingUser );
147 $this->assertTrue(
$status->isGood() );
149 $status = $passwordReset->execute( $performingUser,
null,
'foo@bar.baz' );
150 $this->assertTrue(
$status->isGood() );