File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,14 @@ public function clear(): void
150150 $ this ->cachedReport = null ;
151151 }
152152
153+ /**
154+ * @internal
155+ */
156+ public function clearCache (): void
157+ {
158+ $ this ->cachedReport = null ;
159+ }
160+
153161 /**
154162 * Returns the filter object used.
155163 */
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ final class PHP
2121{
2222 public function process (CodeCoverage $ coverage , ?string $ target = null ): string
2323 {
24+ $ coverage ->clearCache ();
25+
2426 $ buffer = "<?php
2527return \u nserialize(<<<'END_OF_COVERAGE_SERIALIZATION' " . PHP_EOL . serialize ($ coverage ) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION ' . PHP_EOL . '); ' ;
2628
Original file line number Diff line number Diff line change 99 */
1010namespace SebastianBergmann \CodeCoverage \Report ;
1111
12+ use ReflectionProperty ;
1213use SebastianBergmann \CodeCoverage \TestCase ;
1314
1415final class PhpTest extends TestCase
@@ -43,4 +44,21 @@ public function testPHPSerialisationProducesValidCodeWhenOutputIncludesSingleQuo
4344
4445 $ this ->assertEquals ($ coverage , $ unserialized );
4546 }
47+
48+ public function testCacheDataNeverGetSaved (): void
49+ {
50+ $ coverage = $ this ->getLineCoverageForBankAccount ();
51+
52+ // Warm up cache
53+ $ coverage ->getReport ();
54+
55+ $ refProperty = new ReflectionProperty ($ coverage , 'cachedReport ' );
56+
57+ $ this ->assertNotNull ($ refProperty ->getValue ($ coverage ));
58+
59+ /* @noinspection UnusedFunctionResultInspection */
60+ (new PHP )->process ($ coverage , self ::$ TEST_TMP_PATH . '/serialized.php ' );
61+
62+ $ this ->assertNull ($ refProperty ->getValue ($ coverage ));
63+ }
4664}
You can’t perform that action at this time.
0 commit comments