roadrunner-php / laravel-bridge

πŸŒ‰ RoadRunner ⇆ Laravel bridge πŸ‡ΊπŸ‡¦β€οΈ
https://roadrunner.dev/docs/integration-laravel
MIT License
372 stars 25 forks source link

Tests not loaded env from phpunit.xml #132

Closed Rev8Crew closed 1 year ago

Rev8Crew commented 1 year ago

Describe the bug

When I run php artisan test, I expect that my env is testing, but in real env is local. I testing this with https://github.com/tarampampam/laravel-roadrunner-in-docker project image image

Expected behaviour

env must be taken from $_ENV

Actual behaviour

env taken from .env

Steps to reproduce

download https://github.com/tarampampam/laravel-roadrunner-in-docker

make install
make init
make shell
php artisan test

System information

Please, complete the following information:

Key Value
PHP version 8.2
Current package version 5.12
RoadRunner version 2.12.3
Environment docker-wsl

RoadRunner configuration file content

from https://github.com/tarampampam/laravel-roadrunner-in-docker

Package configuration file content

from https://github.com/tarampampam/laravel-roadrunner-in-docker

Additional context

Add any other context about the problem here. Additionally I try to debug LoadEnvironmentVariables::checkForSpecificEnvironmentFile().


$environment = Env::get('APP_ENV');
    var_dump($environment);
    var_dump($_ENV);
    if (! $environment) {
        return;
    }

I get output:
`string(5) "local"
array(0) {
}
`
And when code reach CreatesApplication trait $_ENV is correct:
```php
    public function createApplication()
    {
        /** @var \Illuminate\Foundation\Application $app */
        $app = require __DIR__.'/../bootstrap/app.php';

        $app->make(Kernel::class)->bootstrap();

        \rr\dump($app->runningInConsole(), $_ENV);
        return $app;
    }

output

true
array:10 [
  "APP_ENV" => "testing"
  "BCRYPT_ROUNDS" => "4"
  "CACHE_DRIVER" => "redis"
  "DB_CONNECTION" => "pgsql"
  "DB_DATABASE" => "insap"
  "MAIL_MAILER" => "smtp"
  "QUEUE_CONNECTION" => "rabbitmq"
  "SESSION_DRIVER" => "redis"
  "TELESCOPE_ENABLED" => ""
  "SHELL_VERBOSITY" => 0
]
tarampampam commented 1 year ago

How does this issue relate to the laravel-bridge package?

tarampampam commented 1 year ago

Anyway, you can try to set the following values in your phpunit.xml file:

<env name="APP_ENV" value="testing" force="true"/>
<server name="APP_ENV" value="testing"/>

All should be fine after that.

Rev8Crew commented 1 year ago

How does this issue relate to the laravel-bridge package?

Because this issue occurs only when I use roadrunner and in my project the only package that work with roadrunner is this package:)