Skip to content

Commit

Permalink
bug #37849 [FrameworkBundle] Add missing mailer transports in xsd (l-vo)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Add missing mailer transports in xsd

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

c21df9b [FrameworkBundle] Add missing mailer transports in xsd
  • Loading branch information
fabpot committed Aug 17, 2020
2 parents d6b9936 + c21df9b commit 9d995bd
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 3 deletions.
Expand Up @@ -571,11 +571,16 @@

<xsd:complexType name="mailer">
<xsd:sequence>
<xsd:element name="transport" type="mailer_transport" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="envelope" type="mailer_envelope" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="dsn" type="xsd:string" />
</xsd:complexType>

<xsd:complexType name="mailer_transport" mixed="true">
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>

<xsd:complexType name="mailer_envelope">
<xsd:sequence>
<xsd:element name="sender" type="xsd:string" minOccurs="0" maxOccurs="1" />
Expand Down
@@ -0,0 +1,15 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$container->extension('framework', [
'mailer' => [
'dsn' => 'smtp://example.com',
'envelope' => [
'sender' => 'sender@example.org',
'recipients' => ['redirected@example.org', 'redirected1@example.org'],
],
],
]);
};
@@ -0,0 +1,18 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$container->extension('framework', [
'mailer' => [
'transports' => [
'transport1' => 'smtp://example1.com',
'transport2' => 'smtp://example2.com',
],
'envelope' => [
'sender' => 'sender@example.org',
'recipients' => ['redirected@example.org', 'redirected1@example.org'],
],
],
]);
};
@@ -0,0 +1,20 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:mailer>
<framework:transport name="transport1">smtp://example1.com</framework:transport>
<framework:transport name="transport2">smtp://example2.com</framework:transport>
<framework:envelope>
<framework:sender>sender@example.org</framework:sender>
<framework:recipients>redirected@example.org</framework:recipients>
<framework:recipients>redirected1@example.org</framework:recipients>
</framework:envelope>
</framework:mailer>
</framework:config>
</container>
@@ -0,0 +1,10 @@
framework:
mailer:
transports:
transport1: 'smtp://example1.com'
transport2: 'smtp://example2.com'
envelope:
sender: sender@example.org
recipients:
- redirected@example.org
- redirected1@example.org
Expand Up @@ -1617,13 +1617,29 @@ public function testHttpClientFullDefaultOptions()
], $defaultOptions['peer_fingerprint']);
}

public function testMailer(): void
public function provideMailer(): array
{
return [
['mailer_with_dsn', ['main' => 'smtp://example.com']],
['mailer_with_transports', [
'transport1' => 'smtp://example1.com',
'transport2' => 'smtp://example2.com',
]],
];
}

/**
* @dataProvider provideMailer
*/
public function testMailer(string $configFile, array $expectedTransports): void
{
$container = $this->createContainerFromFile('mailer');
$container = $this->createContainerFromFile($configFile);

$this->assertTrue($container->hasAlias('mailer'));
$this->assertTrue($container->hasDefinition('mailer.transports'));
$this->assertSame($expectedTransports, $container->getDefinition('mailer.transports')->getArgument(0));
$this->assertTrue($container->hasDefinition('mailer.default_transport'));
$this->assertSame('smtp://example.com', $container->getDefinition('mailer.default_transport')->getArgument(0));
$this->assertSame(current($expectedTransports), $container->getDefinition('mailer.default_transport')->getArgument(0));
$this->assertTrue($container->hasDefinition('mailer.envelope_listener'));
$l = $container->getDefinition('mailer.envelope_listener');
$this->assertSame('sender@example.org', $l->getArgument(0));
Expand Down

0 comments on commit 9d995bd

Please sign in to comment.