We've recently started to write tests for our fairly large PHP code base - using PHPUnit we are writing unit and integration test for our models and controllers.
What's the concensus in setting a boolean toggle that states whether a class is in TEST_MODE that alters the behaviour of a method?
ie: An email helper function - we don't need to send out an email during a test and we're not testing the mail server, just that that method has been called.
if (self::TEST_MODE) {
return true;
}
I'm already going off this idea - I don't think adding extra checks throughout the codebase for testing is an elegant solution.
But in this example for instance - what would be a good way to check the email has been sent?