|
13 | 13 |
|
14 | 14 | use Doctrine\DBAL\Connection;
|
15 | 15 | use PHPUnit\Framework\TestCase;
|
| 16 | +use Seld\JsonLint\JsonParser; |
16 | 17 | use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
17 | 18 | use Symfony\Bundle\FullStack;
|
18 | 19 | use Symfony\Component\Cache\Adapter\DoctrineAdapter;
|
@@ -566,6 +567,63 @@ public function testEnabledLockNeedsResources()
|
566 | 567 | ]);
|
567 | 568 | }
|
568 | 569 |
|
| 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 | + |
569 | 627 | protected static function getBundleDefaultConfig()
|
570 | 628 | {
|
571 | 629 | return [
|
|
0 commit comments