Skip to content

Commit

Permalink
Merge pull request #104 from PavelJurasek/php8-2
Browse files Browse the repository at this point in the history
Fix: Config schema is normalized
  • Loading branch information
Spamercz authored Aug 19, 2021
2 parents 494a5a6 + ede9d77 commit 9f0a6bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Kdyby/Redis/DI/Config/ClientSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function complete($value, \Nette\Schema\Context $context)
{
$value = $this->expandParameters($value);

$value = $this->getSchema()->normalize($value, $context);
$value = $this->getSchema()->complete($value, $context);

return $value;
Expand Down
3 changes: 2 additions & 1 deletion src/Kdyby/Redis/DI/Config/RedisSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function merge($value, $base)

public function complete($value, \Nette\Schema\Context $context)
{
$value = $this->expandParameters($value);
$value = $this->expandParameters((array) $value);

$value = $this->normalize($value, $context);
$value = $this->getSchema()->complete($value, $context);

return $value;
Expand Down
20 changes: 18 additions & 2 deletions tests/KdybyTests/Redis/ExtensionTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ require_once __DIR__ . '/../bootstrap.php';
class ExtensionTest extends \Tester\TestCase
{

protected function createContainer(): Container
protected function createConfig(): \Nette\Bootstrap\Configurator
{
$config = new Nette\Configurator();
$config = new \Nette\Bootstrap\Configurator();
$config->setTempDirectory(TEMP_DIR);
$config->onCompile[] = static function ($config, Nette\DI\Compiler $compiler): void {
$compiler->addExtension('redis', new Kdyby\Redis\DI\RedisExtension());
};

return $config;
}

protected function createContainer(): Container
{
$config = $this->createConfig();

$config->addConfig(__DIR__ . '/files/config.neon');

return $config->createContainer();
Expand Down Expand Up @@ -97,6 +104,15 @@ class ExtensionTest extends \Tester\TestCase
Assert::same(FALSE, $sessionOptions['cookie_secure']);
}

public function testWithoutConfiguration(): void
{
$config = $this->createConfig();
$dic = $config->createContainer();
Assert::true($dic->getService('redis.client') instanceof Kdyby\Redis\RedisClient);
Assert::false($dic->hasService('redis.cacheJournal'));
Assert::false($dic->hasService('redis.cacheStorage'));
}

}

(new ExtensionTest())->run();

0 comments on commit 9f0a6bf

Please sign in to comment.