I tried to extend HtmlReporter and ran into all sorts of problems until I realised that I need to do stuff like:
function paintPass($msg) {
parent::paintPass($msg);
echo $msg."<BR>";
}
in order to get the generated stats updated.
Similar things happen with other methods like paintGroupStart(..)
This is rather confusing and perhaps bad design (at least the method name does not really reflect what is going on).
This could be solved by making the public methods pure callbacks (by renaming the current methods that contain logic?)
Having spend more time extending and customizing the HTMLReporter (by subclassing it), I have a much better understanding of what is actually going on.
So, to be more precises, let's take an example:
To customize the exception reporting, paintException($exception) needs to be overridden.
However, to get the final stats right, I am forced to do the following in my implementation:
public function paintException($exception) {
ob_start();
parent::paintException($exception);
// discard default output
ob_get_clean();
... custom display code
}
So, all calls to parent methods need to be wrapped to ignore the output.
Hope this helps, mano
I'm moving this to bugs, because it's something the other developers should take a look at.
You have two choices for handling this:
- Calling the appropriate parent class directly; in this case, it's SimpleReporter::paintException()
- Extending SimpleReporter directly. This is generally a good idea if you're planning on making major changes to HtmlReporter.
I have, however, found it slightly odd that the paint*() methods up the inheritance chain (SimpleScorer) perform pass/fail tracking.