protected $printerName = 'mockbase';
+ protected function setUp() {
+ parent::setUp();
+ $this->setMwGlobals( [
+ 'wgServer' => 'http://example.org'
+ ] );
+ }
+
public function getMockFormatter( ApiMain $main = null, $format, $methods = [] ) {
if ( $main === null ) {
$context = new RequestContext;
public function testHtmlHeader( $post, $registerNonHtml, $expect ) {
$context = new RequestContext;
$request = new FauxRequest( [ 'a' => 1, 'b' => 2 ], $post );
- $request->setRequestURL( 'http://example.org/wx/api.php' );
+ $request->setRequestURL( '/wx/api.php' );
$context->setRequest( $request );
$context->setLanguage( 'qqx' );
$main = new ApiMain( $context );
$printer = $this->getMockFormatter( $main, 'mockfm' );
$mm = $printer->getMain()->getModuleManager();
- $mm->addModule( 'mockfm', 'format', ApiFormatBase::class, function () {
- return $mock;
- } );
- if ( $registerNonHtml ) {
- $mm->addModule( 'mock', 'format', ApiFormatBase::class, function () {
+ $mm->addModule( 'mockfm', 'format', [
+ 'class' => ApiFormatBase::class,
+ 'factory' => function () {
return $mock;
- } );
+ }
+ ] );
+ if ( $registerNonHtml ) {
+ $mm->addModule( 'mock', 'format', [
+ 'class' => ApiFormatBase::class,
+ 'factory' => function () {
+ return $mock;
+ }
+ ] );
}
$printer->initPrinter();