Skip to content

Commit 2c719a4

Browse files
committed
Extension: catch exception is dynamic [closes #67]
1 parent 43d9925 commit 2c719a4

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"nette/http": "^3.2.3",
2525
"contributte/qa": "^0.4",
26-
"contributte/tester": "^0.3",
26+
"contributte/tester": "^0.4",
2727
"contributte/phpstan": "^0.1",
2828
"mockery/mockery": "^1.6.7",
2929
"symfony/event-dispatcher": "^6.4.2 || ^7.0.2"

src/DI/ConsoleExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getConfigSchema(): Schema
4040
'url' => Expect::anyOf(Expect::string(), Expect::null())->dynamic(),
4141
'name' => Expect::string()->dynamic(),
4242
'version' => Expect::anyOf(Expect::string(), Expect::int(), Expect::float()),
43-
'catchExceptions' => Expect::bool(),
43+
'catchExceptions' => Expect::bool()->dynamic(),
4444
'autoExit' => Expect::bool(),
4545
'helperSet' => Expect::anyOf(Expect::string(), Expect::type(Statement::class)),
4646
'helpers' => Expect::arrayOf(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types = 1);
2+
3+
use Contributte\Console\Application;
4+
use Contributte\Console\DI\ConsoleExtension;
5+
use Contributte\Tester\Toolkit;
6+
use Contributte\Tester\Utils\ContainerBuilder;
7+
use Contributte\Tester\Utils\Neonkit;
8+
use Nette\DI\Compiler;
9+
use Tester\Assert;
10+
11+
require_once __DIR__ . '/../../bootstrap.php';
12+
13+
// catchException
14+
Toolkit::test(function (): void {
15+
$container = ContainerBuilder::of()
16+
->withCompiler(function (Compiler $compiler): void {
17+
$compiler->addExtension('console', new ConsoleExtension(true));
18+
$compiler->addConfig(Neonkit::load(<<<'NEON'
19+
console:
20+
catchExceptions: %catchExceptions%
21+
NEON
22+
));
23+
$compiler->setDynamicParameterNames(['catchExceptions']);
24+
})->buildWith([
25+
'catchExceptions' => false,
26+
]);
27+
28+
$application = $container->getByType(Application::class);
29+
assert($application instanceof Application);
30+
Assert::false($application->areExceptionsCaught());
31+
});

0 commit comments

Comments
 (0)