@@ -68,4 +68,32 @@ public function testCanPersistCacheToFile(): void
68
68
69
69
unlink ($ cacheFile );
70
70
}
71
+
72
+ public function testCanBeMerged (): void
73
+ {
74
+ $ cacheSourceOne = new DefaultResultCache ;
75
+ $ cacheSourceOne ->setStatus ('status.a ' , TestStatus::skipped ());
76
+ $ cacheSourceOne ->setStatus ('status.b ' , TestStatus::incomplete ());
77
+ $ cacheSourceOne ->setTime ('time.a ' , 1 );
78
+ $ cacheSourceOne ->setTime ('time.b ' , 2 );
79
+ $ cacheSourceTwo = new DefaultResultCache ;
80
+ $ cacheSourceTwo ->setStatus ('status.c ' , TestStatus::failure ());
81
+ $ cacheSourceTwo ->setTime ('time.c ' , 4 );
82
+
83
+ $ sum = new DefaultResultCache ;
84
+ $ sum ->mergeWith ($ cacheSourceOne );
85
+
86
+ $ this ->assertSame (TestStatus::skipped ()->asString (), $ sum ->status ('status.a ' )->asString ());
87
+ $ this ->assertSame (TestStatus::incomplete ()->asString (), $ sum ->status ('status.b ' )->asString ());
88
+ $ this ->assertNotSame (TestStatus::failure ()->asString (), $ sum ->status ('status.c ' )->asString ());
89
+
90
+ $ this ->assertSame (1.0 , $ sum ->time ('time.a ' ));
91
+ $ this ->assertSame (2.0 , $ sum ->time ('time.b ' ));
92
+ $ this ->assertNotSame (4.0 , $ sum ->time ('time.c ' ));
93
+
94
+ $ sum ->mergeWith ($ cacheSourceTwo );
95
+
96
+ $ this ->assertSame (TestStatus::failure ()->asString (), $ sum ->status ('status.c ' )->asString ());
97
+ $ this ->assertSame (4.0 , $ sum ->time ('time.c ' ));
98
+ }
71
99
}
0 commit comments