It seems that the general consensus of the testing community is not to test private methods. Instead, you should test private methods by testing the public methods that call them . However, I do not like something. Take this method, for example:
protected function getName()
{
$class = get_class($this);
$matches = array();
if (preg_match('/^Reno_OutputGenerator_(.+)$', $class, $matches))
{
return $matches[1];
}
else
{
throw new Reno_OutputGenerator_Exception('Class name must follow the format of Reno_OutputGenerator_<name>.');
}
}
This particular function is used in several places in my class. I would like to test both operator branches ifin this function, which would mean for every public function that I would have to test in these two situations, plus everything that the public method itself does.
, . , , getName() , , , . , , ?
(BTW: , , , ).