Skip to content

Commit 463e347

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: fix typo in PULL_REQUEST_TEMPLATE.md Allow to disable lock without defining a resource [HttpFoundation] Compare cookie with null value as empty string in ResponseCookieValueSame
2 parents d402e86 + e6df8bc commit 463e347

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,12 +1266,15 @@ private function addLockSection(ArrayNodeDefinition $rootNode, callable $enableI
12661266
})
12671267
->end()
12681268
->addDefaultsIfNotSet()
1269+
->validate()
1270+
->ifTrue(static function (array $config) { return $config['enabled'] && !$config['resources']; })
1271+
->thenInvalid('At least one resource must be defined.')
1272+
->end()
12691273
->fixXmlConfig('resource')
12701274
->children()
12711275
->arrayNode('resources')
12721276
->normalizeKeys(false)
12731277
->useAttributeAsKey('name')
1274-
->requiresAtLeastOneElement()
12751278
->defaultValue(['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']])
12761279
->beforeNormalization()
12771280
->ifString()->then(function ($v) { return ['default' => $v]; })

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,31 @@ public function testItErrorsWhenDefaultBusDoesNotExist()
427427
]);
428428
}
429429

430+
public function testLockCanBeDisabled()
431+
{
432+
$processor = new Processor();
433+
$configuration = new Configuration(true);
434+
435+
$config = $processor->processConfiguration($configuration, [
436+
['lock' => ['enabled' => false]],
437+
]);
438+
439+
$this->assertFalse($config['lock']['enabled']);
440+
}
441+
442+
public function testEnabledLockNeedsResources()
443+
{
444+
$processor = new Processor();
445+
$configuration = new Configuration(true);
446+
447+
$this->expectException(InvalidConfigurationException::class);
448+
$this->expectExceptionMessage('Invalid configuration for path "framework.lock": At least one resource must be defined.');
449+
450+
$processor->processConfiguration($configuration, [
451+
['lock' => ['enabled' => true]],
452+
]);
453+
}
454+
430455
protected static function getBundleDefaultConfig()
431456
{
432457
return [

0 commit comments

Comments
 (0)