NB: I consulted other similar questions, but all of them resolved clearing cache, setting APP_ENV in the xml, and/or creating the .env.testing.
Laravel version: "laravel/framework": "5.8.*",
I've the standard .env file with
APP_ENV=local
DB_CONNECTION=mysql
I've cloned the standard .env file and saved as .env.testing, then changed to
APP_ENV=testing
DB_CONNECTION=mongodb
From console, from inside the root of the project, I'm trying to run test using
php artisan config:cache && vendor/bin/phpunit
The problem is that Laravel/PHPUnit is still using the .env file, instead of the expected .env.testing. This is the proof
TypeError: Argument 1 passed to Jenssegers\Mongodb\Query\Builder::__construct() must be an instance of Jenssegers\Mongodb\Connection, instance of Illuminate\Database\MySqlConnection given,
This is the actual phpunit.xml config file
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
So, I kindly ask a suggestion for debugging and fixing
"laravel/framework": "5.8.*",php artisan config:clear && php artisan test