Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jankonas authored and f3l1x committed Dec 2, 2024
1 parent 92cac6f commit 8645da2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Cases/DI/OrmCacheExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use Nette\Caching\Storage;
use Nette\Caching\Storages\MemoryStorage;
use Nette\DI\Compiler;
use Nette\DI\Definitions\Statement;
use Nette\DI\ServiceCreationException;
use Nettrine\ORM\DI\OrmCacheExtension;
use Psr\Cache\CacheItemPoolInterface;
use Tester\Assert;
Expand Down Expand Up @@ -153,3 +154,37 @@ Toolkit::test(function (): void {
Assert::type(CachePool::class, $em->getConfiguration()->getQueryCache());
Assert::type(CachePool::class, $em->getConfiguration()->getResultCache());
});

// Provide non-existent service (for tests coverage)
Toolkit::test(function (): void {
Assert::exception(function (): void {
$container = Container::of()
->withDefaults()
->withCompiler(function (Compiler $compiler): void {
$compiler->addExtension('nettrine.orm.cache', new OrmCacheExtension());
$compiler->addConfig([
'nettrine.orm.cache' => [
'hydrationCache' => '@nonExistentService',
]
]);
})
->build();
}, ServiceCreationException::class);
});

// Provide some nonsense string (for tests coverage)
Toolkit::test(function (): void {
Assert::exception(function (): void {
$container = Container::of()
->withDefaults()
->withCompiler(function (Compiler $compiler): void {
$compiler->addExtension('nettrine.orm.cache', new OrmCacheExtension());
$compiler->addConfig([
'nettrine.orm.cache' => [
'hydrationCache' => 'nonsenseString',
]
]);
})
->build();
}, ServiceCreationException::class);
});

0 comments on commit 8645da2

Please sign in to comment.