Possible Duplicate:
PhpUnit private method testing
In my unit tests I need to call a private method to set my fixtures to a given state. On the other hand, I'd rather not make this method public. How do I go about this?
Possible Duplicate:
PhpUnit private method testing
In my unit tests I need to call a private method to set my fixtures to a given state. On the other hand, I'd rather not make this method public. How do I go about this?
Why not make those functions protected and create a derived class for testing purposes? That class can have public functions for testing that can initialize the various variables etc.
Unit testing private methods is generally a bad idea, but if you really want to, reflection is the way to go. This should do it:
$reflection_class = new ReflectionClass($object_under_test);
$method = $reflection_class->getMethod('nameOfMethod');
$method->setAccessible(true);
$method->invoke($object_under_test, $param);
HTH