I'm starting to implement unit test in my Phalcon MVC app, and I'm struggling to make my models work there. I've picked up the phpunit example from the incubator, working well, I use the [ CoreTestCase->setUp() ] method to load/overwrite some services on the fly (locale, db, cache...), and my test are running fine.
Now comes the time to test the first function using models, and it fails. I get the following message: "Service 'db' wasn't found in the dependency injection container".
Some more details: - Service 'db' is managing the db connection (\Phalcon\Db\Adapter\Pdo\Mysql) - That happens when I try to save data using my email model [$mEmail->create();] - I make my models inherit from a modelStub class containing the static metaData mapping (no db connection required to instanciate the models) - if I dump the model DI [var_dump($mEmail->getDi()->getDb());] it shows the db service properly configured
I had a look at the modelManager class, but didn't have much success. Can anyone help me ? If not the model, what class is looking for the 'db' service ? Alternatively, is there a way to enforce all the classes reloading the DI once I've added some services in the setUp helper?