Skip to content

Commit 86980cd

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: fix tests fix merge fix typo Change ProxyCacheWarmer::warmUp signature CS fix [Serializer] Keep stack trace for enum value denormalizer error add the MailPace transport to the UnsupportedSchemeException add the Phrase translation provider to the UnsupportedSchemeException [Serializer] Fix partial denormalization with missing constructor arguments [Serializer] Moves dummy to fixtures folder [HttpKernel] Don't validate partially denormalized object fix(mailjet-smtp): disable tls for mailjet as it should use starttls instead
2 parents 4b4ce51 + 40ccb82 commit 86980cd

File tree

18 files changed

+161
-28
lines changed

18 files changed

+161
-28
lines changed

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CHANGELOG
1717
6.4
1818
---
1919

20+
* [BC BREAK] Add argument `$buildDir` to `ProxyCacheWarmer::warmUp()`
2021
* [BC BREAK] Add return type-hints to `EntityFactory`
2122
* Deprecate `DbalLogger`, use a middleware instead
2223
* Deprecate not constructing `DoctrineDataCollector` with an instance of `DebugDataHolder`

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/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: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,11 @@ public function testWithoutValidatorAndCouldNotDenormalize()
227227
public function testValidationNotPassed()
228228
{
229229
$content = '{"price": 50, "title": ["not a string"]}';
230-
$payload = new RequestPayload(50);
231230
$serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]);
232231

233232
$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, '')]));
233+
$validator->expects($this->never())
234+
->method('validate');
238235

239236
$resolver = new RequestPayloadValueResolver($serializer, $validator);
240237

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

@@ -639,14 +665,11 @@ public function testQueryValidationErrorCustomStatusCode()
639665
public function testRequestPayloadValidationErrorCustomStatusCode()
640666
{
641667
$content = '{"price": 50, "title": ["not a string"]}';
642-
$payload = new RequestPayload(50);
643668
$serializer = new Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()]);
644669

645670
$validator = $this->createMock(ValidatorInterface::class);
646-
$validator->expects($this->once())
647-
->method('validate')
648-
->with($payload)
649-
->willReturn(new ConstraintViolationList([new ConstraintViolation('Test', null, [], '', null, '')]));
671+
$validator->expects($this->never())
672+
->method('validate');
650673

651674
$resolver = new RequestPayloadValueResolver($serializer, $validator);
652675

@@ -667,7 +690,6 @@ public function testRequestPayloadValidationErrorCustomStatusCode()
667690
$this->assertSame(400, $e->getStatusCode());
668691
$this->assertInstanceOf(ValidationFailedException::class, $validationFailedException);
669692
$this->assertSame('This value should be of type string.', $validationFailedException->getViolations()[0]->getMessage());
670-
$this->assertSame('Test', $validationFailedException->getViolations()[1]->getMessage());
671693
}
672694
}
673695
}
@@ -688,3 +710,24 @@ public function __construct(public readonly float $page)
688710
{
689711
}
690712
}
713+
714+
class User
715+
{
716+
public function __construct(
717+
#[Assert\NotBlank, Assert\Email]
718+
private string $email,
719+
#[Assert\NotBlank]
720+
private string $password,
721+
) {
722+
}
723+
724+
public function getEmail(): string
725+
{
726+
return $this->email;
727+
}
728+
729+
public function getPassword(): string
730+
{
731+
return $this->password;
732+
}
733+
}

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/Bridge/Mailjet/Transport/MailjetSmtpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MailjetSmtpTransport extends EsmtpTransport
1919
{
2020
public function __construct(string $username, #[\SensitiveParameter] string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
2121
{
22-
parent::__construct('in-v3.mailjet.com', 587, true, $dispatcher, $logger);
22+
parent::__construct('in-v3.mailjet.com', 587, false, $dispatcher, $logger);
2323

2424
$this->setUsername($username);
2525
$this->setPassword($password);

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\Postmark\Transport\PostmarkTransportFactory;
2526
use Symfony\Component\Mailer\Bridge\Scaleway\Transport\ScalewayTransportFactory;
2627
use Symfony\Component\Mailer\Bridge\Sendgrid\Transport\SendgridTransportFactory;
@@ -42,6 +43,7 @@ public static function setUpBeforeClass(): void
4243
MailerSendTransportFactory::class => false,
4344
MailgunTransportFactory::class => false,
4445
MailjetTransportFactory::class => false,
46+
MailPaceTransportFactory::class => false,
4547
MandrillTransportFactory::class => false,
4648
PostmarkTransportFactory::class => false,
4749
ScalewayTransportFactory::class => false,
@@ -71,6 +73,7 @@ public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \
7173
yield ['mailersend', 'symfony/mailersend-mailer'];
7274
yield ['mailgun', 'symfony/mailgun-mailer'];
7375
yield ['mailjet', 'symfony/mailjet-mailer'];
76+
yield ['mailpace', 'symfony/mail-pace-mailer'];
7477
yield ['mandrill', 'symfony/mailchimp-mailer'];
7578
yield ['postmark', 'symfony/postmark-mailer'];
7679
yield ['scaleway', 'symfony/scaleway-mailer'];

0 commit comments

Comments
 (0)