Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d628b75

Browse filesBrowse files
bug #57803 [FrameworkBundle] move adding detailed JSON error messages to the validate phase (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] move adding detailed JSON error messages to the validate phase | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #51215 (comment) | License | MIT Commits ------- b9258df move adding detailed JSON error messages to the validate phase
2 parents 39f16af + b9258df commit d628b75
Copy full SHA for d628b75

File tree

Expand file treeCollapse file tree

2 files changed

+59
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+59
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
11971197
->arrayNode('default_context')
11981198
->normalizeKeys(false)
11991199
->useAttributeAsKey('name')
1200-
->beforeNormalization()
1200+
->validate()
12011201
->ifTrue(fn () => $this->debug && class_exists(JsonParser::class))
12021202
->then(fn (array $v) => $v + [JsonDecode::DETAILED_ERROR_MESSAGES => true])
12031203
->end()

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+58Lines 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;
@@ -566,6 +567,63 @@ public function testEnabledLockNeedsResources()
566567
]);
567568
}
568569

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.