wiki.techinc.nl/tests/parser/MultiTestRecorder.php
Thiemo Kreuz 6aa6d10e86 Replace all call_user_func(_array) in all tests
There is native support for all of this now in PHP, thanks to changes
and additions that have been made in later versions. There should be no
need any more to ever use call_user_func() or call_user_func_array().

Reviewing this should be fairly easy: Because this patch touches
exclusivly tests, but no production code, there is no such thing as
"insufficent test coverage". As long as CI goes green, this should be
fine.

Change-Id: Ib9690103687734bb5a85d3dab0e5642a07087bbc
2020-06-06 18:41:20 +02:00

55 lines
1.2 KiB
PHP

<?php
/**
* This is a TestRecorder representing a collection of other TestRecorders.
* It proxies calls to all constituent objects.
*/
class MultiTestRecorder extends TestRecorder {
private $recorders = [];
public function addRecorder( TestRecorder $recorder ) {
$this->recorders[] = $recorder;
}
private function proxy( $funcName, $args ) {
foreach ( $this->recorders as $recorder ) {
$recorder->$funcName( ...$args );
}
}
public function start() {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function startTest( $test ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function startSuite( $path ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function endSuite( $path ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function record( $test, ParserTestResult $result ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function warning( $message ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function skipped( $test, $subtest ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function report() {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function end() {
$this->proxy( __FUNCTION__, func_get_args() );
}
}