@@ -30,8 +30,7 @@ public function testLineDataFromStandardXDebugFormat(): void
3030 }
3131
3232 /**
33- * In the path-coverage XDebug format, the line data exists inside a "lines" array key where the file has
34- * classes or functions. For files without them, the data is stored in the line-only format.
33+ * In the path-coverage XDebug format, the line data exists inside a "lines" array key.
3534 */
3635 public function testLineDataFromPathCoverageXDebugFormat (): void
3736 {
@@ -46,6 +45,53 @@ public function testLineDataFromPathCoverageXDebugFormat(): void
4645
4746 ],
4847 ],
48+ '/some/path/justAScript.php ' => [
49+ 'lines ' => [
50+ 18 => 1 ,
51+ 19 => -2 ,
52+ 113 => -1 ,
53+ ],
54+ 'functions ' => [
55+
56+ ],
57+ ],
58+ ];
59+
60+ $ lineData = [
61+ '/some/path/SomeClass.php ' => [
62+ 8 => 1 ,
63+ 9 => -2 ,
64+ 13 => -1 ,
65+ ],
66+ '/some/path/justAScript.php ' => [
67+ 18 => 1 ,
68+ 19 => -2 ,
69+ 113 => -1 ,
70+ ],
71+ ];
72+
73+ $ dataObject = RawCodeCoverageData::fromXdebugWithPathCoverage ($ rawDataFromDriver );
74+
75+ $ this ->assertEquals ($ lineData , $ dataObject ->lineCoverage ());
76+ }
77+
78+ /**
79+ * In the path-coverage XDebug format for Xdebug < 2.9.6, the line data exists inside a "lines" array key where the
80+ * file has classes or functions. For files without them, the data is stored in the line-only format.
81+ */
82+ public function testLineDataFromMixedCoverageXDebugFormat (): void
83+ {
84+ $ rawDataFromDriver = [
85+ '/some/path/SomeClass.php ' => [
86+ 'lines ' => [
87+ 8 => 1 ,
88+ 9 => -2 ,
89+ 13 => -1 ,
90+ ],
91+ 'functions ' => [
92+
93+ ],
94+ ],
4995 '/some/path/justAScript.php ' => [
5096 18 => 1 ,
5197 19 => -2 ,
@@ -66,7 +112,7 @@ public function testLineDataFromPathCoverageXDebugFormat(): void
66112 ],
67113 ];
68114
69- $ dataObject = RawCodeCoverageData::fromXdebugWithPathCoverage ($ rawDataFromDriver );
115+ $ dataObject = RawCodeCoverageData::fromXdebugWithMixedCoverage ($ rawDataFromDriver );
70116
71117 $ this ->assertEquals ($ lineData , $ dataObject ->lineCoverage ());
72118 }
0 commit comments