In my application I have tests that use Sqlite and seeding to cover my functionality. So my phpunit env value is set to:
<env name="DB_DEFAULT" value="sqlite" />
However, I'd also like a small subset of my tests to look at my current db data. So within 1 test file, connect to my MySQL connection.
The reason for this is I want to check if we have images for all the records in one of my tables, so the test needs to access the latest data, dummy data would not help in this case.
I presumed I could just connect using the following:
$pdo = DB::connection('mysql')->getPdo();
However, the test only connects if I specify "sqlite" here, which is the name of my sqlite connection.
The testing I want to do is not based on a Model, so I don't want to have a solution built into my Model file, I'd like to switch database just in this 1 test file if possible.
How do I configure a small number of tests to use a different database connection, the existing MySQL connection?