Howto get PHPUnit2 talk to a browser
posted: January 22nd, 2006 · by: Sven
Ok, I admit it took me a while to figure out how to run a PHPUnit2 testcase via http rather than cli on a Windows box.
First thing I needed to understand is that PHPUnit2_Util_Printer::__construct() sets fopen(‘php://stdout’, ‘r’); as output stream by default. This won’t output anything, so one has to advise the printer to use php://output.
Next thing was that I started the TestRunner by run(). Wrong way … this instantiated a new PHPUnit2_TextUI_TestRunner object and my output stream was send to nirvana.
The following works though:
$suite = new PHPUnit2_Framework_TestSuite();
$suite->addTestSuite(new ReflectionClass('MyTestCase'));
$runner = new PHPUnit2_TextUI_TestRunner();
$printer = new PHPUnit2_TextUI_ResultPrinter('php://output');
$runner->setPrinter($printer);
echo '<pre>';
$result = $runner->doRun($suite);
And don’t tell me to rtfm. I’ve found no docs on this. Nothing. I don’t think there are any. :(
Access level constrains in php5 really suck
posted: January 4th, 2006 · by: Sven
I can’t understand why I’m being forced to keep the access level of a class’s method when I extend it.
class SomeFactory extends PEAR_Delegator {
protected function __construct() {
}
public static function instance() {
}
}
... would make perfectly sense IVHMO. But it throws …
"Fatal error: Access level to ActivePdo_Relation::__construct() must be public (as in class PEAR_Delegator)"
What’s the reasoning behind this?
That’s because I’m “doing something terribly wrong”, is it? Not the “php way”? Boy, this sucks.