Skip to content

bootstrap.php breaks when running PHPUnit #512

@cameronmurphy

Description

@cameronmurphy

On a vanilla install of Symfony 4.2, running PHPUnit fails with the error Undefined index: APP_ENV. I traced the issue down to the use of elvis operators instead of null coalesce operators (used on the next line) in config/bootstrap.php.

I was able to resolve by changing

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';

to

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'dev';

in config/bootstrap.php.

Steps to reproduce (tested with CentOS 7, PHP 7.2.13, Symfony CLI 4.2.2)

$ symfony new --full test
$ cd test
$ bin/phpunit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions