How to configure symfony unit tests to use an sqlite memory database

Since Bernard Schussecks presentation at “symfony Day Cologne”, talking about lime and using sqlite memory tables for unit tests, I was wondering HOW TO DO IT

Well, there was not much talk about the how… of course this must be known to everybody – such an easy task. (Find yourself some <irony> tags to put around this).

Well, at least I did not have a clue how to do it and did not find too much information on it in the web…

So, spending some more time with testing and some rare tutorials on it, I finally made it work!!

And for you and me and everybod else, I’ll note it down for reference…


  • We are using symfony and doctrine
  • In test/fixtures we have a/some yml files with test data

First, we need to set up the test connection to use sqlite:MEMORY:

In your config/database.yml add

    class: sfDoctrineDatabase
      classname: DebugPDO
      dsn: 'sqlite::memory:'

(yes, ::)

Now, lets assume (accoding to the Jobeet tutorial Day 8 ) we have a


Now, the important part is to not only LOAD the data but first create the tables:

  $configuration = ProjectConfiguration::getApplicationConfiguration( 'frontend', 'test', true);
  new sfDatabaseManager($configuration);

Now, in our test files we can simply call

$t = new lime_test(4);  //change it with the number of tests you have 

Took me quite some time to figure it out – really simpe – if you know how…