Skip to content

Commit 9f9ae65

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: fix typo CS fix [Serializer] Keep stack trace for enum value denormalizer error add the MailPace transport to the UnsupportedSchemeException [Serializer] Fix partial denormalization with missing constructor arguments [Serializer] Moves dummy to fixtures folder [HttpKernel] Don't validate partially denormalized object
2 parents de3b253 + 6b0fbfb commit 9f9ae65

File tree

16 files changed

+152
-24
lines changed

16 files changed

+152
-24
lines changed

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private static function removeDir($dir)
265265
rmdir($dir);
266266
}
267267

268-
public static function setupBeforeClass(): void
268+
public static function setUpBeforeClass(): void
269269
{
270270
foreach (get_declared_classes() as $class) {
271271
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function testFirewalls()
243243
],
244244
], $listeners);
245245

246-
$this->assertFalse($container->hasAlias(UserCheckerInterface::class, 'No user checker alias is registered when custom user checker services are registered'));
246+
$this->assertFalse($container->hasAlias(UserCheckerInterface::class), 'No user checker alias is registered when custom user checker services are registered');
247247
}
248248

249249
public function testFirewallRequestMatchers()

src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CouchbaseBucketAdapterTest extends AdapterTestCase
3131

3232
protected static \CouchbaseBucket $client;
3333

34-
public static function setupBeforeClass(): void
34+
public static function setUpBeforeClass(): void
3535
{
3636
if (!CouchbaseBucketAdapter::isSupported()) {
3737
self::markTestSkipped('Couchbase >= 2.6.0 < 3.0.0 is required.');

src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CouchbaseCollectionAdapterTest extends AdapterTestCase
3232

3333
protected static Collection $client;
3434

35-
public static function setupBeforeClass(): void
35+
public static function setUpBeforeClass(): void
3636
{
3737
if (!CouchbaseCollectionAdapter::isSupported()) {
3838
self::markTestSkipped('Couchbase >= 3.0.0 < 4.0.0 is required.');

src/Symfony/Component/Cache/Tests/Adapter/RedisArrayAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RedisArrayAdapterTest extends AbstractRedisAdapterTestCase
1818
{
1919
public static function setUpBeforeClass(): void
2020
{
21-
parent::setupBeforeClass();
21+
parent::setUpBeforeClass();
2222
if (!class_exists(\RedisArray::class)) {
2323
self::markTestSkipped('The RedisArray class is required.');
2424
}

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo
119119
$payload = $e->getData();
120120
}
121121

122-
if (null !== $payload) {
122+
if (null !== $payload && !\count($violations)) {
123123
$violations->addAll($this->validator->validate($payload, null, $argument->validationGroups ?? null));
124124
}
125125

src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/RequestPayloadValueResolverTest.php

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2929
use Symfony\Component\Serializer\Serializer;
3030
use Symfony\Component\Validator\Constraints as Assert;
31-
use Symfony\Component\Validator\ConstraintViolation;
3231
use Symfony\Component\Validator\ConstraintViolationList;
3332
use Symfony\Component\Validator\Exception\ValidationFailedException;
3433
use Symfony\Component\Validator\Validator\ValidatorInterface;
@@ -227,14 +226,11 @@ public function testWithoutValidatorAndCouldNotDenormalize()
227226
public function testValidationNotPassed()
228227
{
229228
$content = '{"price": 50, "title": ["not a string"]}';
230-
$payload = new RequestPayload(50);
231229
$serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]);
232230

233231
$validator = $this->createMock(ValidatorInterface::class);
234-
$validator->expects($this->once())
235-
->method('validate')
236-
->with($payload)
237-
->willReturn(new ConstraintViolationList([new ConstraintViolation('Test', null, [], '', null, '')]));
232+
$validator->expects($this->never())
233+
->method('validate');
238234

239235
$resolver = new RequestPayloadValueResolver($serializer, $validator);
240236

@@ -255,7 +251,36 @@ public function testValidationNotPassed()
255251
$this->assertSame(422, $e->getStatusCode());
256252
$this->assertInstanceOf(ValidationFailedException::class, $validationFailedException);
257253
$this->assertSame(sprintf('This value should be of type %s.', class_exists(InvalidTypeException::class) ? 'string' : 'unknown'), $validationFailedException->getViolations()[0]->getMessage());
258-
$this->assertSame('Test', $validationFailedException->getViolations()[1]->getMessage());
254+
}
255+
}
256+
257+
public function testValidationNotPerformedWhenPartialDenormalizationReturnsViolation()
258+
{
259+
$content = '{"password": "abc"}';
260+
$serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]);
261+
262+
$validator = $this->createMock(ValidatorInterface::class);
263+
$validator->expects($this->never())
264+
->method('validate');
265+
266+
$resolver = new RequestPayloadValueResolver($serializer, $validator);
267+
268+
$argument = new ArgumentMetadata('invalid', User::class, false, false, null, false, [
269+
MapRequestPayload::class => new MapRequestPayload(),
270+
]);
271+
$request = Request::create('/', 'POST', server: ['CONTENT_TYPE' => 'application/json'], content: $content);
272+
273+
$kernel = $this->createMock(HttpKernelInterface::class);
274+
$arguments = $resolver->resolve($request, $argument);
275+
$event = new ControllerArgumentsEvent($kernel, function () {}, $arguments, $request, HttpKernelInterface::MAIN_REQUEST);
276+
277+
try {
278+
$resolver->onKernelControllerArguments($event);
279+
$this->fail(sprintf('Expected "%s" to be thrown.', HttpException::class));
280+
} catch (HttpException $e) {
281+
$validationFailedException = $e->getPrevious();
282+
$this->assertInstanceOf(ValidationFailedException::class, $validationFailedException);
283+
$this->assertSame('This value should be of type unknown.', $validationFailedException->getViolations()[0]->getMessage());
259284
}
260285
}
261286

@@ -688,3 +713,24 @@ public function __construct(public readonly float $page)
688713
{
689714
}
690715
}
716+
717+
class User
718+
{
719+
public function __construct(
720+
#[Assert\NotBlank, Assert\Email]
721+
private string $email,
722+
#[Assert\NotBlank]
723+
private string $password,
724+
) {
725+
}
726+
727+
public function getEmail(): string
728+
{
729+
return $this->email;
730+
}
731+
732+
public function getPassword(): string
733+
{
734+
return $this->password;
735+
}
736+
}

src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MongoDbStoreTest extends AbstractStoreTestCase
3535
{
3636
use ExpiringStoreTestTrait;
3737

38-
public static function setupBeforeClass(): void
38+
public static function setUpBeforeClass(): void
3939
{
4040
$manager = self::getMongoManager();
4141
try {

src/Symfony/Component/Mailer/Exception/UnsupportedSchemeException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class UnsupportedSchemeException extends LogicException
4444
'class' => Bridge\Mailjet\Transport\MailjetTransportFactory::class,
4545
'package' => 'symfony/mailjet-mailer',
4646
],
47+
'mailpace' => [
48+
'class' => Bridge\MailPace\Transport\MailPaceTransportFactory::class,
49+
'package' => 'symfony/mail-pace-mailer',
50+
],
4751
'mandrill' => [
4852
'class' => Bridge\Mailchimp\Transport\MandrillTransportFactory::class,
4953
'package' => 'symfony/mailchimp-mailer',

src/Symfony/Component/Mailer/Tests/Exception/UnsupportedSchemeExceptionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Mailer\Bridge\MailerSend\Transport\MailerSendTransportFactory;
2222
use Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory;
2323
use Symfony\Component\Mailer\Bridge\Mailjet\Transport\MailjetTransportFactory;
24+
use Symfony\Component\Mailer\Bridge\MailPace\Transport\MailPaceTransportFactory;
2425
use Symfony\Component\Mailer\Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory;
2526
use Symfony\Component\Mailer\Bridge\Postmark\Transport\PostmarkTransportFactory;
2627
use Symfony\Component\Mailer\Bridge\Scaleway\Transport\ScalewayTransportFactory;
@@ -44,6 +45,7 @@ public static function setUpBeforeClass(): void
4445
MailerSendTransportFactory::class => false,
4546
MailgunTransportFactory::class => false,
4647
MailjetTransportFactory::class => false,
48+
MailPaceTransportFactory::class => false,
4749
MandrillTransportFactory::class => false,
4850
OhMySmtpTransportFactory::class => false,
4951
PostmarkTransportFactory::class => false,
@@ -75,6 +77,7 @@ public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \
7577
yield ['mailersend', 'symfony/mailersend-mailer'];
7678
yield ['mailgun', 'symfony/mailgun-mailer'];
7779
yield ['mailjet', 'symfony/mailjet-mailer'];
80+
yield ['mailpace', 'symfony/mail-pace-mailer'];
7881
yield ['mandrill', 'symfony/mailchimp-mailer'];
7982
yield ['ohmysmtp', 'symfony/oh-my-smtp-mailer'];
8083
yield ['postmark', 'symfony/postmark-mailer'];

0 commit comments

Comments
 (0)