phpMick's avatar
Level 15

Query sqlite database while test is running.

I can't help wondering if this is possible.

If I have an xdebug breakpoint in my test, is there any way that I can run up sqlite and check what is happening in the tables?

Mick

0 likes
4 replies
skliche's avatar

@phpMick What exactly do you want to do/check? The queries that have been executed so far? Use \DB::enableQueryLog(); and \DB::getQueryLog();. The contents of the tables? Of course you can query the sqlite database file using the command line or utilities.

phpMick's avatar
Level 15

I want to do a SELECT * FROM to see what is in the tables.

I am using an Sqlite inmemory database, so am not sure how to connect.

D9705996's avatar
D9705996
Best Answer
Level 51

It looks like this is not possible.

It would not be normal to interrogate the database directly with SQL mid test. Is their a reason you cannot do dd the all the models records in your test

e.g. dd(User::all());

If you do need to get access to the database why not temporarily setup a separate on disk sqlite database in ohpunit.xml which you can then connect to?

phpMick's avatar
Level 15

This is pretty much what I am doing:

$users = User::all();

Then I interrogate $users with xdebug.

Thanks,

Mick

Please or to participate in this conversation.