Skip to content

Commit 14562c0

Browse files
Merge branch '7.0' into 7.1
* 7.0: [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling [Translation] Fix CSV escape char in `CsvFileLoader` on PHP >= 7.4 [DoctrineBridge] fix messenger bus dispatch inside an active transaction [HttpFoundation] Add tests for uncovered sections treat uninitialized properties referenced by property paths as null properly set up constraint options [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations move adding detailed JSON error messages to the validate phase [Profiler] Add word wrap in tables in dialog to see all the text [Core] Fix & Enhance security arabic translation. [HttpFoundation] Add tests for `MethodRequestMatcher` and `SchemeRequestMatcher`
2 parents 9c6a443 + bad7b25 commit 14562c0

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,8 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
11181118
->end()
11191119
->arrayNode('default_context')
11201120
->normalizeKeys(false)
1121-
->beforeNormalization()
1121+
->useAttributeAsKey('name')
1122+
->validate()
11221123
->ifTrue(fn () => $this->debug && class_exists(JsonParser::class))
11231124
->then(fn (array $v) => $v + [JsonDecode::DETAILED_ERROR_MESSAGES => true])
11241125
->end()

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\DBAL\Connection;
1515
use PHPUnit\Framework\TestCase;
16+
use Seld\JsonLint\JsonParser;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
1718
use Symfony\Bundle\FullStack;
1819
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
@@ -567,6 +568,63 @@ public function testEnabledLockNeedsResources()
567568
]);
568569
}
569570

571+
public function testSerializerJsonDetailedErrorMessagesEnabledWhenDefaultContextIsConfigured()
572+
{
573+
$processor = new Processor();
574+
$config = $processor->processConfiguration(new Configuration(true), [
575+
[
576+
'serializer' => [
577+
'default_context' => [
578+
'foo' => 'bar',
579+
],
580+
],
581+
],
582+
]);
583+
584+
$this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => true], $config['serializer']['default_context'] ?? []);
585+
}
586+
587+
public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisabled()
588+
{
589+
$processor = new Processor();
590+
$config = $processor->processConfiguration(new Configuration(true), [
591+
[
592+
'serializer' => [
593+
'default_context' => [
594+
'foo' => 'bar',
595+
JsonDecode::DETAILED_ERROR_MESSAGES => false,
596+
],
597+
],
598+
],
599+
]);
600+
601+
$this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => false], $config['serializer']['default_context'] ?? []);
602+
}
603+
604+
public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisabledWithSeveralConfigsBeingMerged()
605+
{
606+
$processor = new Processor();
607+
$config = $processor->processConfiguration(new Configuration(true), [
608+
[
609+
'serializer' => [
610+
'default_context' => [
611+
'foo' => 'bar',
612+
JsonDecode::DETAILED_ERROR_MESSAGES => false,
613+
],
614+
],
615+
],
616+
[
617+
'serializer' => [
618+
'default_context' => [
619+
'foobar' => 'baz',
620+
],
621+
],
622+
],
623+
]);
624+
625+
$this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => false, 'foobar' => 'baz'], $config['serializer']['default_context'] ?? []);
626+
}
627+
570628
public function testScopedHttpClientsInheritRateLimiterAndRetryFailedConfiguration()
571629
{
572630
$processor = new Processor();

0 commit comments

Comments
 (0)