Skip to content

Commit

Permalink
Merge pull request #116 from bearsunday/redis-cache-test
Browse files Browse the repository at this point in the history
Create Redis cache test
  • Loading branch information
koriym committed Oct 17, 2022
2 parents 40a0906 + 4ba8b3d commit f59558f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/DonutCommandInterceptorTest.php
Expand Up @@ -20,9 +20,9 @@

class DonutCommandInterceptorTest extends TestCase
{
private ResourceInterface $resource;
private RepositoryLoggerInterface $logger;
private HttpCacheInterfaceAlias $httpCache;
protected ResourceInterface $resource;
protected RepositoryLoggerInterface $logger;
protected HttpCacheInterfaceAlias $httpCache;

protected function setUp(): void
{
Expand Down
35 changes: 35 additions & 0 deletions tests/DonutCommandRedisCacheTest.php
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace BEAR\QueryRepository;

use BEAR\Resource\ResourceInterface;
use BEAR\Sunday\Extension\Transfer\HttpCacheInterface as HttpCacheInterfaceAlias;
use Madapaja\TwigModule\TwigModule;
use Ray\Di\Injector;

use function assert;
use function dirname;
use function serialize;
use function unserialize;

class DonutCommandRedisCacheTest extends DonutCommandInterceptorTest
{
protected function setUp(): void
{
$namespace = 'FakeVendor\HelloWorld';
$module = new FakeEtagPoolModule(ModuleFactory::getInstance($namespace));
$module->override(new TwigModule([dirname(__DIR__) . '/tests/Fake/fake-app/var/templates']));
$module->override(new StorageRedisModule('127.0.0.1:6379'));
$injector = new Injector($module, $_ENV['TMP_DIR']);
$this->resource = $injector->getInstance(ResourceInterface::class);
$this->logger = $injector->getInstance(RepositoryLoggerInterface::class);
$httpCache = $injector->getInstance(HttpCacheInterfaceAlias::class);
$unserializedHttpCache = unserialize(serialize($httpCache));
assert($unserializedHttpCache instanceof HttpCacheInterfaceAlias);
$this->httpCache = $unserializedHttpCache;

parent::setUp();
}
}

0 comments on commit f59558f

Please sign in to comment.