08.
Test Code Reuse
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
4 Comments
APITestCase for Symfony4 seems to break. I'm getting user not found. It seems to be still hitting my app database instead of app_test database.
Hey azeem
Probably you forgot to override the database url parameter in your "phpunit.xml.dist" file
You can find more info here: https://symfony.com/doc/cur...
Cheers!
I have that set already. And, it hits the correct `app_test` schema if I make any changes via entity manager. However, I am testing an api endpoint for e.g. `/app_test.php/tokens` via GuzzleHttp. if I do `var_dump(getenv('APP_ENV'), getenv('database_url'))` I get 'dev' and `mysql://username:secret@localhost:3306/apps`
Hey azeem!
Hmmm. So basically, when you interact with the database inside your test (e.g. add/delete rows), this correctly happens against the test database. But when you actually make the Guzzle request to /app_test.php/tokens, this hits the "dev" environment. Is that correct?
In that case, what does your app_test.php file look like? And also, in what file are you overriding the database credentials for the test environment?
Indeed, the way that you override some of these variables is a bit different in Symfony 4 :).
Cheers!
"Houston: no signs of life"
Start the conversation!