];
if ( is_callable( $factory ) ) {
- // Uncomment this when callers are cleaned up:
- // wfDeprecated( __METHOD__ . ' with $class and $factory', '1.34' );
+ wfDeprecated( __METHOD__ . ' with $class and $factory', '1.34' );
$spec['factory'] = $factory;
}
} elseif ( !is_array( $spec ) ) {
$mock->method( 'needsToken' )->willReturn( true );
$api = new ApiMain( new FauxRequest( [ 'action' => 'testmodule' ] ) );
- $api->getModuleManager()->addModule( 'testmodule', 'action', get_class( $mock ),
- function () use ( $mock ) {
+ $api->getModuleManager()->addModule( 'testmodule', 'action', [
+ 'class' => get_class( $mock ),
+ 'factory' => function () use ( $mock ) {
return $mock;
}
- );
+ ] );
$api->execute();
}
$mock->method( 'mustBePosted' )->willReturn( false );
$api = new ApiMain( new FauxRequest( [ 'action' => 'testmodule' ] ) );
- $api->getModuleManager()->addModule( 'testmodule', 'action', get_class( $mock ),
- function () use ( $mock ) {
+ $api->getModuleManager()->addModule( 'testmodule', 'action', [
+ 'class' => get_class( $mock ),
+ 'factory' => function () use ( $mock ) {
return $mock;
}
- );
+ ] );
$api->execute();
}
$req->setRequestURL( "http://localhost" );
$api = new ApiMain( $req );
- $api->getModuleManager()->addModule( 'testmodule', 'action', get_class( $mock ),
- function () use ( $mock ) {
+ $api->getModuleManager()->addModule( 'testmodule', 'action', [
+ 'class' => get_class( $mock ),
+ 'factory' => function () use ( $mock ) {
return $mock;
}
- );
+ ] );
$wrapper = TestingAccessWrapper::newFromObject( $api );
$wrapper->mInternalMode = false;
* @dataProvider addModuleProvider
*/
public function testAddModule( $name, $group, $spec, $factory ) {
+ if ( $factory ) {
+ $this->hideDeprecated(
+ ApiModuleManager::class . '::addModule with $class and $factory'
+ );
+ }
+
$moduleManager = $this->getModuleManager();
$moduleManager->addModule( $name, $group, $spec, $factory );
$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();