[Messenger] Error when specified default bus is not among the configured
This commit is contained in:
parent
2743e259c6
commit
dd92d2bb10
@ -19,6 +19,7 @@ use Symfony\Component\Asset\Package;
|
||||
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;
|
||||
@ -1136,6 +1137,10 @@ class Configuration implements ConfigurationInterface
|
||||
->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)
|
||||
|
@ -271,6 +271,27 @@ class ConfigurationTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
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 [
|
||||
|
Reference in New Issue
Block a user