Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/system/Cache/Handlers/AbstractHandlerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ 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
// `$this->memcachedHandler->save()` (e.g. 12:00:01.0000)
// 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']);
}
Expand Down
19 changes: 13 additions & 6 deletions tests/system/Cache/Handlers/PredisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Loading