Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 28, 2021
1 parent 39e2172 commit 58da926
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,30 @@
*/
const TEST_FILES_PATH = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR;

if (file_exists(__DIR__ . '/../vendor/autoload.php') && file_exists(__DIR__ . '/autoload.php')) {
print 'More than one test fixture autoloader is available, exiting.' . \PHP_EOL;
$composer = file_exists(__DIR__ . '/../vendor/autoload.php');
$phar = file_exists(__DIR__ . '/autoload.php');

if ($composer && $phar) {
print 'More than one test fixture autoloader is available, exiting.' . PHP_EOL;

exit(1);
}

if (!$composer && !$phar) {
print 'No test fixture autoloader was registered, exiting.' . PHP_EOL;

exit(1);
}

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
if ($composer) {
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__) . '/vendor/autoload.php');
}

require_once __DIR__ . '/../vendor/autoload.php';

return;
}

if (file_exists(__DIR__ . '/autoload.php')) {
if ($phar) {
if (!defined('__PHPUNIT_PHAR__')) {
require_once __DIR__ . '/../build/artifacts/phpunit-snapshot.phar';
}
Expand All @@ -38,12 +45,6 @@
foreach (json_decode(file_get_contents($jsonFile), true)['autoload-dev']['files'] as $file) {
require_once $base . DIRECTORY_SEPARATOR . $file;
}

unset($jsonFile, $base, $file);

return;
}

print 'No test fixture autoloader was registered, exiting.' . \PHP_EOL;

exit(1);
unset($composer, $phar, $jsonFile, $base, $file);

0 comments on commit 58da926

Please sign in to comment.