@@ -114,6 +114,18 @@ public function testDisableRegistration()
114
114
$ config ['registration ' ] = false ;
115
115
$ loader ->load (array ($ config ), $ this ->configuration );
116
116
$ 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 (
'[email protected] ' =>
'Acme Ltd ' ),
125
+ 'resetting ' =>
array (
'[email protected] ' =>
'Acme Corp ' ),
126
+ ),
127
+ $ parameters ['from_email ' ]
128
+ );
117
129
}
118
130
119
131
public function testDisableResetting ()
@@ -124,6 +136,18 @@ public function testDisableResetting()
124
136
$ config ['resetting ' ] = false ;
125
137
$ loader ->load (array ($ config ), $ this ->configuration );
126
138
$ 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 (
'[email protected] ' =>
'Acme Corp ' ),
147
+ 'resetting ' =>
array (
'[email protected] ' =>
'Acme Ltd ' ),
148
+ ),
149
+ $ parameters ['from_email ' ]
150
+ );
127
151
}
128
152
129
153
public function testDisableProfile ()
@@ -146,6 +170,53 @@ public function testDisableChangePassword()
146
170
$ this ->assertNotHasDefinition ('fos_user.change_password.form.factory ' );
147
171
}
148
172
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 ' =>
'[email protected] ' ,
'sender_name ' =>
'Acme Ltd ' ),
197
+ ),
198
+ ),
199
+ );
200
+ $ configOverridenResettingEmail = array (
201
+ 'resetting ' => array (
202
+ 'email ' => array (
203
+ 'from_email ' =>
array (
'address ' =>
'[email protected] ' ,
'sender_name ' =>
'Acme Ltd ' ),
204
+ ),
205
+ ),
206
+ );
207
+
208
+ $ default =
array (
'[email protected] ' =>
'Acme Corp ' );
209
+ $ overriden =
array (
'[email protected] ' =>
'Acme Ltd ' );
210
+
211
+ return array (
212
+ array (
$ configBothFeaturesDisabled,
array (
'[email protected] ' =>
'Acme Ltd ' ),
array (
'[email protected] ' =>
'Acme Ltd ' )),
213
+ array (
$ configResettingDisabled,
$ default,
array (
'[email protected] ' =>
'Acme Ltd ' )),
214
+ array (
$ configRegistrationDisabled,
array (
'[email protected] ' =>
'Acme Ltd ' ),
$ default),
215
+ array ($ configOverridenRegistrationEmail , $ overriden , $ default ),
216
+ array ($ configOverridenResettingEmail , $ default , $ overriden ),
217
+ );
218
+ }
219
+
149
220
public function testUserLoadModelClassWithDefaults ()
150
221
{
151
222
$ this ->createEmptyConfiguration ();
0 commit comments