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
150
150
$ this ->cachedReport = null ;
151
151
}
152
152
153
+ /**
154
+ * @internal
155
+ */
156
+ public function clearCache (): void
157
+ {
158
+ $ this ->cachedReport = null ;
159
+ }
160
+
153
161
/**
154
162
* Returns the filter object used.
155
163
*/
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ final class PHP
21
21
{
22
22
public function process (CodeCoverage $ coverage , ?string $ target = null ): string
23
23
{
24
+ $ coverage ->clearCache ();
25
+
24
26
$ buffer = "<?php
25
27
return \u nserialize(<<<'END_OF_COVERAGE_SERIALIZATION' " . PHP_EOL . serialize ($ coverage ) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION ' . PHP_EOL . '); ' ;
26
28
Original file line number Diff line number Diff line change 9
9
*/
10
10
namespace SebastianBergmann \CodeCoverage \Report ;
11
11
12
+ use ReflectionProperty ;
12
13
use SebastianBergmann \CodeCoverage \TestCase ;
13
14
14
15
final class PhpTest extends TestCase
@@ -43,4 +44,21 @@ public function testPHPSerialisationProducesValidCodeWhenOutputIncludesSingleQuo
43
44
44
45
$ this ->assertEquals ($ coverage , $ unserialized );
45
46
}
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
+ }
46
64
}
You can’t perform that action at this time.
0 commit comments