Closed carlosafonso closed 8 years ago
This is expected.
You must delete the cached config file.
Isn't that what php artisan config:cache
does?
No. That makes a new config cache file.
I see. Indeed, running php artisan config:clear
seems to solve this. Thank you.
If you're open to PRs on the framework's documentation I'm willing to add this to the Testing section. I think developers could benefit from knowing this in advance, if you find it appropriate.
I might just be doing something horribly wrong, but I came across the following behavior in Laravel 5.2.26 with PHP 7.0.4 under OS X 10.11.
I usually work with a Postgres DB in my local environment, and my tests run on an in-memory Sqlite DB. Right now it looks like Laravel ignores the settings for the testing environment.
Please follow these steps to reproduce the issue:
1- Configure you local environment (
.env
) to use an existing DB, and set the correct connection parameters.2- Modify
phpunit.xml
to have different DB settings to be used when running the tests:3- Create a test case like this one (it extends the default
TestCase
):4- Run the tests.
5- Change the settings in the
.env
file, use a non-existent DB name; then runphp artisan clear-compiled
andphp artisan config:cache
.6- Run the tests again.
Expected result
Both tests succeed as Laravel uses the testing environment DB settings. Breaking the settings for the local environment does not impact the tests.
Actual result
The second test run fails with the following error (
bar
is the non-existent DB name we changed in step 5):Furthermore, the
dump()
call outputs the correct values (in my example above,testing
andsqlite
respectively.It looks like the framework loads the correct testing settings but ignores them when running the migrations, using the ones from the local environment instead.
Did I miss some step or is this a bug?