From 71213d51f56d61e3136c5addadd97351b5e219fc Mon Sep 17 00:00:00 2001 From: Joel Male Date: Wed, 27 May 2026 21:01:34 +1000 Subject: [PATCH] fix: null-safe json_decode in RedisDriver; add getSessionModel test to MultiDriverTest --- src/Drivers/RedisDriver.php | 4 ++-- tests/Unit/Drivers/MultiDriverTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Drivers/RedisDriver.php b/src/Drivers/RedisDriver.php index 0cd05c0..7f8b9df 100644 --- a/src/Drivers/RedisDriver.php +++ b/src/Drivers/RedisDriver.php @@ -57,7 +57,7 @@ public function getItems(): array { $data = $this->redis->connection($this->connection)->get($this->itemsKey()); - return $data ? json_decode($data, true) : []; + return $data ? (json_decode($data, true) ?? []) : []; } public function putItems(array $items): void @@ -73,7 +73,7 @@ public function getConditions(): array { $data = $this->redis->connection($this->connection)->get($this->conditionsKey()); - return $data ? json_decode($data, true) : []; + return $data ? (json_decode($data, true) ?? []) : []; } public function putConditions(array $conditions): void diff --git a/tests/Unit/Drivers/MultiDriverTest.php b/tests/Unit/Drivers/MultiDriverTest.php index 0a16a9a..c182c5a 100644 --- a/tests/Unit/Drivers/MultiDriverTest.php +++ b/tests/Unit/Drivers/MultiDriverTest.php @@ -77,4 +77,8 @@ test('throws when constructed with no drivers', function () { expect(fn() => new MultiDriver([]))->toThrow(InvalidArgumentException::class); }); + + test('getSessionModel delegates to primary driver', function () { + expect($this->driver->getSessionModel())->toBeNull(); + }); });