Support the ongoing development of Laravel.io →
Database Testing

My test suite currently has 67 tests and 167 assertions. If I run the tests in a SQLite memory database, the tests run in less than 20 seconds. If I run them in MySQL, they take nearly two minutes, so I'd prefer to run all the tests that I can using the SQLite memory database.

However, I have a table that contains spatial data, and SQLite doesn't support spatial data. I want to run tests on that model and table using the MySQL driver. Can I specify the MySQL database connection for an individual unit test while running the rest in SQLite?

Last updated 2 years ago.
0

You could probably just do like Config::set('database.default', 'mysql'); in that/those test(s).

Last updated 2 years ago.
0

Just a note for anybody else who wants to use this method, this is how I setup the test:

if (Config::get('database.default') == 'sqlite')
{
	Config::set('database.default', 'mysql');

	Artisan::call('migrate:refresh');
}

Works great, thanks!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

benharold benharold Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.