8000 fix SYMFONY_DEPRECATIONS_HELPER env is empty in bootstrap · symfony/symfony@aecd60d · GitHub
[go: up one dir, main page]

Skip to content

Commit aecd60d

Browse files
author
Emmanuel BORGES
committed
fix SYMFONY_DEPRECATIONS_HELPER env is empty in bootstrap
1 parent b296860 commit aecd60d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Symfony/Bridge/PhpUnit/bootstrap.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@
3535
}
3636
}
3737

38+
// load an .env.test file for override phpunit.xml(.dist) vars
39+
$path = dirname(getenv('SYMFONY_PHPUNIT_DIR'), 2);
40+
if (file_exists($path.'/vendor/autoload.php')) {
41+
$loader = clone require $path.'/vendor/autoload.php';
42+
if (!class_exists(\Symfony\Component\Dotenv\Dotenv::class)) {
43+
throw new \RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
44+
}
45+
46+
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
47+
$path .= '/.env.'.(false !== getenv('APP_ENV') ? getenv('APP_ENV'): 'test');
48+
if (file_exists($p = $path)) {
49+
$dotenv->load($p);
50+
}
51+
52+
$loader->unregister();
53+
}
54+
3855
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
3956
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
4057
}

0 commit comments

Comments
 (0)
0