10 $config = new \HashConfig( [
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 );
61 $creator = $this->getMockBuilder( \User::class )->getMock();
62 $userWithoutEmail = $this->getMockBuilder( \User::class )->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::class )->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' )
70 ->willReturn( \Status::newFatal(
'fail' ) );
71 $userExpectsConfirmation = $this->getMockBuilder( \User::class )->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' )
77 ->willReturn( \Status::newGood() );
78 $userNotExpectsConfirmation = $this->getMockBuilder( \User::class )->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, [] );
99 $logger = $this->getMockForAbstractClass( LoggerInterface::class );
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, [] );