1414use Cache \Hierarchy \Tests \Helper \CachePool ;
1515
1616/**
17- * We should not use constans on interfaces in the tests. Tests should break if the constant is changed.
17+ * We should not use constants on interfaces in the tests. Tests should break if the constant is changed.
1818 *
1919 * @author Tobias Nyholm <[email protected] > 2020 */
2121class HierarchicalCachePoolTest extends \PHPUnit_Framework_TestCase
2222{
23+ private function assertEqualsSha1 ($ expected , $ result , $ message = '' )
24+ {
25+ $ this ->assertEquals (sha1 ($ expected ), $ result , $ message );
26+ }
27+
2328 public function testGetHierarchyKey ()
2429 {
2530 $ path = null ;
@@ -31,13 +36,13 @@ public function testGetHierarchyKey()
3136
3237 $ pool = new CachePool (['idx_1 ' , 'idx_2 ' , 'idx_3 ' ]);
3338 $ result = $ pool ->exposeGetHierarchyKey ('|foo|bar ' , $ path );
34- $ this ->assertEquals ('root!!idx_1!foo!!idx_2!bar!!idx_3! ' , $ result );
35- $ this ->assertEquals ('path!root!!idx_1!foo!!idx_2!bar! ' , $ path );
39+ $ this ->assertEqualsSha1 ('root!!idx_1!foo!!idx_2!bar!!idx_3! ' , $ result );
40+ $ this ->assertEqualsSha1 ('path!root!!idx_1!foo!!idx_2!bar! ' , $ path );
3641
3742 $ pool = new CachePool (['idx_1 ' , 'idx_2 ' , 'idx_3 ' ]);
3843 $ result = $ pool ->exposeGetHierarchyKey ('| ' , $ path );
39- $ this ->assertEquals ('path!root! ' , $ path );
40- $ this ->assertEquals ('root!!idx_1! ' , $ result );
44+ $ this ->assertEqualsSha1 ('path!root! ' , $ path );
45+ $ this ->assertEqualsSha1 ('root!!idx_1! ' , $ result );
4146 }
4247
4348 public function testGetHierarchyKeyWithTags ()
@@ -51,13 +56,13 @@ public function testGetHierarchyKeyWithTags()
5156
5257 $ pool = new CachePool (['idx_1 ' , 'idx_2 ' , 'idx_3 ' ]);
5358 $ result = $ pool ->exposeGetHierarchyKey ('|foo|bar!tagHash ' , $ path );
54- $ this ->assertEquals ('root!tagHash!idx_1!foo!tagHash!idx_2!bar!tagHash!idx_3! ' , $ result );
55- $ this ->assertEquals ('path!root!tagHash!idx_1!foo!tagHash!idx_2!bar!tagHash ' , $ path );
59+ $ this ->assertEqualsSha1 ('root!tagHash!idx_1!foo!tagHash!idx_2!bar!tagHash!idx_3! ' , $ result );
60+ $ this ->assertEqualsSha1 ('path!root!tagHash!idx_1!foo!tagHash!idx_2!bar!tagHash ' , $ path );
5661
5762 $ pool = new CachePool (['idx_1 ' , 'idx_2 ' , 'idx_3 ' ]);
5863 $ result = $ pool ->exposeGetHierarchyKey ('|!tagHash ' , $ path );
59- $ this ->assertEquals ('path!root!tagHash ' , $ path );
60- $ this ->assertEquals ('root!tagHash!idx_1! ' , $ result );
64+ $ this ->assertEqualsSha1 ('path!root!tagHash ' , $ path );
65+ $ this ->assertEqualsSha1 ('root!tagHash!idx_1! ' , $ result );
6166 }
6267
6368 public function testGetHierarchyKeyEmptyCache ()
@@ -70,12 +75,12 @@ public function testGetHierarchyKeyEmptyCache()
7075 $ this ->assertNull ($ path );
7176
7277 $ result = $ pool ->exposeGetHierarchyKey ('|foo|bar ' , $ path );
73- $ this ->assertEquals ('root!!!foo!!!bar!!! ' , $ result );
74- $ this ->assertEquals ('path!root!!!foo!!!bar! ' , $ path );
78+ $ this ->assertEqualsSha1 ('root!!!foo!!!bar!!! ' , $ result );
79+ $ this ->assertEqualsSha1 ('path!root!!!foo!!!bar! ' , $ path );
7580
7681 $ result = $ pool ->exposeGetHierarchyKey ('| ' , $ path );
77- $ this ->assertEquals ('path!root! ' , $ path );
78- $ this ->assertEquals ('root!!! ' , $ result );
82+ $ this ->assertEqualsSha1 ('path!root! ' , $ path );
83+ $ this ->assertEqualsSha1 ('root!!! ' , $ result );
7984 }
8085
8186 public function testKeyCache ()
@@ -84,13 +89,13 @@ public function testKeyCache()
8489
8590 $ pool = new CachePool (['idx_1 ' , 'idx_2 ' , 'idx_3 ' ]);
8691 $ result = $ pool ->exposeGetHierarchyKey ('|foo ' , $ path );
87- $ this ->assertEquals ('root!!idx_1!foo!!idx_2! ' , $ result );
88- $ this ->assertEquals ('path!root!!idx_1!foo! ' , $ path );
92+ $ this ->assertEqualsSha1 ('root!!idx_1!foo!!idx_2! ' , $ result );
93+ $ this ->assertEqualsSha1 ('path!root!!idx_1!foo! ' , $ path );
8994
9095 // Make sure re reuse the old index value we already looked up for 'root'.
9196 $ result = $ pool ->exposeGetHierarchyKey ('|bar ' , $ path );
92- $ this ->assertEquals ('root!!idx_1!bar!!idx_3! ' , $ result );
93- $ this ->assertEquals ('path!root!!idx_1!bar! ' , $ path );
97+ $ this ->assertEqualsSha1 ('root!!idx_1!bar!!idx_3! ' , $ result );
98+ $ this ->assertEqualsSha1 ('path!root!!idx_1!bar! ' , $ path );
9499 }
95100
96101 public function testClearHierarchyKeyCache ()
0 commit comments