Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [FrameworkBundle] Fix mailer config with XML
  • Loading branch information
lyrixx committed Mar 15, 2024
2 parents 71c441e + 322b40a commit 044c21b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2199,6 +2199,7 @@ private function addMailerSection(ArrayNodeDefinition $rootNode, callable $enabl
->end()
->arrayNode('envelope')
->info('Mailer Envelope configuration')
->fixXmlConfig('recipient')
->children()
->scalarNode('sender')->end()
->arrayNode('recipients')
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/schema/symfony-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@
<xsd:complexType name="mailer_envelope">
<xsd:sequence>
<xsd:element name="sender" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="recipients" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="recipient" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>

Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'dsn' => 'smtp://example.com',
'envelope' => [
'sender' => '[email protected]',
'recipients' => ['[email protected]', '[email protected]'],
'recipients' => ['[email protected]'],
],
'headers' => [
'from' => '[email protected]',
Expand Down
3 changes: 1 addition & 2 deletions Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<framework:mailer dsn="smtp://example.com">
<framework:envelope>
<framework:sender>[email protected]</framework:sender>
<framework:recipients>[email protected]</framework:recipients>
<framework:recipients>[email protected]</framework:recipients>
<framework:recipient>[email protected]</framework:recipient>
</framework:envelope>
<framework:header name="from">[email protected]</framework:header>
<framework:header name="bcc">[email protected]</framework:header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<framework:transport name="transport2">smtp://example2.com</framework:transport>
<framework:envelope>
<framework:sender>[email protected]</framework:sender>
<framework:recipients>[email protected]</framework:recipients>
<framework:recipients>[email protected]</framework:recipients>
<framework:recipient>[email protected]</framework:recipient>
<framework:recipient>[email protected]</framework:recipient>
</framework:envelope>
<framework:header name="from">[email protected]</framework:header>
<framework:header name="bcc">[email protected]</framework:header>
Expand Down
1 change: 0 additions & 1 deletion Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ framework:
sender: [email protected]
recipients:
- [email protected]
- [email protected]
headers:
from: [email protected]
bcc: [[email protected], [email protected]]
Expand Down
22 changes: 14 additions & 8 deletions Tests/DependencyInjection/FrameworkExtensionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function testWorkflows()
$this->assertSame('state_machine.pull_request.metadata_store', (string) $metadataStoreReference);

$metadataStoreDefinition = $container->getDefinition('state_machine.pull_request.metadata_store');
$this->assertSame(Workflow\Metadata\InMemoryMetadataStore::class, $metadataStoreDefinition->getClass());
$this->assertSame(InMemoryMetadataStore::class, $metadataStoreDefinition->getClass());
$this->assertSame(InMemoryMetadataStore::class, $metadataStoreDefinition->getClass());

$workflowMetadata = $metadataStoreDefinition->getArgument(0);
Expand Down Expand Up @@ -2056,21 +2056,27 @@ public function testHttpClientFullDefaultOptions()
$this->assertSame(['foo' => ['bar' => 'baz']], $defaultOptions['extra']);
}

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

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

Expand All @@ -2082,7 +2088,7 @@ public function testMailer(string $configFile, array $expectedTransports)
$this->assertTrue($container->hasDefinition('mailer.envelope_listener'));
$l = $container->getDefinition('mailer.envelope_listener');
$this->assertSame('[email protected]', $l->getArgument(0));
$this->assertSame(['[email protected]', '[email protected]'], $l->getArgument(1));
$this->assertSame($expectedRecipients, $l->getArgument(1));
$this->assertEquals(new Reference('messenger.default_bus', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('mailer.mailer')->getArgument(1));

$this->assertTrue($container->hasDefinition('mailer.message_listener'));
Expand Down

0 comments on commit 044c21b

Please sign in to comment.