9
9
use Composite \DB \Tests \TestStand \Tables ;
10
10
use Composite \Entity \AbstractEntity ;
11
11
use Composite \DB \Tests \Helpers ;
12
+ use Ramsey \Uuid \Uuid ;
12
13
13
14
final class AbstractCachedTableTest extends \PHPUnit \Framework \TestCase
14
15
{
15
16
public static function getOneCacheKey_dataProvider (): array
16
17
{
17
18
$ cache = Helpers \CacheHelper::getCache ();
19
+ $ uuid = Uuid::uuid4 ();
20
+ $ uuidCacheKey = str_replace ('- ' , '_ ' , (string )$ uuid );
18
21
return [
19
22
[
20
23
new Tables \TestAutoincrementCachedTable ($ cache ),
@@ -28,24 +31,21 @@ public static function getOneCacheKey_dataProvider(): array
28
31
],
29
32
[
30
33
new Tables \TestUniqueCachedTable ($ cache ),
31
- new Entities \TestUniqueEntity (id: ' 123abc ' , name: 'John ' ),
32
- 'sqlite.TestUnique.v1.o.id_123abc ' ,
34
+ new Entities \TestUniqueEntity (id: $ uuid , name: 'John ' ),
35
+ 'sqlite.TestUnique.v1.o.id_ ' . $ uuidCacheKey ,
33
36
],
34
37
[
35
- new Tables \TestUniqueCachedTable ($ cache ),
36
- new Entities \TestUniqueEntity (
37
- id: implode ('' , array_fill (0 , 100 , 'a ' )),
38
- name: 'John ' ,
39
- ),
40
- 'ed66f06444d851a981a9ddcecbbf4d5860cd3131 ' ,
38
+ new Tables \TestCompositeCachedTable ($ cache ),
39
+ new Entities \TestCompositeEntity (user_id: PHP_INT_MAX , post_id: PHP_INT_MAX , message: 'Text ' ),
40
+ '69b5bbf599d78f0274feb5cb0e6424f35cca0b57 ' ,
41
41
],
42
42
];
43
43
}
44
44
45
45
/**
46
46
* @dataProvider getOneCacheKey_dataProvider
47
47
*/
48
- public function test_getOneCacheKey (AbstractTable $ table , AbstractEntity $ object , string $ expected ): void
48
+ public function test_getOneCacheKey (AbstractCachedTable $ table , AbstractEntity $ object , string $ expected ): void
49
49
{
50
50
$ reflectionMethod = new \ReflectionMethod ($ table , 'getOneCacheKey ' );
51
51
$ actual = $ reflectionMethod ->invoke ($ table , $ object );
@@ -194,6 +194,8 @@ public function test_getCustomCacheKey(array $parts, string $expected): void
194
194
195
195
public static function collectCacheKeysByEntity_dataProvider (): array
196
196
{
197
+ $ uuid = Uuid::uuid4 ();
198
+ $ uuidCacheKey = str_replace ('- ' , '_ ' , (string )$ uuid );
197
199
return [
198
200
[
199
201
new Entities \TestAutoincrementEntity (name: 'foo ' ),
@@ -215,21 +217,21 @@ public static function collectCacheKeysByEntity_dataProvider(): array
215
217
],
216
218
],
217
219
[
218
- new Entities \TestUniqueEntity (id: ' 123abc ' , name: 'foo ' ),
220
+ new Entities \TestUniqueEntity (id: $ uuid , name: 'foo ' ),
219
221
new Tables \TestUniqueCachedTable (Helpers \CacheHelper::getCache ()),
220
222
[
221
223
'sqlite.TestUnique.v1.l.name_eq_foo ' ,
222
224
'sqlite.TestUnique.v1.c.name_eq_foo ' ,
223
- 'sqlite.TestUnique.v1.o.id_123abc ' ,
225
+ 'sqlite.TestUnique.v1.o.id_ ' . $ uuidCacheKey ,
224
226
],
225
227
],
226
228
[
227
- Entities \TestUniqueEntity::fromArray (['id ' => ' 456def ' , 'name ' => 'bar ' ]),
229
+ Entities \TestUniqueEntity::fromArray (['id ' => $ uuid , 'name ' => 'bar ' ]),
228
230
new Tables \TestUniqueCachedTable (Helpers \CacheHelper::getCache ()),
229
231
[
230
232
'sqlite.TestUnique.v1.l.name_eq_bar ' ,
231
233
'sqlite.TestUnique.v1.c.name_eq_bar ' ,
232
- 'sqlite.TestUnique.v1.o.id_456def ' ,
234
+ 'sqlite.TestUnique.v1.o.id_ ' . $ uuidCacheKey ,
233
235
],
234
236
],
235
237
];
0 commit comments