Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
nicolas-grekas committed Jul 26, 2024
2 parents 9c6a443 + bad7b25 commit 14562c0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,8 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
->end()
->arrayNode('default_context')
->normalizeKeys(false)
->beforeNormalization()
->useAttributeAsKey('name')
->validate()
->ifTrue(fn () => $this->debug && class_exists(JsonParser::class))
->then(fn (array $v) => $v + [JsonDecode::DETAILED_ERROR_MESSAGES => true])
->end()
Expand Down
58 changes: 58 additions & 0 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Doctrine\DBAL\Connection;
use PHPUnit\Framework\TestCase;
use Seld\JsonLint\JsonParser;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
use Symfony\Bundle\FullStack;
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
Expand Down Expand Up @@ -567,6 +568,63 @@ public function testEnabledLockNeedsResources()
]);
}

public function testSerializerJsonDetailedErrorMessagesEnabledWhenDefaultContextIsConfigured()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [
[
'serializer' => [
'default_context' => [
'foo' => 'bar',
],
],
],
]);

$this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => true], $config['serializer']['default_context'] ?? []);
}

public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisabled()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [
[
'serializer' => [
'default_context' => [
'foo' => 'bar',
JsonDecode::DETAILED_ERROR_MESSAGES => false,
],
],
],
]);

$this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => false], $config['serializer']['default_context'] ?? []);
}

public function testSerializerJsonDetailedErrorMessagesInDefaultContextCanBeDisabledWithSeveralConfigsBeingMerged()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [
[
'serializer' => [
'default_context' => [
'foo' => 'bar',
JsonDecode::DETAILED_ERROR_MESSAGES => false,
],
],
],
[
'serializer' => [
'default_context' => [
'foobar' => 'baz',
],
],
],
]);

$this->assertSame(['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => false, 'foobar' => 'baz'], $config['serializer']['default_context'] ?? []);
}

public function testScopedHttpClientsInheritRateLimiterAndRetryFailedConfiguration()
{
$processor = new Processor();
Expand Down

0 comments on commit 14562c0

Please sign in to comment.