wiki.techinc.nl/tests/parser/MultiTestRecorder.php
C. Scott Ananian 5a49745add tests/parser/TestMode: move parser test helper class to parsoid library
Depends-On: I6a653889afd42fefb61daefd8ac842107dce8759
Depends-On: I73f320dfb03e5c26971a7bc36564021d2c9f3695
Change-Id: Id3e44a5b419d7f6917819e72c046f94a3a2286fe
2022-08-16 16:26:25 -04:00

59 lines
1.5 KiB
PHP

<?php
use Wikimedia\Parsoid\ParserTests\Test as ParserTest;
use Wikimedia\Parsoid\ParserTests\TestMode as ParserTestMode;
/**
* This is a TestRecorder representing a collection of other TestRecorders.
* It proxies calls to all constituent objects.
*/
class MultiTestRecorder extends TestRecorder {
/** @var 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( ParserTest $test, ParserTestMode $mode ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function startSuite( string $path ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function endSuite( string $path ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function record( ParserTestResult $result ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function warning( string $message ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function skipped( ParserTest $test, ParserTestMode $mode, string $reason ) {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function report() {
$this->proxy( __FUNCTION__, func_get_args() );
}
public function end() {
$this->proxy( __FUNCTION__, func_get_args() );
}
}