File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Tests/DependencyInjection Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -1117,12 +1117,15 @@ private function addLockSection(ArrayNodeDefinition $rootNode)
11171117 })
11181118 ->end ()
11191119 ->addDefaultsIfNotSet ()
1120+ ->validate ()
1121+ ->ifTrue (static function (array $ config ) { return $ config ['enabled ' ] && !$ config ['resources ' ]; })
1122+ ->thenInvalid ('At least one resource must be defined. ' )
1123+ ->end ()
11201124 ->fixXmlConfig ('resource ' )
11211125 ->children ()
11221126 ->arrayNode ('resources ' )
11231127 ->normalizeKeys (false )
11241128 ->useAttributeAsKey ('name ' )
1125- ->requiresAtLeastOneElement ()
11261129 ->defaultValue (['default ' => [class_exists (SemaphoreStore::class) && SemaphoreStore::isSupported () ? 'semaphore ' : 'flock ' ]])
11271130 ->beforeNormalization ()
11281131 ->ifString ()->then (function ($ v ) { return ['default ' => $ v ]; })
Original file line number Diff line number Diff line change @@ -378,6 +378,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
378378 ]);
379379 }
380380
381+ public function testLockCanBeDisabled ()
382+ {
383+ $ processor = new Processor ();
384+ $ configuration = new Configuration (true );
385+
386+ $ config = $ processor ->processConfiguration ($ configuration , [
387+ ['lock ' => ['enabled ' => false ]],
388+ ]);
389+
390+ $ this ->assertFalse ($ config ['lock ' ]['enabled ' ]);
391+ }
392+
393+ public function testEnabledLockNeedsResources ()
394+ {
395+ $ processor = new Processor ();
396+ $ configuration = new Configuration (true );
397+
398+ $ this ->expectException (InvalidConfigurationException::class);
399+ $ this ->expectExceptionMessage ('Invalid configuration for path "framework.lock": At least one resource must be defined. ' );
400+
401+ $ processor ->processConfiguration ($ configuration , [
402+ ['lock ' => ['enabled ' => true ]],
403+ ]);
404+ }
405+
381406 protected static function getBundleDefaultConfig ()
382407 {
383408 return [
You can’t perform that action at this time.
0 commit comments