Skip to content

Commit

Permalink
Adapt configuration group names to Yii conventions (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Feb 16, 2023
1 parent fe11a3c commit 8fc782f
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Yii Event Change Log

## 1.0.4 under development
## 2.0.0 under development

- Chg #50: Adapt configuration group names to Yii conventions (@vjik)
- Enh #41: Raise minimum PHP version to 8.0 (@vjik, @xepozz)

## 1.0.3 June 27, 2022
Expand Down
25 changes: 11 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
"yiisoft/config": "^1.3",
"yiisoft/di": "^1.2",
"yiisoft/test-support": "^1.3"
},
"autoload": {
Expand All @@ -44,28 +46,23 @@
},
"extra": {
"config-plugin-options": {
"source-directory": "config"
"source-directory": "config",
"merge-plan-file": "../tests/environment/.merge-plan.php"
},
"config-plugin": {
"common": "common.php",
"console": "console.php",
"events": "events.php",
"events-web": [
"$events",
"events-web.php"
],
"events-console": [
"$events",
"events-console.php"
],
"web": "web.php"
"di": "di.php",
"di-web": "di-web.php",
"di-console": "di-console.php",
"events-web": [],
"events-console": []
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"composer/package-versions-deprecated": true
"composer/package-versions-deprecated": true,
"yiisoft/config": true
}
},
"scripts": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions config/events-console.php

This file was deleted.

5 changes: 0 additions & 5 deletions config/events-web.php

This file was deleted.

5 changes: 0 additions & 5 deletions config/events.php

This file was deleted.

73 changes: 73 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Yii\Event\Tests;

use PHPUnit\Framework\TestCase;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\EventDispatcher\ListenerProviderInterface;
use Yiisoft\Config\Config;
use Yiisoft\Config\ConfigPaths;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
use Yiisoft\EventDispatcher\Dispatcher\Dispatcher;
use Yiisoft\EventDispatcher\Provider\ListenerCollection;
use Yiisoft\EventDispatcher\Provider\Provider;
use Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher;

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

$eventDispatcher = $container->get(EventDispatcherInterface::class);
$listenerProvider = $container->get(ListenerProviderInterface::class);

$this->assertInstanceOf(Dispatcher::class, $eventDispatcher);
$this->assertInstanceOf(Provider::class, $listenerProvider);
}

public function testDiWeb(): void
{
$container = $this->createContainer('web');

$listenerCollection = $container->get(ListenerCollection::class);

$this->assertInstanceOf(ListenerCollection::class, $listenerCollection);
}

public function testDiConsole(): void
{
$container = $this->createContainer('console');

$listenerCollection = $container->get(ListenerCollection::class);

$this->assertInstanceOf(ListenerCollection::class, $listenerCollection);
}

private function createContainer(?string $postfix = null): Container
{
return new Container(
ContainerConfig::create()->withDefinitions(
$this->createConfig()->get('di' . ($postfix !== null ? '-' . $postfix : ''))
+
[
EventDispatcherInterface::class => new SimpleEventDispatcher(),
]
)
);
}

private function createConfig(): Config
{
return new Config(
new ConfigPaths(dirname(__DIR__), 'config'),
null,
[],
null,
'../tests/environment/.merge-plan.php'
);
}
}
2 changes: 2 additions & 0 deletions tests/environment/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 8fc782f

Please sign in to comment.