diff --git a/CHANGELOG.md b/CHANGELOG.md index 766c8e5..ca0aba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/tests/AbstractCache.php b/tests/AbstractCache.php index 27bd4ae..0bf0fee 100644 --- a/tests/AbstractCache.php +++ b/tests/AbstractCache.php @@ -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'; @@ -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]); + } + } + } } \ No newline at end of file diff --git a/tests/ApcuCacheTest.php b/tests/ApcuCacheTest.php index 30142d7..00d436e 100644 --- a/tests/ApcuCacheTest.php +++ b/tests/ApcuCacheTest.php @@ -144,6 +144,12 @@ public static function tearDownAfterClass(): void parent::tearDownAfterClass(); Cache::factory(CacheEnum::APCU, 60)->clearAllCache(); } + + #[\Override] + public function testArrayDepth(): void + { + parent::testArrayDepth(); + } /** * diff --git a/tests/MemcacheCacheTest.php b/tests/MemcacheCacheTest.php index 8a146c3..dc95eed 100644 --- a/tests/MemcacheCacheTest.php +++ b/tests/MemcacheCacheTest.php @@ -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 { diff --git a/tests/PRedisCacheTest.php b/tests/PRedisCacheTest.php index ebfe98c..99bfc1c 100644 --- a/tests/PRedisCacheTest.php +++ b/tests/PRedisCacheTest.php @@ -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 diff --git a/tests/RedisCacheTest.php b/tests/RedisCacheTest.php index 074fe40..9b4823f 100644 --- a/tests/RedisCacheTest.php +++ b/tests/RedisCacheTest.php @@ -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