9 $config = new \HashConfig( [
10 'EnableEmail' =>
true,
11 'EmailAuthentication' =>
true,
15 $provider->setConfig( $config );
16 $providerPriv = \TestingAccessWrapper::newFromObject( $provider );
17 $this->assertTrue( $providerPriv->sendConfirmationEmail );
20 'sendConfirmationEmail' =>
false,
22 $provider->setConfig( $config );
23 $providerPriv = \TestingAccessWrapper::newFromObject( $provider );
24 $this->assertFalse( $providerPriv->sendConfirmationEmail );
60 $creator = $this->getMock(
'User' );
61 $userWithoutEmail = $this->getMock(
'User' );
62 $userWithoutEmail->expects( $this->any() )->method(
'getEmail' )->willReturn(
'' );
63 $userWithoutEmail->expects( $this->any() )->method(
'getInstanceForUpdate' )->willReturnSelf();
64 $userWithoutEmail->expects( $this->never() )->method(
'sendConfirmationMail' );
65 $userWithEmailError = $this->getMock(
'User' );
66 $userWithEmailError->expects( $this->any() )->method(
'getEmail' )->willReturn(
'foo@bar.baz' );
67 $userWithEmailError->expects( $this->any() )->method(
'getInstanceForUpdate' )->willReturnSelf();
68 $userWithEmailError->expects( $this->any() )->method(
'sendConfirmationMail' )
69 ->willReturn( \Status::newFatal(
'fail' ) );
70 $userExpectsConfirmation = $this->getMock(
'User' );
71 $userExpectsConfirmation->expects( $this->any() )->method(
'getEmail' )
72 ->willReturn(
'foo@bar.baz' );
73 $userExpectsConfirmation->expects( $this->any() )->method(
'getInstanceForUpdate' )
75 $userExpectsConfirmation->expects( $this->once() )->method(
'sendConfirmationMail' )
76 ->willReturn( \Status::newGood() );
77 $userNotExpectsConfirmation = $this->getMock(
'User' );
78 $userNotExpectsConfirmation->expects( $this->any() )->method(
'getEmail' )
79 ->willReturn(
'foo@bar.baz' );
80 $userNotExpectsConfirmation->expects( $this->any() )->method(
'getInstanceForUpdate' )
82 $userNotExpectsConfirmation->expects( $this->never() )->method(
'sendConfirmationMail' );
85 'sendConfirmationEmail' =>
false,
87 $provider->setManager( $authManager );
88 $provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );
91 'sendConfirmationEmail' =>
true,
93 $provider->setManager( $authManager );
94 $provider->beginSecondaryAccountCreation( $userWithoutEmail, $creator, [] );
95 $provider->beginSecondaryAccountCreation( $userExpectsConfirmation, $creator, [] );
98 $logger = $this->getMockForAbstractClass( LoggerInterface::class );
99 $logger->expects( $this->once() )->method(
'warning' );
100 $provider->setLogger( $logger );
101 $provider->beginSecondaryAccountCreation( $userWithEmailError, $creator, [] );
104 $authManager->setAuthenticationSessionData(
'no-email',
true );
105 $provider->setManager( $authManager );
106 $provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );