Unit testing packages in Concrete5
Loader::model('people', 'my package');
PHPUnit has no clue what "Loader" is. Is there a file(s) I can include to load up Concrete in my tests?
My conclusion is that its practical for self contained classes, but as soon as a class starts interacting with the database or the core it becomes messy. You end up re-factoring a class to enable such interactions to be stubbed or otherwise intercepted by the test.
I am usually a big advocate of self contained unit tests. But in the case of c5 development, I have found they end up testing the part of my code where the bugs are less likely to be and that integration testing is where I discover something useful in how my code interacts with the database and core. So I often develop code with switch-able traces and logging, so I can monitor what it is doing inside while interacting with the system.
Essentially, I take this:
And wrap it in a php equivalent of this:
And enable the whole lot through a single flag that is on during development and testing and off when released.