Code: Select all
$cal->attach($event);
// test that $cal->_children contains $eventModerator: General Moderators
Code: Select all
$cal->attach($event);
// test that $cal->_children contains $eventCode: Select all
$this->assertTrue(in_array($event, $cal->getChildren(), true));Code: Select all
function getFoo() {
return $this->foo;
}Sometimes code which is hard to test is a smell indicating bad design and changing a class to make it easier to test can lead to a better one. That's probably more to do with shuffling responsibilities around rather than changing the interface. Probably.Maugrim_The_Reaper wrote:I'm not so sure about avoiding adding new public methods to make testing easier. In many cases you shouldn't because you just end up with class bloat, code serving no real purpose. However I think you should ask the question anyway: Will it add useful functionality? In most cases we're talking about a simple getter - and in some cases users will like that extra getter when it comes to building on your base class for their applications.