File tree Expand file tree Collapse file tree 3 files changed +55
-2
lines changed Expand file tree Collapse file tree 3 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,31 @@ public function merge(self $that): void
380
380
continue ;
381
381
}
382
382
383
+ if ((count ($ lines ) > 0 )
384
+ && (count ($ this ->data [$ file ]) > 0 )
385
+ && (count ($ lines ) != count ($ this ->data [$ file ]))
386
+ ) {
387
+ if (count ($ lines ) > count ($ ours = $ this ->data [$ file ])) {
388
+ // More lines in the one being added in
389
+ $ lines = array_filter (
390
+ $ lines ,
391
+ function ($ value , $ key ) use ($ ours ) {
392
+ return array_key_exists ($ key , $ ours );
393
+ },
394
+ ARRAY_FILTER_USE_BOTH
395
+ );
396
+ } else {
397
+ // More lines in the one we currently have
398
+ $ this ->data [$ file ] = array_filter (
399
+ $ this ->data [$ file ],
400
+ function ($ value , $ key ) use ($ lines ) {
401
+ return array_key_exists ($ key , $ lines );
402
+ },
403
+ ARRAY_FILTER_USE_BOTH
404
+ );
405
+ }
406
+ }
407
+
383
408
foreach ($ lines as $ line => $ data ) {
384
409
if ($ data !== null ) {
385
410
if (!isset ($ this ->data [$ file ][$ line ])) {
Original file line number Diff line number Diff line change @@ -231,6 +231,34 @@ protected function getCoverageForBankAccountForLastTwoTests()
231
231
}
232
232
233
233
protected function getExpectedDataArrayForBankAccount ()
234
+ {
235
+ return [
236
+ TEST_FILES_PATH . 'BankAccount.php ' => [
237
+ 8 => [
238
+ 0 => 'BankAccountTest::testBalanceIsInitiallyZero ' ,
239
+ 1 => 'BankAccountTest::testDepositWithdrawMoney '
240
+ ],
241
+ 13 => [],
242
+ 16 => [],
243
+ 22 => [
244
+ 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2 ' ,
245
+ 1 => 'BankAccountTest::testDepositWithdrawMoney '
246
+ ],
247
+ 24 => [
248
+ 0 => 'BankAccountTest::testDepositWithdrawMoney ' ,
249
+ ],
250
+ 29 => [
251
+ 0 => 'BankAccountTest::testBalanceCannotBecomeNegative ' ,
252
+ 1 => 'BankAccountTest::testDepositWithdrawMoney '
253
+ ],
254
+ 31 => [
255
+ 0 => 'BankAccountTest::testDepositWithdrawMoney '
256
+ ],
257
+ ]
258
+ ];
259
+ }
260
+
261
+ protected function getExpectedDataArrayForBankAccount2 ()
234
262
{
235
263
return [
236
264
TEST_FILES_PATH . 'BankAccount.php ' => [
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ public function testCollect()
215
215
$ coverage = $ this ->getCoverageForBankAccount ();
216
216
217
217
$ this ->assertEquals (
218
- $ this ->getExpectedDataArrayForBankAccount (),
218
+ $ this ->getExpectedDataArrayForBankAccount2 (),
219
219
$ coverage ->getData ()
220
220
);
221
221
@@ -251,7 +251,7 @@ public function testMerge2()
251
251
$ coverage ->merge ($ this ->getCoverageForBankAccount ());
252
252
253
253
$ this ->assertEquals (
254
- $ this ->getExpectedDataArrayForBankAccount (),
254
+ $ this ->getExpectedDataArrayForBankAccount2 (),
255
255
$ coverage ->getData ()
256
256
);
257
257
}
You can’t perform that action at this time.
0 commit comments