Skip to content

Commit

Permalink
Adapt configuration group names to Yii conventions (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Feb 16, 2023
1 parent cf117b3 commit 38a71d2
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
@@ -1,8 +1,8 @@
# Yii Mailer Library - Symfony Mailer Extension Change Log

## 2.1.1 under development
## 3.0.0 under development

- no changes in this release.
- Chg #27: Adapt configuration group names to Yii conventions (@vjik)

## 2.1.0 January 02, 2023

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -27,7 +27,7 @@ This package is an adapter for [yiisoft/mailer](https://github.com/yiisoft/maile
The package could be installed with composer:

```shell
composer require yiisoft/mailer-symfony --prefer-dist
composer require yiisoft/mailer-symfony
```

## General usage
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Expand Up @@ -38,13 +38,16 @@
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"roave/infection-static-analysis-plugin": "^1.25",
"rector/rector": "^0.15.2",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.4",
"yiisoft/aliases": "^3.0",
"yiisoft/di": "^1.2",
"yiisoft/files": "^2.0",
"yiisoft/psr-dummy-provider": "^1.0",
"yiisoft/test-support": "^3.0"
"yiisoft/test-support": "^3.0",
"yiisoft/view": "^7.0"
},
"autoload": {
"psr-4": {
Expand All @@ -62,7 +65,7 @@
},
"config-plugin": {
"params": "params.php",
"common": "common.php"
"di": "di.php"
}
},
"config": {
Expand Down
File renamed without changes.
74 changes: 74 additions & 0 deletions tests/ConfigTest.php
@@ -0,0 +1,74 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Mailer\Symfony\Tests;

use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mailer\Transport\TransportInterface;
use Yiisoft\Aliases\Aliases;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
use Yiisoft\Mailer\FileMailer;
use Yiisoft\Mailer\MailerInterface;
use Yiisoft\Mailer\MessageBodyRenderer;
use Yiisoft\Mailer\MessageFactory;
use Yiisoft\Mailer\MessageFactoryInterface;
use Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher;
use Yiisoft\View\View;

final class ConfigTest extends \PHPUnit\Framework\TestCase
{
public function testBase(): void
{
$container = $this->createContainer();

$messageBodyRenderer = $container->get(MessageBodyRenderer::class);
$messageFactory = $container->get(MessageFactoryInterface::class);
$transport = $container->get(TransportInterface::class);
$fileMailer = $container->get(FileMailer::class);
$mailer = $container->get(MailerInterface::class);

$this->assertInstanceOf(MessageBodyRenderer::class, $messageBodyRenderer);
$this->assertInstanceOf(MessageFactory::class, $messageFactory);
$this->assertInstanceOf(EsmtpTransport::class, $transport);
$this->assertInstanceOf(FileMailer::class, $fileMailer);
$this->assertInstanceOf(FileMailer::class, $mailer);
}

private function createContainer(?array $params = null): Container
{
return new Container(
ContainerConfig::create()->withDefinitions(
$this->getDiConfig($params)
+
[
View::class => ['__construct()' => [__DIR__]],
EventDispatcherInterface::class => new SimpleEventDispatcher(),
Aliases::class => [
'__construct()' => [
[
'resources' => __DIR__ . '/environment/resources',
'runtime' => __DIR__ . '/environment/runtime',
],
],
],
]
)
);
}

private function getDiConfig(?array $params = null): array
{
if ($params === null) {
$params = $this->getParams();
}
return require dirname(__DIR__) . '/config/di.php';
}

private function getParams(): array
{
return require dirname(__DIR__) . '/config/params.php';
}
}
Empty file.
Empty file.

0 comments on commit 38a71d2

Please sign in to comment.