diff --git a/src/core/src/Redis/Subscriber.php b/src/core/src/Redis/Subscriber.php index 0a83fcf07..68b4d7a04 100644 --- a/src/core/src/Redis/Subscriber.php +++ b/src/core/src/Redis/Subscriber.php @@ -63,4 +63,9 @@ public function psubscribe(array|string $channels, Closure $callback): void throw new SocketException('Redis connection is disconnected abnormally.'); } } + + public function __destruct() + { + $this->subscriber->close(); + } } diff --git a/src/foundation/src/Application.php b/src/foundation/src/Application.php index 972088506..3147df81b 100644 --- a/src/foundation/src/Application.php +++ b/src/foundation/src/Application.php @@ -31,7 +31,7 @@ class Application extends Container implements ApplicationContract * * @var string */ - public const VERSION = '0.1.5'; + public const VERSION = '0.1.6'; /** * The base path for the Hypervel installation. diff --git a/tests/Core/RedisSubscriberTest.php b/tests/Core/RedisSubscriberTest.php index aa49035f5..d3f9c1330 100644 --- a/tests/Core/RedisSubscriberTest.php +++ b/tests/Core/RedisSubscriberTest.php @@ -45,6 +45,9 @@ public function testSubscribe() ->twice() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = true; $subscriber = new Subscriber($config, $mockRedisSubscriber); @@ -83,6 +86,9 @@ public function testSubscribeThrowsExceptionWhenConnectionClosedAbnormally() ->once() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = false; $subscriber = new Subscriber($config, $mockRedisSubscriber); @@ -126,6 +132,9 @@ public function testPsubscribe() ->twice() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = true; $subscriber = new Subscriber($config, $mockRedisSubscriber); @@ -164,6 +173,9 @@ public function testPsubscribeThrowsExceptionWhenConnectionClosedAbnormally() ->once() ->andReturn($mockChannel); + $mockRedisSubscriber->shouldReceive('close') + ->once(); + $mockRedisSubscriber->closed = false; $subscriber = new Subscriber($config, $mockRedisSubscriber);