Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpClient\HttpClient;
Expand Down Expand Up @@ -1136,6 +1137,10 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode)
->ifTrue(function ($v) { return isset($v['buses']) && \count($v['buses']) > 1 && null === $v['default_bus']; })
->thenInvalid('You must specify the "default_bus" if you define more than one bus.')
->end()
->validate()
->ifTrue(static function ($v): bool { return isset($v['buses']) && null !== $v['default_bus'] && !isset($v['buses'][$v['default_bus']]); })
->then(static function (array $v): void { throw new InvalidConfigurationException(sprintf('The specified default bus "%s" is not configured. Available buses are "%s".', $v['default_bus'], implode('", "', array_keys($v['buses'])))); })
->end()
->children()
->arrayNode('routing')
->normalizeKeys(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefau
]);
}

public function testItErrorsWhenDefaultBusDoesNotExist()
{
$processor = new Processor();
$configuration = new Configuration(true);

$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('The specified default bus "foo" is not configured. Available buses are "bar", "baz".');

$processor->processConfiguration($configuration, [
[
'messenger' => [
'default_bus' => 'foo',
'buses' => [
'bar' => null,
'baz' => null,
],
],
],
]);
}

protected static function getBundleDefaultConfig()
{
return [
Expand Down