File tree 2 files changed +29
-0
lines changed
src/Symfony/Bundle/FrameworkBundle
Tests/DependencyInjection
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1110,6 +1110,10 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode)
1110
1110
->{!class_exists (FullStack::class) && interface_exists (MessageBusInterface::class) ? 'canBeDisabled ' : 'canBeEnabled ' }()
1111
1111
->fixXmlConfig ('transport ' )
1112
1112
->fixXmlConfig ('bus ' , 'buses ' )
1113
+ ->validate ()
1114
+ ->ifTrue (function ($ v ) { return isset ($ v ['buses ' ]) && \count ($ v ['buses ' ]) > 1 && null === $ v ['default_bus ' ]; })
1115
+ ->thenInvalid ('You must specify the "default_bus" if you define more than one bus. ' )
1116
+ ->end ()
1113
1117
->children ()
1114
1118
->arrayNode ('routing ' )
1115
1119
->useAttributeAsKey ('message_class ' )
Original file line number Diff line number Diff line change @@ -188,6 +188,31 @@ public function provideInvalidAssetConfigurationTests()
188
188
yield [$ createPackageConfig ($ config ), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages. ' ];
189
189
}
190
190
191
+ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus ()
192
+ {
193
+ $ expectedMessage = 'You must specify the "default_bus" if you define more than one bus. ' ;
194
+ if (method_exists ($ this , 'expectException ' )) {
195
+ $ this ->expectException (InvalidConfigurationException::class);
196
+ $ this ->expectExceptionMessage ($ expectedMessage );
197
+ } else {
198
+ $ this ->setExpectedException (InvalidConfigurationException::class, $ expectedMessage );
199
+ }
200
+ $ processor = new Processor ();
201
+ $ configuration = new Configuration (true );
202
+
203
+ $ processor ->processConfiguration ($ configuration , [
204
+ 'framework ' => [
205
+ 'messenger ' => [
206
+ 'default_bus ' => null ,
207
+ 'buses ' => [
208
+ 'first_bus ' => [],
209
+ 'second_bus ' => [],
210
+ ],
211
+ ],
212
+ ],
213
+ ]);
214
+ }
215
+
191
216
protected static function getBundleDefaultConfig ()
192
217
{
193
218
return [
You can’t perform that action at this time.
0 commit comments