Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb3ec06

Browse files
committed
bug #54292 [FrameworkBundle] Fix mailer config with XML (lyrixx)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Fix mailer config with XML | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT I noticed that, while adding test for #54044 --- Before my patch, if I keep only one recipients: ``` >…ome/gregoire/dev/github.com/lyrixx/symfony(5.4 *) git di diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml index be53f59..5ccdefaf32 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml @@ -11,7 +11,7 @@ <framework:envelope> <framework:sender>[email protected]</framework:sender> <framework:recipients>[email protected]</framework:recipients> - <framework:recipients>[email protected]</framework:recipients> + <!-- <framework:recipients>[email protected]</framework:recipients> --> </framework:envelope> <framework:header name="from">[email protected]</framework:header> <framework:header name="bcc">[email protected]</framework:header> >…ome/gregoire/dev/github.com/lyrixx/symfony(5.4 *) ./phpunit src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php --filter 'testMailer#0' PHPUnit 9.6.16 by Sebastian Bergmann and contributors. Warning: Your XML configuration validates against a deprecated schema. Suggestion: Migrate your XML configuration using "--migrate-configuration"! Testing Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\XmlFrameworkExtensionTest E 1 / 1 (100%)R Time: 00:00.103, Memory: 21.88 MB There was 1 error: 1) Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\XmlFrameworkExtensionTest::testMailer with data set #0 ('mailer_with_dsn', array('smtp://example.com')) Symfony\Component\Config\Definition\Exception\InvalidTypeException: Invalid type for path "framework.mailer.envelope.recipients". Expected "array", but got "string" ``` And I cannot add more XML configuration, without this patch Commits ------- 0cfdf2f [FrameworkBundle] Fix mailer config with XML
2 parents e05d922 + 0cfdf2f commit cb3ec06

File tree

8 files changed

+21
-17
lines changed

8 files changed

+21
-17
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode, callable $e
15591559
continue;
15601560
}
15611561
if (\is_array($scopedConfig['retry_failed'])) {
1562-
$scopedConfig['retry_failed'] = $scopedConfig['retry_failed'] + $config['default_options']['retry_failed'];
1562+
$scopedConfig['retry_failed'] += $config['default_options']['retry_failed'];
15631563
}
15641564
}
15651565

@@ -1897,6 +1897,7 @@ private function addMailerSection(ArrayNodeDefinition $rootNode, callable $enabl
18971897
->end()
18981898
->arrayNode('envelope')
18991899
->info('Mailer Envelope configuration')
1900+
->fixXmlConfig('recipient')
19001901
->children()
19011902
->scalarNode('sender')->end()
19021903
->arrayNode('recipients')

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@
703703
<xsd:complexType name="mailer_envelope">
704704
<xsd:sequence>
705705
<xsd:element name="sender" type="xsd:string" minOccurs="0" maxOccurs="1" />
706-
<xsd:element name="recipients" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
706+
<xsd:element name="recipient" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
707707
</xsd:sequence>
708708
</xsd:complexType>
709709

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'dsn' => 'smtp://example.com',
99
'envelope' => [
1010
'sender' => '[email protected]',
11-
'recipients' => ['[email protected]', '[email protected]'],
11+
'recipients' => ['[email protected]'],
1212
],
1313
'headers' => [
1414
'from' => '[email protected]',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
<framework:mailer dsn="smtp://example.com">
1111
<framework:envelope>
1212
<framework:sender>[email protected]</framework:sender>
13-
<framework:recipients>[email protected]</framework:recipients>
14-
<framework:recipients>[email protected]</framework:recipients>
13+
<framework:recipient>[email protected]</framework:recipient>
1514
</framework:envelope>
1615
<framework:header name="from">[email protected]</framework:header>
1716
<framework:header name="bcc">[email protected]</framework:header>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<framework:transport name="transport2">smtp://example2.com</framework:transport>
1313
<framework:envelope>
1414
<framework:sender>[email protected]</framework:sender>
15-
<framework:recipients>[email protected]</framework:recipients>
16-
<framework:recipients>[email protected]</framework:recipients>
15+
<framework:recipient>[email protected]</framework:recipient>
16+
<framework:recipient>[email protected]</framework:recipient>
1717
</framework:envelope>
1818
<framework:header name="from">[email protected]</framework:header>
1919
<framework:header name="bcc">[email protected]</framework:header>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer_with_dsn.yml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ framework:
55
66
recipients:
77
8-
98
headers:
109
1110

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public function testWorkflows()
318318
$this->assertSame('state_machine.pull_request.metadata_store', (string) $metadataStoreReference);
319319

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

324324
$workflowMetadata = $metadataStoreDefinition->getArgument(0);
@@ -1940,21 +1940,27 @@ public function testHttpClientFullDefaultOptions()
19401940
], $defaultOptions['peer_fingerprint']);
19411941
}
19421942

1943-
public static function provideMailer(): array
1943+
public static function provideMailer(): iterable
19441944
{
1945-
return [
1946-
['mailer_with_dsn', ['main' => 'smtp://example.com']],
1947-
['mailer_with_transports', [
1945+
yield [
1946+
'mailer_with_dsn',
1947+
['main' => 'smtp://example.com'],
1948+
1949+
];
1950+
yield [
1951+
'mailer_with_transports',
1952+
[
19481953
'transport1' => 'smtp://example1.com',
19491954
'transport2' => 'smtp://example2.com',
1950-
]],
1955+
],
1956+
19511957
];
19521958
}
19531959

19541960
/**
19551961
* @dataProvider provideMailer
19561962
*/
1957-
public function testMailer(string $configFile, array $expectedTransports)
1963+
public function testMailer(string $configFile, array $expectedTransports, array $expectedRecipients)
19581964
{
19591965
$container = $this->createContainerFromFile($configFile);
19601966

@@ -1966,7 +1972,7 @@ public function testMailer(string $configFile, array $expectedTransports)
19661972
$this->assertTrue($container->hasDefinition('mailer.envelope_listener'));
19671973
$l = $container->getDefinition('mailer.envelope_listener');
19681974
$this->assertSame('[email protected]', $l->getArgument(0));
1969-
$this->assertSame(['[email protected]', '[email protected]'], $l->getArgument(1));
1975+
$this->assertSame($expectedRecipients, $l->getArgument(1));
19701976
$this->assertEquals(new Reference('messenger.default_bus', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('mailer.mailer')->getArgument(1));
19711977

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

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Config\FileLocator;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
17-
use Symfony\Component\RateLimiter\Policy\SlidingWindowLimiter;
1817

1918
class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase
2019
{

0 commit comments

Comments
 (0)