Connecting to the correct database when Lithium unit testing

This is really a note-to-self.

Sometimes when I run my unit tests in Lithium (li3) I get something like:

Exception thrown in lithium\data\Model::connection() on line 929:
The data connection `test` is not configured.

Which doesn't make any sense because our unit test classes inherit from our own Unit class, which determines which data connection to use, however in our Unit test class setUp method we have to tell every class we need to use to use the correct data connection. Also, we never use the data connection "test". (The "test" data connection is the one li3 chooses by default when tests are run, which is why we had to overwrite it in our Unit class.)

So why is this happening? Because a class that I'm using as part of the testing includes another class in itself, and so we also have to manually tell this file which data connection to use.

Probably a better way to do this :D


0 Responses to Connecting to the correct database when Lithium unit testing

  1. There are currently no comments.

Leave a Reply



About

User

Remember me on this computer?