I'm trying to set the database for the tests I'm going to run but I have one problem:
I've already read all posts related to upgrade phpunit in a global context but I've failed doing that. I tried everything and I just couldn't upgrade phpunit globally so I started to use vendor/bin/phpunit instead and everything works fine. Now that led me to a second problem:
I know I need to set all the information about the database in the phpunit.xml file but the one that is in the base path works only for the global phpunit version. So where can I set the database information for the vendor/bin phunit version?
phpunit.xml works for both local and global phpunit installation. You don't need a global phpunit. Just run your test using ./vendor/bin/phpunit
.
For the database configuration add the following to your phpunit.xml:
<!-- To use sqlite in memory (Faster)
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<!-- To use Mysql -->
<!--<env name="DB_DATABASE" value="databse_test"/>-->
As others have said ./vendor/bin/phpunit
should read the phpunit.xml
file if you running things from your app root path. To help with testing you can explicitly say what config file you need, like:
vendor/bin/phpunit -c ./phpunit.xml
but if the file is in the current directory you in its not needed, perhaps just double check that.