Benjamest's avatar

PHPUnit sqlite and JSON fields

Hi all,

I wish to write tests on a model which utilises the JSON field type. The test runs fine when utilising mysql or running the code in production however it is extremely slow to run the full suite of tests. Whenever I try to run the test in sqlite I get:

"RuntimeException : This database engine does not support JSON contains operations."

From what I have read there is the open to run the tests in mysql, which is extremely slow, or a more complicated method of trying to install a json library for sqlite.

Is there any easy way of getting around this? One other method I'd like to explore as a compromise is whether I can run the non-json tests in sqlite and the json model tests in mysql. Any advice is greatly appreciated.

Thanks

0 likes
1 reply
bugsysha's avatar

Which trait are you using in your tests for the database (DatabaseMigrations, RefreshDatabase, DatabaseTransactions)? Maybe changing those can help.

Please or to participate in this conversation.