Fix config merging in lock
This commit is contained in:
parent
841ec99831
commit
6bb2d67cf1
@ -1122,6 +1122,8 @@ class Configuration implements ConfigurationInterface
|
|||||||
->fixXmlConfig('resource')
|
->fixXmlConfig('resource')
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('resources')
|
->arrayNode('resources')
|
||||||
|
->normalizeKeys(false)
|
||||||
|
->useAttributeAsKey('name')
|
||||||
->requiresAtLeastOneElement()
|
->requiresAtLeastOneElement()
|
||||||
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
|
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
@ -1144,6 +1146,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
})
|
})
|
||||||
->end()
|
->end()
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
|
->performNoDeepMerging()
|
||||||
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
|
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -250,6 +250,34 @@ class ConfigurationTest extends TestCase
|
|||||||
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLockMergeConfigs()
|
||||||
|
{
|
||||||
|
$processor = new Processor();
|
||||||
|
$configuration = new Configuration(true);
|
||||||
|
$config = $processor->processConfiguration($configuration, [
|
||||||
|
[
|
||||||
|
'lock' => [
|
||||||
|
'payload' => 'flock',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'lock' => [
|
||||||
|
'payload' => 'semaphore'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
[
|
||||||
|
'enabled' => true,
|
||||||
|
'resources' => [
|
||||||
|
'payload' => ['semaphore']
|
||||||
|
],
|
||||||
|
],
|
||||||
|
$config['lock']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus()
|
public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus()
|
||||||
{
|
{
|
||||||
$expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';
|
$expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';
|
||||||
|
Reference in New Issue
Block a user