Skip to content

Commit 2003a9e

Browse files
authored
Merge pull request #38 from DamImpr/test_array_depth
test method with depth array greater than 1
2 parents 7148ba9 + 3439484 commit 2003a9e

6 files changed

Lines changed: 55 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@
2626
- [2026-01-16] DamImpr: hotfix null value [#36](https://github.com/DamImpr/cache-multi-layer/pull/36)
2727

2828
- [2026-01-16] DamImpr: chore: update CHANGELOG for PR #36 [#37](https://github.com/DamImpr/cache-multi-layer/pull/37)
29+
30+
- [2026-01-16] DamImpr: test method with depth array greater than 1 [#38](https://github.com/DamImpr/cache-multi-layer/pull/38)

tests/AbstractCache.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ public function testArray(): void
8686
$this->assertEquals($val, $x);
8787
}
8888

89+
public function testArrayDepth(): void
90+
{
91+
$x = [1, 2, 3, null, [
92+
1, 2, 3, null, [
93+
1, 2, 3, null
94+
]
95+
]
96+
];
97+
$key = 'test_array_depth';
98+
$res = $this->cache->set($key, $x);
99+
$this->assertTrue($res);
100+
$val = $this->cache->get($key);
101+
$this->testRecursiveArray($x, $val);
102+
}
103+
89104
public function testClass(): void
90105
{
91106
$key = 'test_class';
@@ -187,4 +202,16 @@ public final function getCache(): ?Cache
187202
{
188203
return $this->cache;
189204
}
205+
206+
private function testRecursiveArray(array $actual, array $expected): void
207+
{
208+
foreach($expected as $key => $value){
209+
$this->assertArrayHasKey($key, $actual);
210+
if(is_array($value)){
211+
$this->testRecursiveArray($value, $actual[$key]);
212+
} else {
213+
$this->assertEquals($value, $actual[$key]);
214+
}
215+
}
216+
}
190217
}

tests/ApcuCacheTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ public static function tearDownAfterClass(): void
144144
parent::tearDownAfterClass();
145145
Cache::factory(CacheEnum::APCU, 60)->clearAllCache();
146146
}
147+
148+
#[\Override]
149+
public function testArrayDepth(): void
150+
{
151+
parent::testArrayDepth();
152+
}
147153

148154
/**
149155
*

tests/MemcacheCacheTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,19 @@ public function testPrefix(): void
156156
{
157157
$val = 10; //maradona
158158
$key = "test_prefix";
159-
$cacheSamePrefix = Cache::factory(CacheEnum::MEMCACHE, 60, ['key_prefix' => '','server_address' => 'memcache-server']);
160-
$cacheOtherPrefix = Cache::factory(CacheEnum::MEMCACHE, 10, ['key_prefix' => 'other_','server_address' => 'memcache-server']);
159+
$cacheSamePrefix = Cache::factory(CacheEnum::MEMCACHE, 60, ['key_prefix' => '', 'server_address' => 'memcache-server']);
160+
$cacheOtherPrefix = Cache::factory(CacheEnum::MEMCACHE, 10, ['key_prefix' => 'other_', 'server_address' => 'memcache-server']);
161161
$this->getCache()->set($key, $val);
162162
$this->assertEquals($cacheSamePrefix->get($key), $val);
163163
$this->assertNull($cacheOtherPrefix->get($key));
164164
}
165165

166+
#[\Override]
167+
public function testArrayDepth(): void
168+
{
169+
parent::testArrayDepth();
170+
}
171+
166172
#[\Override]
167173
public static function tearDownAfterClass(): void
168174
{

tests/PRedisCacheTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ public function testPrefix(): void
166166
$this->assertEquals($cacheSamePrefix->get($key), $val);
167167
$this->assertNull($cacheOtherPrefix->get($key));
168168
}
169+
170+
#[\Override]
171+
public function testArrayDepth(): void
172+
{
173+
parent::testArrayDepth();
174+
}
169175

170176
#[\Override]
171177
public static function tearDownAfterClass(): void

tests/RedisCacheTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ public function testPrefix(): void
163163
$this->assertEquals($cacheSamePrefix->get($key), $val);
164164
$this->assertNull($cacheOtherPrefix->get($key));
165165
}
166+
167+
#[\Override]
168+
public function testArrayDepth(): void
169+
{
170+
parent::testArrayDepth();
171+
}
166172

167173
#[\Override]
168174
public static function tearDownAfterClass(): void

0 commit comments

Comments
 (0)