5 use Psr\Log\LoggerInterface;
6 use Wikimedia\TestingAccessWrapper;
11 'EnableEmail' =>
true,
12 'EmailAuthentication' =>
true,
16 $provider->setConfig(
$config );
17 $providerPriv = TestingAccessWrapper::newFromObject( $provider );
18 $this->assertTrue( $providerPriv->sendConfirmationEmail );
21 'sendConfirmationEmail' =>
false,
23 $provider->setConfig(
$config );
24 $providerPriv = TestingAccessWrapper::newFromObject( $provider );
25 $this->assertFalse( $providerPriv->sendConfirmationEmail );
35 'sendConfirmationEmail' =>
true,
37 $this->assertSame( $expected, $provider->getAuthenticationRequests(
$action, [] ) );
52 'sendConfirmationEmail' =>
true,
61 $creator = $this->getMockBuilder(
'User' )->getMock();
62 $userWithoutEmail = $this->getMockBuilder(
'User' )->getMock();
63 $userWithoutEmail->expects( $this->
any() )->method(
'getEmail' )->willReturn(
'' );
64 $userWithoutEmail->expects( $this->
any() )->method(
'getInstanceForUpdate' )->willReturnSelf();
65 $userWithoutEmail->expects( $this->never() )->method(
'sendConfirmationMail' );
66 $userWithEmailError = $this->getMockBuilder(
'User' )->getMock();
67 $userWithEmailError->expects( $this->
any() )->method(
'getEmail' )->willReturn(
'foo@bar.baz' );
68 $userWithEmailError->expects( $this->
any() )->method(
'getInstanceForUpdate' )->willReturnSelf();
69 $userWithEmailError->expects( $this->
any() )->method(
'sendConfirmationMail' )
71 $userExpectsConfirmation = $this->getMockBuilder(
'User' )->getMock();
72 $userExpectsConfirmation->expects( $this->
any() )->method(
'getEmail' )
73 ->willReturn(
'foo@bar.baz' );
74 $userExpectsConfirmation->expects( $this->
any() )->method(
'getInstanceForUpdate' )
76 $userExpectsConfirmation->expects( $this->once() )->method(
'sendConfirmationMail' )
78 $userNotExpectsConfirmation = $this->getMockBuilder(
'User' )->getMock();
79 $userNotExpectsConfirmation->expects( $this->
any() )->method(
'getEmail' )
80 ->willReturn(
'foo@bar.baz' );
81 $userNotExpectsConfirmation->expects( $this->
any() )->method(
'getInstanceForUpdate' )
83 $userNotExpectsConfirmation->expects( $this->never() )->method(
'sendConfirmationMail' );
86 'sendConfirmationEmail' =>
false,
88 $provider->setManager( $authManager );
89 $provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );
92 'sendConfirmationEmail' =>
true,
94 $provider->setManager( $authManager );
95 $provider->beginSecondaryAccountCreation( $userWithoutEmail, $creator, [] );
96 $provider->beginSecondaryAccountCreation( $userExpectsConfirmation, $creator, [] );
100 $logger->expects( $this->once() )->method(
'warning' );
101 $provider->setLogger( $logger );
102 $provider->beginSecondaryAccountCreation( $userWithEmailError, $creator, [] );
105 $authManager->setAuthenticationSessionData(
'no-email',
true );
106 $provider->setManager( $authManager );
107 $provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );