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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
- [2026-01-16] DamImpr: hotfix null value [#36](https://github.com/DamImpr/cache-multi-layer/pull/36)

- [2026-01-16] DamImpr: chore: update CHANGELOG for PR #36 [#37](https://github.com/DamImpr/cache-multi-layer/pull/37)

- [2026-01-16] DamImpr: test method with depth array greater than 1 [#38](https://github.com/DamImpr/cache-multi-layer/pull/38)
27 changes: 27 additions & 0 deletions tests/AbstractCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ public function testArray(): void
$this->assertEquals($val, $x);
}

public function testArrayDepth(): void
{
$x = [1, 2, 3, null, [
1, 2, 3, null, [
1, 2, 3, null
]
]
];
$key = 'test_array_depth';
$res = $this->cache->set($key, $x);
$this->assertTrue($res);
$val = $this->cache->get($key);
$this->testRecursiveArray($x, $val);
}

public function testClass(): void
{
$key = 'test_class';
Expand Down Expand Up @@ -187,4 +202,16 @@ public final function getCache(): ?Cache
{
return $this->cache;
}

private function testRecursiveArray(array $actual, array $expected): void
{
foreach($expected as $key => $value){
$this->assertArrayHasKey($key, $actual);
if(is_array($value)){
$this->testRecursiveArray($value, $actual[$key]);
} else {
$this->assertEquals($value, $actual[$key]);
}
}
}
}
6 changes: 6 additions & 0 deletions tests/ApcuCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ public static function tearDownAfterClass(): void
parent::tearDownAfterClass();
Cache::factory(CacheEnum::APCU, 60)->clearAllCache();
}

#[\Override]
public function testArrayDepth(): void
{
parent::testArrayDepth();
}

/**
*
Expand Down
10 changes: 8 additions & 2 deletions tests/MemcacheCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,19 @@ public function testPrefix(): void
{
$val = 10; //maradona
$key = "test_prefix";
$cacheSamePrefix = Cache::factory(CacheEnum::MEMCACHE, 60, ['key_prefix' => '','server_address' => 'memcache-server']);
$cacheOtherPrefix = Cache::factory(CacheEnum::MEMCACHE, 10, ['key_prefix' => 'other_','server_address' => 'memcache-server']);
$cacheSamePrefix = Cache::factory(CacheEnum::MEMCACHE, 60, ['key_prefix' => '', 'server_address' => 'memcache-server']);
$cacheOtherPrefix = Cache::factory(CacheEnum::MEMCACHE, 10, ['key_prefix' => 'other_', 'server_address' => 'memcache-server']);
$this->getCache()->set($key, $val);
$this->assertEquals($cacheSamePrefix->get($key), $val);
$this->assertNull($cacheOtherPrefix->get($key));
}

#[\Override]
public function testArrayDepth(): void
{
parent::testArrayDepth();
}

#[\Override]
public static function tearDownAfterClass(): void
{
Expand Down
6 changes: 6 additions & 0 deletions tests/PRedisCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ public function testPrefix(): void
$this->assertEquals($cacheSamePrefix->get($key), $val);
$this->assertNull($cacheOtherPrefix->get($key));
}

#[\Override]
public function testArrayDepth(): void
{
parent::testArrayDepth();
}

#[\Override]
public static function tearDownAfterClass(): void
Expand Down
6 changes: 6 additions & 0 deletions tests/RedisCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ public function testPrefix(): void
$this->assertEquals($cacheSamePrefix->get($key), $val);
$this->assertNull($cacheOtherPrefix->get($key));
}

#[\Override]
public function testArrayDepth(): void
{
parent::testArrayDepth();
}

#[\Override]
public static function tearDownAfterClass(): void
Expand Down