Skip to content

Commit

Permalink
Add event listener checker
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
  • Loading branch information
viktorprogger and samdark committed Feb 26, 2021
1 parent 02c1c85 commit 3a7cc34
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ApplicationRunner.php
Expand Up @@ -18,6 +18,7 @@
use Yiisoft\ErrorHandler\Renderer\HtmlRenderer;
use Yiisoft\Files\FileHelper;
use Yiisoft\Http\Method;
use Yiisoft\Yii\Event\ListenerConfigurationChecker;
use Yiisoft\Yii\Web\Application;
use Yiisoft\Yii\Web\SapiEmitter;
use Yiisoft\Yii\Web\ServerRequestFactory;
Expand Down Expand Up @@ -54,6 +55,11 @@ public function run(): void
$this->registerErrorHandler($container->get(ErrorHandler::class), $errorHandler);

$container = $container->get(ContainerInterface::class);

if ($this->debug) {
$container->get(ListenerConfigurationChecker::class)->check(require Builder::path('events-web'));
}

$application = $container->get(Application::class);

$request = $container->get(ServerRequestFactory::class)->createFromGlobals();
Expand Down
23 changes: 23 additions & 0 deletions tests/Functional/EventListenerConfigurationTest.php
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace App\Tests\Functional;

use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Yiisoft\Composer\Config\Builder;
use Yiisoft\Di\Container;
use Yiisoft\Yii\Event\ListenerConfigurationChecker;

class EventListenerConfigurationTest extends TestCase
{
public function testConsoleListenerConfiguration(): void
{
$container = (new Container(require Builder::path('console')))->get(ContainerInterface::class);
$checker = $container->get(ListenerConfigurationChecker::class);
$checker->check(require Builder::path('events-console'));

self::assertInstanceOf(ListenerConfigurationChecker::class, $checker);
}
}

0 comments on commit 3a7cc34

Please sign in to comment.