Skip to content

Commit

Permalink
Create connection test with serializable redis adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Apr 20, 2023
1 parent aca7043 commit 75b0f2c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/RedisAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Ray\Di\Injector;
use Redis;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Contracts\Cache\ItemInterface;

use function serialize;
use function unserialize;
Expand All @@ -17,7 +18,19 @@ class RedisAdapterTest extends TestCase
{
public function testSerialize(): string
{
$string = serialize(new RedisAdapter(new Redis()));
$client = RedisAdapter::createConnection(
'redis://localhost',
);

$adapter = new RedisAdapter($client);
$adapter->get('foo', static function (ItemInterface $item) {
return 'foobar';
});
$foo = $adapter->get('foo', static function (ItemInterface $item) {
return '_no_serve_';
});
$this->assertSame('foobar', $foo);
$string = serialize($adapter);
$this->assertIsString($string);

return $string;
Expand All @@ -26,7 +39,11 @@ public function testSerialize(): string
/** @depends testSerialize */
public function testUnserialize(string $string): void
{
$this->assertInstanceOf(RedisAdapter::class, unserialize($string));
$adapter = unserialize($string);
$this->assertInstanceOf(RedisAdapter::class, $adapter);
$this->assertSame('foobar', $adapter->get('foo', static function (ItemInterface $item) {
return '_no_serve_';
}));
}

public function testCacheNamespaceModule(): void
Expand Down

0 comments on commit 75b0f2c

Please sign in to comment.