Merge branch '4.4' into 5.1
* 4.4: [Sendgrid-Mailer] Fixed envelope recipients on sendgridApiTransport mark the AssertingContextualValidator class as internal Fix the parameter names in the SecurityFactoryInterface::create() method [Serializer][ClassDiscriminatorMapping] Fix getMappedObjectType() when a discriminator child extends another one make return type correct
This commit is contained in:
commit
44caccbac8
@ -29,7 +29,7 @@ interface SecurityFactoryInterface
|
||||
* - the listener id
|
||||
* - the entry point id
|
||||
*/
|
||||
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint);
|
||||
public function create(ContainerBuilder $container, string $id, array $config, string $userProviderId, ?string $defaultEntryPointId);
|
||||
|
||||
/**
|
||||
* Defines the position at which the provider is called.
|
||||
|
@ -148,7 +148,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Returns an iterator to iterate over children (implements \IteratorAggregate).
|
||||
*
|
||||
* @return \ArrayIterator|FormView[] The iterator
|
||||
* @return \ArrayIterator<string, FormView> The iterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
|
@ -192,4 +192,34 @@ class SendgridApiTransportTest extends TestCase
|
||||
$this->assertArrayHasKey('email', $payload['reply_to']);
|
||||
$this->assertSame($replyTo, $payload['reply_to']['email']);
|
||||
}
|
||||
|
||||
public function testEnvelopeSenderAndRecipients()
|
||||
{
|
||||
$from = 'from@example.com';
|
||||
$to = 'to@example.com';
|
||||
$envelopeFrom = 'envelopefrom@example.com';
|
||||
$envelopeTo = 'envelopeto@example.com';
|
||||
$email = new Email();
|
||||
$email->from($from)
|
||||
->to($to)
|
||||
->cc('cc@example.com')
|
||||
->bcc('bcc@example.com')
|
||||
->text('content');
|
||||
$envelope = new Envelope(new Address($envelopeFrom), [new Address($envelopeTo)]);
|
||||
|
||||
$transport = new SendgridApiTransport('ACCESS_KEY');
|
||||
$method = new \ReflectionMethod(SendgridApiTransport::class, 'getPayload');
|
||||
$method->setAccessible(true);
|
||||
$payload = $method->invoke($transport, $email, $envelope);
|
||||
|
||||
$this->assertArrayHasKey('from', $payload);
|
||||
$this->assertArrayHasKey('email', $payload['from']);
|
||||
$this->assertSame($envelopeFrom, $payload['from']['email']);
|
||||
|
||||
$this->assertArrayHasKey('personalizations', $payload);
|
||||
$this->assertArrayHasKey('to', $payload['personalizations'][0]);
|
||||
$this->assertArrayHasKey('email', $payload['personalizations'][0]['to'][0]);
|
||||
$this->assertCount(1, $payload['personalizations'][0]['to']);
|
||||
$this->assertSame($envelopeTo, $payload['personalizations'][0]['to'][0]['email']);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class SendgridApiTransport extends AbstractApiTransport
|
||||
}
|
||||
|
||||
$personalization = [
|
||||
'to' => array_map($addressStringifier, $email->getTo()),
|
||||
'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)),
|
||||
'subject' => $email->getSubject(),
|
||||
];
|
||||
if ($emails = array_map($addressStringifier, $email->getCc())) {
|
||||
|
@ -23,6 +23,18 @@ class ClassDiscriminatorMapping
|
||||
{
|
||||
$this->typeProperty = $typeProperty;
|
||||
$this->typesMapping = $typesMapping;
|
||||
|
||||
uasort($this->typesMapping, static function (string $a, string $b): int {
|
||||
if (is_a($a, $b, true)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_a($b, $a, true)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
public function getTypeProperty(): string
|
||||
|
@ -16,7 +16,8 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
/**
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "first"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild",
|
||||
* "second"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild"
|
||||
* "second"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild",
|
||||
* "third"="Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild",
|
||||
* })
|
||||
*/
|
||||
abstract class AbstractDummy
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Tests\Fixtures;
|
||||
|
||||
final class AbstractDummyThirdChild extends AbstractDummyFirstChild
|
||||
{
|
||||
}
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild;
|
||||
|
||||
/**
|
||||
* @author Samuel Roze <samuel.roze@gmail.com>
|
||||
@ -35,9 +36,11 @@ class ClassDiscriminatorMappingTest extends TestCase
|
||||
{
|
||||
$mapping = new ClassDiscriminatorMapping('type', [
|
||||
'first' => AbstractDummyFirstChild::class,
|
||||
'third' => AbstractDummyThirdChild::class,
|
||||
]);
|
||||
|
||||
$this->assertEquals('first', $mapping->getMappedObjectType(new AbstractDummyFirstChild()));
|
||||
$this->assertNull($mapping->getMappedObjectType(new AbstractDummySecondChild()));
|
||||
$this->assertSame('third', $mapping->getMappedObjectType(new AbstractDummyThirdChild()));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummy;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyFirstChild;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummySecondChild;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\IgnoreDummy;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\AbstractDummyThirdChild;
|
||||
use Symfony\Component\Serializer\Tests\Mapping\TestClassMetadataFactory;
|
||||
|
||||
/**
|
||||
@ -66,6 +67,7 @@ class AnnotationLoaderTest extends TestCase
|
||||
$expected = new ClassMetadata(AbstractDummy::class, new ClassDiscriminatorMapping('type', [
|
||||
'first' => AbstractDummyFirstChild::class,
|
||||
'second' => AbstractDummySecondChild::class,
|
||||
'third' => AbstractDummyThirdChild::class,
|
||||
]));
|
||||
|
||||
$expected->addAttributeMetadata(new AttributeMetadata('foo'));
|
||||
|
@ -385,6 +385,9 @@ class ConstraintViolationAssertion
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AssertingContextualValidator implements ContextualValidatorInterface
|
||||
{
|
||||
private $context;
|
||||
|
Reference in New Issue
Block a user