Skip to content

Commit

Permalink
PhpExtension: validates options
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and dg committed Jul 30, 2023
1 parent 705f741 commit 483fba1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Bootstrap/Extensions/PhpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ final class PhpExtension extends Nette\DI\CompilerExtension
{
public function getConfigSchema(): Nette\Schema\Schema
{
return Expect::arrayOf(Expect::scalar()->dynamic());
return Expect::arrayOf(
Expect::type('scalar|null')->dynamic(),
Expect::string(),
);
}


Expand Down
27 changes: 27 additions & 0 deletions tests/Bootstrap/PhpExtension.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Nette\DI;
use Tester\Assert;

require __DIR__ . '/../bootstrap.php';


$compiler = new DI\Compiler;
$compiler->setClassName('Container');
$compiler->addExtension('php', new Nette\Bootstrap\Extensions\PhpExtension);
$compiler->addConfig([
'php' => [
'date.timezone' => 'Europe/Rome',
'exit_on_timeout' => null,
],
]);
eval($compiler->compile());

ini_set('date.timezone', 'Europe/Prague');

$container = new Container;
$container->initialize();

Assert::same('Europe/Rome', ini_get('date.timezone'));

0 comments on commit 483fba1

Please sign in to comment.