Skip to content

Commit 8908717

Browse files
Do not register Composer-generated autoloader when running PHPUnit's own test suite using a PHAR
1 parent 0bdef05 commit 8908717

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tests/bootstrap.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,29 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10+
const TEST_FILES_PATH = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR;
11+
12+
if (defined('__PHPUNIT_PHAR__')) {
13+
if (!file_exists(__DIR__ . '/autoload.php')) {
14+
print __DIR__ . '/autoload.php does not exist' . PHP_EOL;
15+
16+
exit(1);
17+
}
18+
19+
require_once __DIR__ . '/autoload.php';
20+
21+
$jsonFile = realpath(__DIR__ . '/../composer.json');
22+
$base = dirname($jsonFile);
23+
24+
foreach (json_decode(file_get_contents($jsonFile), true)['autoload-dev']['files'] as $file) {
25+
require_once $base . DIRECTORY_SEPARATOR . $file;
26+
}
27+
28+
return;
29+
}
30+
1031
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
1132
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__) . '/vendor/autoload.php');
1233
}
1334

14-
const TEST_FILES_PATH = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR;
15-
1635
require_once PHPUNIT_COMPOSER_INSTALL;

0 commit comments

Comments
 (0)