Skip to content

Commit 3b4aab8

Browse files
Add event listener checker
1 parent 3ad1503 commit 3b4aab8

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
"autoload-dev": {
7070
"psr-4": {
7171
"App\\Tests\\": "tests/",
72-
"App\\Tests\\Acceptance\\": "tests/acceptance/"
72+
"App\\Tests\\Acceptance\\": "tests/acceptance/",
73+
"App\\Tests\\Functional\\": "tests/functional/"
7374
}
7475
},
7576
"scripts": {

src/ApplicationRunner.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Yiisoft\ErrorHandler\Renderer\JsonRenderer;
1919
use Yiisoft\Files\FileHelper;
2020
use Yiisoft\Http\Method;
21+
use Yiisoft\Yii\Event\ListenerConfigurationChecker;
2122
use Yiisoft\Yii\Web\Application;
2223
use Yiisoft\Yii\Web\SapiEmitter;
2324
use Yiisoft\Yii\Web\ServerRequestFactory;
@@ -54,6 +55,11 @@ public function run(): void
5455
$this->registerErrorHandler($container->get(ErrorHandler::class), $errorHandler);
5556

5657
$container = $container->get(ContainerInterface::class);
58+
59+
if ($this->debug) {
60+
$container->get(ListenerConfigurationChecker::class)->check(Builder::path('events-web'));
61+
}
62+
5763
$application = $container->get(Application::class);
5864

5965
$request = $container->get(ServerRequestFactory::class)->createFromGlobals();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Tests\Functional;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Psr\Container\ContainerInterface;
9+
use Yiisoft\Composer\Config\Builder;
10+
use Yiisoft\Di\Container;
11+
use Yiisoft\Yii\Event\ListenerConfigurationChecker;
12+
13+
class EventListenerConfigurationTest extends TestCase
14+
{
15+
public function testConsoleListenerConfiguration(): void
16+
{
17+
$container = (new Container(require Builder::path('console')))->get(ContainerInterface::class);
18+
$checker = $container->get(ListenerConfigurationChecker::class);
19+
$checker->check(require Builder::path('events-console'));
20+
21+
self::assertInstanceOf(ListenerConfigurationChecker::class, $checker);
22+
}
23+
}

0 commit comments

Comments
 (0)