@@ -101,26 +101,6 @@ class PHP_CodeCoverage
101101 */
102102 protected $ tests = array ();
103103
104- /**
105- * @var boolean
106- */
107- protected $ isCodeCoverageTestSuite = FALSE ;
108-
109- /**
110- * @var boolean
111- */
112- protected $ isFileIteratorTestSuite = FALSE ;
113-
114- /**
115- * @var boolean
116- */
117- protected $ isTimerTestSuite = FALSE ;
118-
119- /**
120- * @var boolean
121- */
122- protected $ isTokenStreamTestSuite = FALSE ;
123-
124104 /**
125105 * Constructor.
126106 *
@@ -141,23 +121,34 @@ public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCove
141121 $ this ->driver = $ driver ;
142122 $ this ->filter = $ filter ;
143123
144- if (defined ('PHP_CODECOVERAGE_TESTSUITE ' )) {
145- $ this ->isCodeCoverageTestSuite = TRUE ;
124+ // @codeCoverageIgnoreStart
125+ if (!defined ('PHP_CODECOVERAGE_TESTSUITE ' )) {
126+ $ this ->filter ->addFilesToBlacklist (php_codecoverage_autoload ());
146127 }
147128
148- // @codeCoverageIgnoreStart
149- if (defined ('FILE_ITERATOR_TESTSUITE ' )) {
150- $ this ->isFileIteratorTestSuite = TRUE ;
129+ if (!defined ('PHPUNIT_TESTSUITE ' )) {
130+ $ this ->filter ->addFilesToBlacklist (phpunit_autoload ());
131+ $ this ->filter ->addFilesToBlacklist (phpunit_dbunit_autoload ());
132+ $ this ->filter ->addFilesToBlacklist (phpunit_mockobject_autoload ());
133+ $ this ->filter ->addFilesToBlacklist (phpunit_selenium_autoload ());
134+ $ this ->filter ->addFilesToBlacklist (phpunit_story_autoload ());
135+ }
136+
137+ if (!defined ('FILE_ITERATOR_TESTSUITE ' )) {
138+ $ this ->filter ->addFilesToBlacklist (file_iterator_autoload ());
151139 }
152140
153- if (defined ('PHP_TIMER_TESTSUITE ' )) {
154- $ this ->isTimerTestSuite = TRUE ;
141+ if (!defined ('PHP_TIMER_TESTSUITE ' ) &&
142+ function_exists ('php_timer_autoload ' )) {
143+ $ this ->filter ->addFilesToBlacklist (php_timer_autoload ());
155144 }
156145
157- if (defined ('PHP_TOKENSTREAM_TESTSUITE ' )) {
158- $ this ->isTokenStreamTestSuite = TRUE ;
146+ if (! defined ('PHP_TOKENSTREAM_TESTSUITE ' )) {
147+ $ this ->filter -> addFilesToBlacklist ( php_tokenstream_autoload ()) ;
159148 }
160149 // @codeCoverageIgnoreEnd
150+
151+ $ this ->filter ->addFilesToBlacklist (text_template_autoload ());
161152 }
162153
163154 /**
@@ -268,7 +259,6 @@ public function append(array $data, $id = NULL)
268259 throw new InvalidArgumentException ;
269260 }
270261
271- $ this ->applySelfFilter ($ data );
272262 $ this ->applyListsFilter ($ data );
273263 $ this ->initializeFilesThatAreSeenTheFirstTime ($ data );
274264 $ this ->applyCoversAnnotationFilter ($ data , $ id );
@@ -431,54 +421,6 @@ protected function applyListsFilter(&$data)
431421 }
432422 }
433423
434- /**
435- * Filters sourcecode files from PHP_CodeCoverage, PHP_TokenStream,
436- * Text_Template, and File_Iterator.
437- *
438- * @param array $data
439- * @codeCoverageIgnore
440- */
441- protected function applySelfFilter (&$ data )
442- {
443- foreach (array_keys ($ data ) as $ filename ) {
444- if (!$ this ->filter ->isFile ($ filename )) {
445- unset($ data [$ filename ]);
446- continue ;
447- }
448-
449- if (!$ this ->isCodeCoverageTestSuite &&
450- strpos ($ filename , dirname (__FILE__ )) === 0 ) {
451- unset($ data [$ filename ]);
452- continue ;
453- }
454-
455- if (!$ this ->isFileIteratorTestSuite &&
456- (substr ($ filename , -17 ) == 'File/Iterator.php ' ||
457- substr ($ filename , -25 ) == 'File/Iterator/Factory.php ' )) {
458- unset($ data [$ filename ]);
459- continue ;
460- }
461-
462- if (!$ this ->isTimerTestSuite &&
463- (substr ($ filename , -13 ) == 'PHP/Timer.php ' )) {
464- unset($ data [$ filename ]);
465- continue ;
466- }
467-
468- if (!$ this ->isTokenStreamTestSuite &&
469- (substr ($ filename , -13 ) == 'PHP/Token.php ' ||
470- substr ($ filename , -20 ) == 'PHP/Token/Stream.php ' ||
471- substr ($ filename , -35 ) == 'PHP/Token/Stream/CachingFactory.php ' )) {
472- unset($ data [$ filename ]);
473- continue ;
474- }
475-
476- if (substr ($ filename , -17 ) == 'Text/Template.php ' ) {
477- unset($ data [$ filename ]);
478- }
479- }
480- }
481-
482424 /**
483425 * @since Method available since Release 1.1.0
484426 */
0 commit comments