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.
16
* @author Sebastian Bergmann <sebastian@phpunit.de>
17
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
18
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
19
* @link http://www.phpunit.de/
20
* @since Class available since Release 4.0.0
22
class PHPUnit_Util_Blacklist
27
public static $blacklistedClassNames = array(
29
'PHP_CodeCoverage' => 1,
33
'PHPUnit_Framework_TestCase' => 2,
34
'PHPUnit_Extensions_Database_TestCase' => 2,
35
'PHPUnit_Framework_MockObject_Generator' => 2,
36
'PHPUnit_Extensions_SeleniumTestCase' => 2,
37
'PHPUnit_Extensions_Story_TestCase' => 2,
39
'Symfony\Component\Yaml\Yaml' => 1,
40
'SebastianBergmann\Diff\Diff' => 1,
41
'SebastianBergmann\Environment\Runtime' => 1,
42
'SebastianBergmann\Comparator\Comparator' => 1,
43
'SebastianBergmann\Exporter\Exporter' => 1,
44
'SebastianBergmann\RecursionContext\Context' => 1,
45
'SebastianBergmann\Version' => 1,
46
'Composer\Autoload\ClassLoader' => 1,
47
'Doctrine\Instantiator\Instantiator' => 1
53
private static $directories;
57
* @since Method available since Release 4.1.0
59
public function getBlacklistedDirectories()
63
return self::$directories;
70
public function isBlacklisted($file)
72
if (defined('PHPUNIT_TESTSUITE')) {
78
foreach (self::$directories as $directory) {
79
if (strpos($file, $directory) === 0) {
87
private function initialize()
89
if (self::$directories === null) {
90
self::$directories = array();
92
foreach (self::$blacklistedClassNames as $className => $parent) {
93
if (!class_exists($className)) {
97
$reflector = new ReflectionClass($className);
98
$directory = $reflector->getFileName();
100
for ($i = 0; $i < $parent; $i++) {
101
$directory = dirname($directory);
104
self::$directories[] = $directory;
107
// Hide process isolation workaround on Windows.
108
// @see PHPUnit_Util_PHP::factory()
109
// @see PHPUnit_Util_PHP_Windows::process()
110
if (DIRECTORY_SEPARATOR === '\\') {
111
// tempnam() prefix is limited to first 3 chars.
112
// @see http://php.net/manual/en/function.tempnam.php
113
self::$directories[] = sys_get_temp_dir() . '\\PHP';