Skip to content

Commit

Permalink
Extension: catch exception is dynamic [closes #67]
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Jan 3, 2024
1 parent 43d9925 commit 2c719a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require-dev": {
"nette/http": "^3.2.3",
"contributte/qa": "^0.4",
"contributte/tester": "^0.3",
"contributte/tester": "^0.4",
"contributte/phpstan": "^0.1",
"mockery/mockery": "^1.6.7",
"symfony/event-dispatcher": "^6.4.2 || ^7.0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/DI/ConsoleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getConfigSchema(): Schema
'url' => Expect::anyOf(Expect::string(), Expect::null())->dynamic(),
'name' => Expect::string()->dynamic(),
'version' => Expect::anyOf(Expect::string(), Expect::int(), Expect::float()),
'catchExceptions' => Expect::bool(),
'catchExceptions' => Expect::bool()->dynamic(),
'autoExit' => Expect::bool(),
'helperSet' => Expect::anyOf(Expect::string(), Expect::type(Statement::class)),
'helpers' => Expect::arrayOf(
Expand Down
31 changes: 31 additions & 0 deletions tests/cases/DI/ConsoleExtension.dynamic.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types = 1);

use Contributte\Console\Application;
use Contributte\Console\DI\ConsoleExtension;
use Contributte\Tester\Toolkit;
use Contributte\Tester\Utils\ContainerBuilder;
use Contributte\Tester\Utils\Neonkit;
use Nette\DI\Compiler;
use Tester\Assert;

require_once __DIR__ . '/../../bootstrap.php';

// catchException
Toolkit::test(function (): void {
$container = ContainerBuilder::of()
->withCompiler(function (Compiler $compiler): void {
$compiler->addExtension('console', new ConsoleExtension(true));
$compiler->addConfig(Neonkit::load(<<<'NEON'
console:
catchExceptions: %catchExceptions%
NEON
));
$compiler->setDynamicParameterNames(['catchExceptions']);
})->buildWith([
'catchExceptions' => false,
]);

$application = $container->getByType(Application::class);
assert($application instanceof Application);
Assert::false($application->areExceptionsCaught());
});

0 comments on commit 2c719a4

Please sign in to comment.