File tree 2 files changed +29
-1
lines changed
Tests/DependencyInjection
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)
1117
1117
})
1118
1118
->end ()
1119
1119
->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 ()
1120
1124
->fixXmlConfig ('resource ' )
1121
1125
->children ()
1122
1126
->arrayNode ('resources ' )
1123
1127
->normalizeKeys (false )
1124
1128
->useAttributeAsKey ('name ' )
1125
- ->requiresAtLeastOneElement ()
1126
1129
->defaultValue (['default ' => [class_exists (SemaphoreStore::class) && SemaphoreStore::isSupported () ? 'semaphore ' : 'flock ' ]])
1127
1130
->beforeNormalization ()
1128
1131
->ifString ()->then (function ($ v ) { return ['default ' => $ v ]; })
Original file line number Diff line number Diff line change @@ -378,6 +378,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
378
378
]);
379
379
}
380
380
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
+
381
406
protected static function getBundleDefaultConfig ()
382
407
{
383
408
return [
You can’t perform that action at this time.
0 commit comments