Adapted for version 5.3.7 from From 67f2b31d5dbb7ba0ad423d07a1256f14b6f019c5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 23 Mar 2023 10:05:04 +0100 Subject: [PATCH] fix testObject for redis 7.2 --- tests/RedisTest.php | 8 +++++--- tests/TestSuite.php | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff -up ./tests/RedisTest.php.pr2335 ./tests/RedisTest.php --- ./tests/RedisTest.php.pr2335 2023-03-23 10:17:56.611597097 +0100 +++ ./tests/RedisTest.php 2023-03-23 10:19:48.911307411 +0100 @@ -2744,14 +2744,15 @@ class Redis_Test extends TestSuite /* Newer versions of redis are going to encode lists as 'quicklists', * so 'quicklist' or 'ziplist' is valid here */ $str_encoding = $this->redis->object('encoding', 'key'); - $this->assertTrue($str_encoding === "ziplist" || $str_encoding === 'quicklist'); + $this->assertTrue($str_encoding === "ziplist" || $str_encoding === 'quicklist' || $str_encoding === 'listpack', $str_encoding); $this->assertTrue($this->redis->object('refcount', 'key') === 1); $this->assertTrue($this->redis->object('idletime', 'key') === 0); $this->redis->del('key'); $this->redis->sadd('key', 'value'); - $this->assertTrue($this->redis->object('encoding', 'key') === "hashtable"); + $str_encoding = $this->redis->object('encoding', 'key'); + $this->assertTrue($str_encoding === "hashtable" || $str_encoding === 'listpack', $str_encoding); $this->assertTrue($this->redis->object('refcount', 'key') === 1); $this->assertTrue($this->redis->object('idletime', 'key') === 0); diff -up ./tests/TestSuite.php.pr2335 ./tests/TestSuite.php --- ./tests/TestSuite.php.pr2335 2022-02-15 19:25:22.000000000 +0100 +++ ./tests/TestSuite.php 2023-03-23 10:17:56.611597097 +0100 @@ -99,13 +99,13 @@ class TestSuite return false; } - protected function assertTrue($bool) { + protected function assertTrue($bool, $msg='') { if($bool) return true; $bt = debug_backtrace(false); - self::$errors []= sprintf("Assertion failed: %s:%d (%s)\n", - $bt[0]["file"], $bt[0]["line"], $bt[1]["function"]); + self::$errors []= sprintf("Assertion failed: %s:%d (%s) %s\n", + $bt[0]["file"], $bt[0]["line"], $bt[1]["function"], $msg); return false; }