forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
213 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Content\Mail; | ||
|
||
use Shopware\Core\Content\Mail\Service\MailerTransportLoader; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* @package core | ||
* | ||
* @interal | ||
*/ | ||
class MailerConfigurationCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
$container->getDefinition('mailer.default_transport')->setFactory([ | ||
new Reference(MailerTransportLoader::class), | ||
'fromString', | ||
]); | ||
|
||
$container->getDefinition('mailer.transports')->setFactory([ | ||
new Reference(MailerTransportLoader::class), | ||
'fromStrings', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/unit/php/Core/Content/Mail/MailerConfigurationCompilerPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Tests\Unit\Core\Content\Mail; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Shopware\Core\Content\Mail\MailerConfigurationCompilerPass; | ||
use Shopware\Core\Content\Mail\Service\MailerTransportLoader; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Shopware\Core\Content\Mail\MailerConfigurationCompilerPass | ||
*/ | ||
class MailerConfigurationCompilerPassTest extends TestCase | ||
{ | ||
public function testProcess(): void | ||
{ | ||
$container = new ContainerBuilder(); | ||
|
||
$container->setDefinition('mailer.default_transport', new Definition(\ArrayObject::class)); | ||
$container->setDefinition('mailer.transports', new Definition(\ArrayObject::class)); | ||
|
||
$pass = new MailerConfigurationCompilerPass(); | ||
$pass->process($container); | ||
|
||
$defaultTransport = $container->getDefinition('mailer.default_transport'); | ||
|
||
$factory = $defaultTransport->getFactory(); | ||
static::assertIsArray($factory); | ||
static::assertArrayHasKey(0, $factory); | ||
static::assertArrayHasKey(1, $factory); | ||
static::assertInstanceOf(Reference::class, $factory[0]); | ||
static::assertSame(MailerTransportLoader::class, (string) $factory[0]); | ||
static::assertSame('fromString', $factory[1]); | ||
|
||
$transports = $container->getDefinition('mailer.transports'); | ||
|
||
$factory = $transports->getFactory(); | ||
static::assertIsArray($factory); | ||
static::assertArrayHasKey(0, $factory); | ||
static::assertArrayHasKey(1, $factory); | ||
static::assertInstanceOf(Reference::class, $factory[0]); | ||
static::assertSame(MailerTransportLoader::class, (string) $factory[0]); | ||
static::assertSame('fromStrings', $factory[1]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.