@@ -87,6 +87,11 @@ class PHP_CodeCoverage
87
87
*/
88
88
protected $ currentId ;
89
89
90
+ /**
91
+ * @var array
92
+ */
93
+ protected $ currentFilterGroups = array ('DEFAULT ' );
94
+
90
95
/**
91
96
* Code coverage data.
92
97
*
@@ -199,9 +204,10 @@ public function getReport()
199
204
*/
200
205
public function clear ()
201
206
{
202
- $ this ->currentId = NULL ;
203
- $ this ->data = array ();
204
- $ this ->tests = array ();
207
+ $ this ->currentId = NULL ;
208
+ $ this ->currentFilterGroups = array ('DEFAULT ' );
209
+ $ this ->data = array ();
210
+ $ this ->tests = array ();
205
211
}
206
212
207
213
/**
@@ -244,10 +250,11 @@ public function getTests()
244
250
* Start collection of code coverage information.
245
251
*
246
252
* @param mixed $id
253
+ * @param array $filterGroups
247
254
* @param boolean $clear
248
255
* @throws InvalidArgumentException
249
256
*/
250
- public function start ($ id , $ clear = FALSE )
257
+ public function start ($ id , array $ filterGroups = array ( ' DEFAULT ' ), $ clear = FALSE )
251
258
{
252
259
if (!is_bool ($ clear )) {
253
260
throw new InvalidArgumentException ;
@@ -257,7 +264,8 @@ public function start($id, $clear = FALSE)
257
264
$ this ->clear ();
258
265
}
259
266
260
- $ this ->currentId = $ id ;
267
+ $ this ->currentId = $ id ;
268
+ $ this ->currentFilterGroups = $ filterGroups ;
261
269
262
270
$ this ->driver ->start ();
263
271
}
@@ -293,7 +301,7 @@ public function stop($append = TRUE)
293
301
* @param mixed $id
294
302
* @param array $filterGroups
295
303
*/
296
- public function append (array $ data , $ id = NULL , array $ filterGroups = array ( ' DEFAULT ' ) )
304
+ public function append (array $ data , $ id = NULL , array $ filterGroups = NULL )
297
305
{
298
306
if ($ id === NULL ) {
299
307
$ id = $ this ->currentId ;
@@ -303,6 +311,10 @@ public function append(array $data, $id = NULL, array $filterGroups = array('DEF
303
311
throw new InvalidArgumentException ;
304
312
}
305
313
314
+ if ($ filterGroups === NULL ) {
315
+ $ filterGroups = $ this ->currentFilterGroups ;
316
+ }
317
+
306
318
$ this ->applySelfFilter ($ data );
307
319
$ this ->applyListsFilter ($ data , $ filterGroups );
308
320
$ this ->initializeFilesThatAreSeenTheFirstTime ($ data );
@@ -343,18 +355,27 @@ public function merge(PHP_CodeCoverage $that)
343
355
{
344
356
foreach ($ that ->data as $ file => $ lines ) {
345
357
if (!isset ($ this ->data [$ file ])) {
346
- $ this ->data [$ file ] = $ lines ;
358
+ if (!$ this ->filter ->isFiltered ($ file , $ this ->currentFilterGroups )) {
359
+ $ this ->data [$ file ] = $ lines ;
360
+ }
361
+
347
362
continue ;
348
363
}
349
364
350
365
foreach ($ lines as $ line => $ data ) {
351
366
if ($ data !== NULL ) {
352
- $ this ->data [$ file ][$ line ] = array_unique (
353
- array_merge ($ this ->data [$ file ][$ line ], $ data )
354
- );
367
+ if (!isset ($ this ->data [$ file ][$ line ])) {
368
+ $ this ->data [$ file ][$ line ] = $ data ;
369
+ } else {
370
+ $ this ->data [$ file ][$ line ] = array_unique (
371
+ array_merge ($ this ->data [$ file ][$ line ], $ data )
372
+ );
373
+ }
355
374
}
356
375
}
357
376
}
377
+
378
+ $ this ->tests = array_merge ($ this ->tests , $ that ->getTests ());
358
379
}
359
380
360
381
/**
0 commit comments