It somehow forces to use MySQL for Job Batching
Closed this issue · 2 comments
- Testbench Version: v8.5.0
- Laravel Version: v10.8.0
- PHP Version: 8.2.3
- Database Driver & Version: sqlite
Description:
Since testbench v8.3.0, the testbench-code/laravel/config/queue.php file contains the following code:
Testbench is supposed to use SQLite as its default database for testing, but it seems to be ignoring this and using MySQL for job batching regardless.
Steps To Reproduce:
It might be easier to provide a package that includes job batching tests, so please allow me to use my package. You can find my package at:
https://github.com/askdkc/livewire-csv
To use it, simply clone the repository and follow these steps:
cd livewire-csv
composer install
./vendor/bin/pest
It will output something like this (See strange Connection: mysql
outputs):
• Tests\CsvImporterTest > it can handled none required column even when column is empty
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: insert into `job_batches`
Now you edit the vendor/orchestra/testbench-core/laravel/config/queue.php
and comment out follwoing.
'batching' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'job_batches',
],
to
// 'batching' => [
// 'database' => env('DB_CONNECTION', 'mysql'),
// 'table' => 'job_batches',
// ],
Then run ./vendor/bin/pest
again. This time test passes perfectly.
Is there any way to fix testbench to use SQLite for Job Batching?
Testbench is supposed to use SQLite as its default database for testing, but it seems to be ignoring this and using MySQL for job batching regardless.
This is incorrect, Testbench depends on DB_CONNECTION
value for the default database connection.
Also suggested in the documentation: https://packages.tools/testbench/getting-started/configuration.html#in-memory-sqlite-connection
This is incorrect, Testbench depends on DB_CONNECTION value for the default database connection.
Oops. Thank you for clarifying this.
I added following and run the test again, and it worked without any errors.
<php>
<env name="DB_CONNECTION" value="testing"/>
</php>