3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Utility class for blacklisting PHPUnit's own source code files.
14 * @since Class available since Release 4.0.0
16 class PHPUnit_Util_Blacklist
21 public static $blacklistedClassNames = array(
23 'PHP_CodeCoverage' => 1,
27 'PHPUnit_Framework_TestCase' => 2,
28 'PHPUnit_Extensions_Database_TestCase' => 2,
29 'PHPUnit_Framework_MockObject_Generator' => 2,
30 'PHPUnit_Extensions_SeleniumTestCase' => 2,
32 'Symfony\Component\Yaml\Yaml' => 1,
33 'SebastianBergmann\Diff\Diff' => 1,
34 'SebastianBergmann\Environment\Runtime' => 1,
35 'SebastianBergmann\Comparator\Comparator' => 1,
36 'SebastianBergmann\Exporter\Exporter' => 1,
37 'SebastianBergmann\GlobalState\Snapshot' => 1,
38 'SebastianBergmann\RecursionContext\Context' => 1,
39 'SebastianBergmann\Version' => 1,
40 'Composer\Autoload\ClassLoader' => 1,
41 'Doctrine\Instantiator\Instantiator' => 1,
42 'phpDocumentor\Reflection\DocBlock' => 1,
43 'Prophecy\Prophet' => 1
49 private static $directories;
54 * @since Method available since Release 4.1.0
56 public function getBlacklistedDirectories()
60 return self::$directories;
68 public function isBlacklisted($file)
70 if (defined('PHPUNIT_TESTSUITE')) {
76 foreach (self::$directories as $directory) {
77 if (strpos($file, $directory) === 0) {
85 private function initialize()
87 if (self::$directories === null) {
88 self::$directories = array();
90 foreach (self::$blacklistedClassNames as $className => $parent) {
91 if (!class_exists($className)) {
95 $reflector = new ReflectionClass($className);
96 $directory = $reflector->getFileName();
98 for ($i = 0; $i < $parent; $i++) {
99 $directory = dirname($directory);
102 self::$directories[] = $directory;
105 // Hide process isolation workaround on Windows.
106 // @see PHPUnit_Util_PHP::factory()
107 // @see PHPUnit_Util_PHP_Windows::process()
108 if (DIRECTORY_SEPARATOR === '\\') {
109 // tempnam() prefix is limited to first 3 chars.
110 // @see http://php.net/manual/en/function.tempnam.php
111 self::$directories[] = sys_get_temp_dir() . '\\PHP';