-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
# Folders - recursive | ||
*.expected | ||
*.actual | ||
|
||
# Folders | ||
/tmp | ||
|
||
# Files | ||
/*.log | ||
/*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Cases\DI; | ||
|
||
use Contributte\Tester\Environment; | ||
use Contributte\Tester\Toolkit; | ||
use Contributte\Tester\Utils\ContainerBuilder; | ||
use Nette\DI\Compiler; | ||
use Nette\InvalidStateException; | ||
use Nettrine\Cache\DI\CacheExtension; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
|
||
if (function_exists('apcu_exists')) { | ||
Environment::skip('Exception unreachable when apcu is available'); | ||
} | ||
|
||
Toolkit::test(function (): void { | ||
Assert::exception(function (): void { | ||
ContainerBuilder::of() | ||
->withCompiler(function (Compiler $compiler): void { | ||
$compiler->addExtension('nettrine.cache', new CacheExtension()); | ||
$compiler->addDependencies([__FILE__]); | ||
}) | ||
->build(); | ||
}, InvalidStateException::class, 'Unable to find an available cache driver, please provide one via \'nettrine.cache > driver\' configuration.'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Cases\DI; | ||
|
||
use Contributte\Tester\Environment; | ||
use Contributte\Tester\Toolkit; | ||
use Contributte\Tester\Utils\ContainerBuilder; | ||
use Doctrine\Common\Cache\ApcuCache; | ||
use Doctrine\Common\Cache\Cache; | ||
use Nette\DI\Compiler; | ||
use Nettrine\Cache\DI\CacheExtension; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
|
||
if (!function_exists('apcu_exists')) { | ||
Environment::skip('Autoselect driver unreachable when apcu is not available'); | ||
} | ||
|
||
Toolkit::test(function (): void { | ||
$container = ContainerBuilder::of() | ||
->withCompiler(function (Compiler $compiler): void { | ||
$compiler->addExtension('nettrine.cache', new CacheExtension()); | ||
$compiler->addDependencies([__FILE__]); | ||
}) | ||
->build(); | ||
|
||
Assert::type(ApcuCache::class, $container->getByType(Cache::class)); | ||
Assert::type(ApcuCache::class, $container->getService('nettrine.cache.driver')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Cases\DI; | ||
|
||
use Contributte\Tester\Environment; | ||
use Contributte\Tester\Toolkit; | ||
use Contributte\Tester\Utils\ContainerBuilder; | ||
use Contributte\Tester\Utils\Neonkit; | ||
use Doctrine\Common\Cache\Cache; | ||
use Doctrine\Common\Cache\PhpFileCache; | ||
use Doctrine\Common\Cache\VoidCache; | ||
use Nette\DI\Compiler; | ||
use Nettrine\Cache\DI\CacheExtension; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
|
||
Toolkit::test(function (): void { | ||
$container = ContainerBuilder::of() | ||
->withCompiler(function (Compiler $compiler): void { | ||
$compiler->addExtension('nettrine.cache', new CacheExtension()); | ||
$compiler->addConfig([ | ||
'parameters' => [ | ||
'tempDir' => Environment::getTestDir(), | ||
], | ||
]); | ||
$compiler->addDependencies([__FILE__]); | ||
}) | ||
->build(); | ||
|
||
Assert::type(PhpFileCache::class, $container->getByType(Cache::class)); | ||
Assert::type(PhpFileCache::class, $container->getService('nettrine.cache.driver')); | ||
}); | ||
|
||
Toolkit::test(function (): void { | ||
$container = ContainerBuilder::of() | ||
->withCompiler(function (Compiler $compiler): void { | ||
$compiler->addExtension('nettrine.cache', new CacheExtension()); | ||
$compiler->addConfig(Neonkit::load(' | ||
nettrine.cache: | ||
driver: Doctrine\Common\Cache\VoidCache() | ||
')); | ||
$compiler->addDependencies([__FILE__]); | ||
}) | ||
->build(); | ||
|
||
Assert::type(VoidCache::class, $container->getByType(Cache::class)); | ||
Assert::type(VoidCache::class, $container->getService('nettrine.cache.driver')); | ||
}); |
This file was deleted.
Oops, something went wrong.