I would make it easy for myself and just use mysql for all the tests.
Having both SQLite and MySQL running for Tests.
Hi all,
Thanks for taking the time to review this query.
Basically, we have a situation where we have an application that uses some MySQL only functions, i.e. ANY_VALUE, MAX, etc. It is done in this way because of how complex the requirements are for what we are building. This isn't the problem.
The problem we have is during our tests, which use SQLite, those functions do not exist and as such, the tests fail with an error.
What I am asking is, if it is at all possible to have both SQLite and a MYSQL test databases that we can switch between interchangeably. We wish to do this because SQLite provides better performance for testing over MySQL but we need to have a MySQL suite for cases like this where we do RAW queries that use MySQL specific functions.
I've gotten as far as creating a new connection 'mysql_test' in the database.php file and we are by default specifying sqlite as the default connection in the phpunit.xml as such:
<server name="DB_CONNECTION" value="sqlite"/>
What I would like to do is for specific tests is switch this to mysql_test, so it will run on the MySQL database instead.
I am not sure if this is the best way to do it, and I am open to any and all suggestions to get this working.
Thanks for your time, it's very much appreciated.
@robsykes That is a pretty good solution.
Just make a small script with both commands in
On Mac and linux
phpunit --configuration phpunit-mysql.xml && phpunit --configuration phpunit.xml
Then it will run them with just one command.
Please or to participate in this conversation.