liuggio / fastest

Simple parallel testing execution... with some goodies for functional tests.
MIT License
475 stars 65 forks source link

Can't seem to ever access fastest ENV vars #129

Closed kirkbushell closed 6 years ago

kirkbushell commented 6 years ago

I'm currently running a phpunit test suite with its own xml file, and testing against laravel.

I'm trying to setup the suite so that it creates/destroys a database based on the channel the process is using, but the relevant env vars are never available.

Any ideas?

DonCallisto commented 6 years ago

Show us some code please. I've never tested it with PHPUnit. Maybe @francoispluchino can help you.

kirkbushell commented 6 years ago

So what we've done is configure database.php for laravel, and calling for the test channel from fastest:

'testing' => [
            'driver'    => env('TESTING_DB_DRIVER', 'mysql'),
            'host'      => env('TESTING_DB_HOST', 'localhost'),
            'database'  => env('TESTING_DB_DATABASE', 'af_testing').'_'.env('ENV_TEST_CHANNEL'),
            'username'  => env('TESTING_DB_USERNAME', 'af_testing'),
            'password'  => env('TESTING_DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => str_random(8).'_',
            'strict'    => false,
        ],

This would theoretically allow us to setup 4 or more databases that the tests could be run on. Unfortunately, the ENV_TEST_CHANNEL is never available.

DonCallisto commented 6 years ago

env is not modified anyhow AFAIK. Have you tried with https://github.com/liuggio/fastest/blob/3e2b96d2d681b8d54e8d1309d03f1299aa2f19de/README.md#sqlite-databases

Don't know if this solve.

kirkbushell commented 6 years ago

The docs state that there are various env vars injected for use - including the test channel.

We can't use sqlite databases, for a variety of reasons.

DonCallisto commented 6 years ago

You're right, I was just focusing on __DATABASE__ placeholder. BTW in my projects all works. Just wondering if env instead of getenv (I don't use laravel but AFAIK is should only be a kind "of wrapper") is messing things around. Have you tried to dump the env variables? Moreover, could you replicate it in a open repo in order to let me try tackle this? I've tried locally but it works :\

kirkbushell commented 6 years ago

@DonCallisto getenv seems to work, so I think there may be a bug with the env() wrapper in that library. So I'm able to get the various processes now but seeing some weirdness with our setup which I'm trying to work out. In any case, I'd consider this issue closed. Thanks :)