Skip to content

Commit

Permalink
Fix events configuration for Yii Debug (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Jun 6, 2024
1 parent 6753946 commit 7044bc1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## 6.1.1 under development

- no changes in this release.
- Bug #112: Fix events configuration for Yii Debug (@vjik)

## 6.1.0 May 28, 2024

- New #102: Add layout specific injections (@vjik)
- Enh #107: Implement lazy loading for injections (@vjik)
- Enh #79: Add debug collector for yiisoft/yii-debug (@xepozz)
- Enh #99: Make `viewPath` in `ViewRenderer` constructor optional (@vjik)
- Bug #82: Fixed find for layout file due to compatibility with `yiisoft/view` (@rustamwin)
- Bug #82: Fix find for layout file due to compatibility with `yiisoft/view` (@rustamwin)

## 6.0.0 February 16, 2023

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"maglnet/composer-require-checker": "^4.3",
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^9.5",
"rector/rector": "^1.0.0",
"rector/rector": "1.0.*",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.24",
Expand Down
4 changes: 4 additions & 0 deletions config/events-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Yiisoft\View\Event\WebView\AfterRender;
use Yiisoft\Yii\View\Debug\WebViewCollector;

if (!($params['yiisoft/yii-debug']['enabled'] ?? false)) {
return [];
}

return [
AfterRender::class => [
[WebViewCollector::class, 'collect'],
Expand Down
18 changes: 18 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ public function testDiWeb(): void
$this->assertInstanceOf(ViewRenderer::class, $viewRenderer);
}

public function testEventsWebWithDebug(): void
{
$eventsConfig = $this->getEventsWeb(['yiisoft/yii-debug' => ['enabled' => true]]);
$this->assertCount(1, $eventsConfig);
}

public function testEventsWebWithoutDebug(): void
{
$eventsConfig = $this->getEventsWeb(['yiisoft/yii-debug' => ['enabled' => false]]);
$this->assertCount(0, $eventsConfig);
}

private function createContainer(?string $postfix = null): Container
{
return new Container(
Expand All @@ -43,6 +55,12 @@ private function getDiConfig(?string $postfix = null): array
return require dirname(__DIR__) . '/config/di' . ($postfix !== null ? '-' . $postfix : '') . '.php';
}

private function getEventsWeb(?array $params = null)
{
$params ??= $this->getParams();
return require dirname(__DIR__) . '/config/events-web.php';
}

private function getParams(): array
{
return require dirname(__DIR__) . '/config/params.php';
Expand Down

0 comments on commit 7044bc1

Please sign in to comment.