-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpunit-bootstrap.php
More file actions
53 lines (46 loc) · 1.59 KB
/
phpunit-bootstrap.php
File metadata and controls
53 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
if (\defined('PHP_CODESNIFFER_IN_TESTS') === false) {
\define('PHP_CODESNIFFER_IN_TESTS', true);
}
/*
* Load the necessary PHPCS files.
*/
// Get the PHPCS dir from an environment variable.
$phpcsDir = \getenv('PHPCS_DIR');
$composerPHPCSPath = __DIR__ . '/vendor/squizlabs/php_codesniffer';
if ($phpcsDir === false && \is_dir($composerPHPCSPath)) {
// PHPCS installed via Composer.
$phpcsDir = $composerPHPCSPath;
}
elseif ($phpcsDir !== false) {
/*
* PHPCS in a custom directory.
* For this to work, the `PHPCS_DIR` needs to be set in a custom `phpunit.xml` file.
*/
$phpcsDir = \realpath($phpcsDir);
}
// Try and load the PHPCS autoloader.
if ($phpcsDir !== false
&& \file_exists($phpcsDir . '/autoload.php')
&& \file_exists($phpcsDir . '/tests/bootstrap.php')
) {
require_once $phpcsDir . '/autoload.php';
require_once $phpcsDir . '/tests/bootstrap.php';
} else {
echo 'Uh oh... can\'t find PHPCS.
If you use Composer, please run `composer install`.
Otherwise, make sure you set a `PHPCS_DIR` environment variable in your phpunit.xml file
pointing to the PHPCS directory and that PHPCSUtils is included in the `installed_paths`
for that PHPCS install.
';
exit(1);
}
// Alias the PHPCS 3.x test case to the PHPCS 4.x name.
if (class_exists('PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest') === true
&& class_exists('PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase') === false
) {
class_alias(
'PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest',
'PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase'
);
}