13 $config = new \HashConfig( [
14 'EnableEmail' =>
true,
15 'EmailAuthentication' =>
true,
19 $provider->setConfig( $config );
20 $providerPriv = TestingAccessWrapper::newFromObject( $provider );
21 $this->assertTrue( $providerPriv->sendConfirmationEmail );
24 'sendConfirmationEmail' =>
false,
26 $provider->setConfig( $config );
27 $providerPriv = TestingAccessWrapper::newFromObject( $provider );
28 $this->assertFalse( $providerPriv->sendConfirmationEmail );
64 $creator = $this->getMockBuilder( \User::class )->getMock();
65 $userWithoutEmail = $this->getMockBuilder( \User::class )->getMock();
66 $userWithoutEmail->expects( $this->any() )->method(
'getEmail' )->willReturn(
'' );
67 $userWithoutEmail->expects( $this->any() )->method(
'getInstanceForUpdate' )->willReturnSelf();
68 $userWithoutEmail->expects( $this->never() )->method(
'sendConfirmationMail' );
69 $userWithEmailError = $this->getMockBuilder( \User::class )->getMock();
70 $userWithEmailError->expects( $this->any() )->method(
'getEmail' )->willReturn(
'foo@bar.baz' );
71 $userWithEmailError->expects( $this->any() )->method(
'getInstanceForUpdate' )->willReturnSelf();
72 $userWithEmailError->expects( $this->any() )->method(
'sendConfirmationMail' )
73 ->willReturn( \Status::newFatal(
'fail' ) );
74 $userExpectsConfirmation = $this->getMockBuilder( \User::class )->getMock();
75 $userExpectsConfirmation->expects( $this->any() )->method(
'getEmail' )
76 ->willReturn(
'foo@bar.baz' );
77 $userExpectsConfirmation->expects( $this->any() )->method(
'getInstanceForUpdate' )
79 $userExpectsConfirmation->expects( $this->once() )->method(
'sendConfirmationMail' )
80 ->willReturn( \Status::newGood() );
81 $userNotExpectsConfirmation = $this->getMockBuilder( \User::class )->getMock();
82 $userNotExpectsConfirmation->expects( $this->any() )->method(
'getEmail' )
83 ->willReturn(
'foo@bar.baz' );
84 $userNotExpectsConfirmation->expects( $this->any() )->method(
'getInstanceForUpdate' )
86 $userNotExpectsConfirmation->expects( $this->never() )->method(
'sendConfirmationMail' );
89 'sendConfirmationEmail' =>
false,
91 $provider->setManager( $authManager );
92 $provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );
95 'sendConfirmationEmail' =>
true,
97 $provider->setManager( $authManager );
98 $provider->beginSecondaryAccountCreation( $userWithoutEmail, $creator, [] );
99 $provider->beginSecondaryAccountCreation( $userExpectsConfirmation, $creator, [] );
102 $logger = $this->getMockForAbstractClass( LoggerInterface::class );
103 $logger->expects( $this->once() )->method(
'warning' );
104 $provider->setLogger( $logger );
105 $provider->beginSecondaryAccountCreation( $userWithEmailError, $creator, [] );
108 $authManager->setAuthenticationSessionData(
'no-email',
true );
109 $provider->setManager( $authManager );
110 $provider->beginSecondaryAccountCreation( $userNotExpectsConfirmation, $creator, [] );