@@ -114,6 +114,18 @@ public function testDisableRegistration()
114114 $ config ['registration ' ] = false ;
115115 $ loader ->load (array ($ config ), $ this ->configuration );
116116 $ this ->assertNotHasDefinition ('fos_user.registration.form.factory ' );
117+
118+ $ mailer = $ this ->configuration ->getDefinition ('fos_user.mailer.default ' );
119+ $ parameters = $ this ->configuration ->getParameterBag ()->resolveValue (
120+ $ mailer ->getArgument (3 )
121+ );
122+ $ this ->assertSame (
123+ array (
124+ 'confirmation ' => array ('no-registration@acme.com ' => 'Acme Ltd ' ),
125+ 'resetting ' => array ('admin@acme.org ' => 'Acme Corp ' ),
126+ ),
127+ $ parameters ['from_email ' ]
128+ );
117129 }
118130
119131 public function testDisableResetting ()
@@ -124,6 +136,18 @@ public function testDisableResetting()
124136 $ config ['resetting ' ] = false ;
125137 $ loader ->load (array ($ config ), $ this ->configuration );
126138 $ this ->assertNotHasDefinition ('fos_user.resetting.form.factory ' );
139+
140+ $ mailer = $ this ->configuration ->getDefinition ('fos_user.mailer.default ' );
141+ $ parameters = $ this ->configuration ->getParameterBag ()->resolveValue (
142+ $ mailer ->getArgument (3 )
143+ );
144+ $ this ->assertSame (
145+ array (
146+ 'confirmation ' => array ('admin@acme.org ' => 'Acme Corp ' ),
147+ 'resetting ' => array ('no-resetting@acme.com ' => 'Acme Ltd ' ),
148+ ),
149+ $ parameters ['from_email ' ]
150+ );
127151 }
128152
129153 public function testDisableProfile ()
@@ -146,6 +170,53 @@ public function testDisableChangePassword()
146170 $ this ->assertNotHasDefinition ('fos_user.change_password.form.factory ' );
147171 }
148172
173+ /**
174+ * @dataProvider providerEmailsDisabledFeature
175+ */
176+ public function testEmailsDisabledFeature ($ testConfig , $ registration , $ resetting )
177+ {
178+ $ this ->configuration = new ContainerBuilder ();
179+ $ loader = new FOSUserExtension ();
180+ $ config = $ this ->getEmptyConfig ();
181+ $ config = array_merge ($ config , $ testConfig );
182+ $ loader ->load (array ($ config ), $ this ->configuration );
183+
184+ $ this ->assertParameter ($ registration , 'fos_user.registration.confirmation.from_email ' );
185+ $ this ->assertParameter ($ resetting , 'fos_user.resetting.email.from_email ' );
186+ }
187+
188+ public function providerEmailsDisabledFeature ()
189+ {
190+ $ configBothFeaturesDisabled = array ('registration ' => false , 'resetting ' => false );
191+ $ configResettingDisabled = array ('resetting ' => false );
192+ $ configRegistrationDisabled = array ('registration ' => false );
193+ $ configOverridenRegistrationEmail = array (
194+ 'registration ' => array (
195+ 'confirmation ' => array (
196+ 'from_email ' => array ('address ' => 'ltd@acme.com ' , 'sender_name ' => 'Acme Ltd ' ),
197+ ),
198+ ),
199+ );
200+ $ configOverridenResettingEmail = array (
201+ 'resetting ' => array (
202+ 'email ' => array (
203+ 'from_email ' => array ('address ' => 'ltd@acme.com ' , 'sender_name ' => 'Acme Ltd ' ),
204+ ),
205+ ),
206+ );
207+
208+ $ default = array ('admin@acme.org ' => 'Acme Corp ' );
209+ $ overriden = array ('ltd@acme.com ' => 'Acme Ltd ' );
210+
211+ return array (
212+ array ($ configBothFeaturesDisabled , array ('no-registration@acme.com ' => 'Acme Ltd ' ), array ('no-resetting@acme.com ' => 'Acme Ltd ' )),
213+ array ($ configResettingDisabled , $ default , array ('no-resetting@acme.com ' => 'Acme Ltd ' )),
214+ array ($ configRegistrationDisabled , array ('no-registration@acme.com ' => 'Acme Ltd ' ), $ default ),
215+ array ($ configOverridenRegistrationEmail , $ overriden , $ default ),
216+ array ($ configOverridenResettingEmail , $ default , $ overriden ),
217+ );
218+ }
219+
149220 public function testUserLoadModelClassWithDefaults ()
150221 {
151222 $ this ->createEmptyConfiguration ();
0 commit comments