diff --git a/tests/system/Cache/Handlers/AbstractHandlerTestCase.php b/tests/system/Cache/Handlers/AbstractHandlerTestCase.php index 5732663f99f9..c0343ff06da0 100644 --- a/tests/system/Cache/Handlers/AbstractHandlerTestCase.php +++ b/tests/system/Cache/Handlers/AbstractHandlerTestCase.php @@ -38,6 +38,7 @@ public function testGetMetaData(): void $this->handler->save(self::$key1, 'value'); $actual = $this->handler->getMetaData(self::$key1); + $this->assertIsArray($actual); // This test is time-dependent, and depending on the timing, // seconds in `$time` (e.g. 12:00:00.9999) and seconds of @@ -45,7 +46,6 @@ public function testGetMetaData(): void // may be off by one second. In that case, the following calculation // will result in maximum of (60 + 1). $this->assertLessThanOrEqual(60 + 1, $actual['expire'] - $time); - $this->assertLessThanOrEqual(1, $actual['mtime'] - $time); $this->assertSame('value', $actual['data']); } diff --git a/tests/system/Cache/Handlers/PredisHandlerTest.php b/tests/system/Cache/Handlers/PredisHandlerTest.php index 96857fc6a9f2..a906457b5c97 100644 --- a/tests/system/Cache/Handlers/PredisHandlerTest.php +++ b/tests/system/Cache/Handlers/PredisHandlerTest.php @@ -107,11 +107,12 @@ public function testSave(): void public function testSavePermanent(): void { $this->assertTrue($this->handler->save(self::$key1, 'value', 0)); - $metaData = $this->handler->getMetaData(self::$key1); - $this->assertNull($metaData['expire']); - $this->assertLessThanOrEqual(1, $metaData['mtime'] - Time::now()->getTimestamp()); - $this->assertSame('value', $metaData['data']); + $metadata = $this->handler->getMetaData(self::$key1); + $this->assertIsArray($metadata); + $this->assertNull($metadata['expire']); + $this->assertLessThanOrEqual(1, $metadata['mtime'] - Time::now()->getTimestamp()); + $this->assertSame('value', $metadata['data']); $this->assertTrue($this->handler->delete(self::$key1)); } @@ -131,8 +132,11 @@ public function testDeleteMatchingPrefix(): void $this->handler->save('key_' . $i, 'value' . $i); } + $cacheInfo = $this->handler->getCacheInfo(); + $this->assertIsArray($cacheInfo); + // check that there are 101 items is cache store - $this->assertSame('101', $this->handler->getCacheInfo()['Keyspace']['db0']['keys']); + $this->assertSame('101', $cacheInfo['Keyspace']['db0']['keys']); // Checking that given the prefix "key_1", deleteMatching deletes 13 keys: // (key_1, key_10, key_11, key_12, key_13, key_14, key_15, key_16, key_17, key_18, key_19, key_100, key_101) @@ -149,8 +153,11 @@ public function testDeleteMatchingSuffix(): void $this->handler->save('key_' . $i, 'value' . $i); } + $cacheInfo = $this->handler->getCacheInfo(); + $this->assertIsArray($cacheInfo); + // check that there are 101 items is cache store - $this->assertSame('101', $this->handler->getCacheInfo()['Keyspace']['db0']['keys']); + $this->assertSame('101', $cacheInfo['Keyspace']['db0']['keys']); // Checking that given the suffix "1", deleteMatching deletes 11 keys: // (key_1, key_11, key_21, key_31, key_41, key_51, key_61, key_71, key_81, key_91, key_101)