19 return new ApiLogin( $main, $action );
35 [ $this,
'newApiLogin' ],
42 function (
ApiMain $main, $action ) {
54 $moduleManager->addModule(
$name, $group, $class, $factory );
56 $this->assertTrue( $moduleManager->isDefined(
$name, $group ),
'isDefined' );
57 $this->assertNotNull( $moduleManager->getModule(
$name, $group,
true ),
'getModule' );
69 'login' =>
'ApiLogin',
70 'logout' =>
'ApiLogout',
78 'class' =>
'ApiLogin',
79 'factory' => [ $this,
'newApiLogin' ],
82 'class' =>
'ApiLogout',
83 'factory' =>
function (
ApiMain $main, $action ) {
98 $moduleManager->addModules(
$modules, $group );
101 $this->assertTrue( $moduleManager->isDefined(
$name, $group ),
'isDefined' );
102 $this->assertNotNull( $moduleManager->getModule(
$name, $group,
true ),
'getModule' );
105 $this->assertTrue(
true );
110 'feedrecentchanges' =>
'ApiFeedRecentChanges',
111 'feedcontributions' => [
'class' =>
'ApiFeedContributions' ],
113 'class' =>
'ApiLogin',
114 'factory' => [ $this,
'newApiLogin' ],
117 'class' =>
'ApiLogout',
118 'factory' =>
function (
ApiMain $main, $action ) {
128 'ApiFeedRecentChanges',
134 'ApiFeedContributions',
157 $moduleManager->addModules(
$modules,
'test' );
160 $module1 = $moduleManager->getModule(
$name,
null,
false );
161 $this->assertInstanceOf( $expectedClass, $module1 );
164 $module2 = $moduleManager->getModule(
$name,
'test',
true );
165 $this->assertNotNull( $module2 );
168 $module3 = $moduleManager->getModule(
$name,
null,
false );
169 $this->assertSame( $module1, $module3 );
172 $module4 = $moduleManager->getModule(
$name,
null,
true );
173 $this->assertNotSame( $module1, $module4 );
181 'login' =>
'ApiLogin',
182 'logout' =>
'ApiLogout',
186 $moduleManager->addModules(
$modules,
'test' );
188 $this->assertNull( $moduleManager->getModule(
'quux' ),
'unknown name' );
189 $this->assertNull( $moduleManager->getModule(
'login',
'bla' ),
'wrong group' );
197 'login' =>
'ApiLogin',
198 'logout' =>
'ApiLogout',
202 'feedcontributions' => [
'class' =>
'ApiFeedContributions' ],
203 'feedrecentchanges' => [
'class' =>
'ApiFeedRecentChanges' ],
207 $moduleManager->addModules( $fooModules,
'foo' );
208 $moduleManager->addModules( $barModules,
'bar' );
210 $fooNames = $moduleManager->getNames(
'foo' );
213 $allNames = $moduleManager->getNames();
214 $allModules = array_merge( $fooModules, $barModules );
223 'login' =>
'ApiLogin',
224 'logout' =>
'ApiLogout',
228 'feedcontributions' => [
'class' =>
'ApiFeedContributions' ],
229 'feedrecentchanges' => [
'class' =>
'ApiFeedRecentChanges' ],
233 $moduleManager->addModules( $fooModules,
'foo' );
234 $moduleManager->addModules( $barModules,
'bar' );
236 $fooNamesWithClasses = $moduleManager->getNamesWithClasses(
'foo' );
239 $allNamesWithClasses = $moduleManager->getNamesWithClasses();
240 $allModules = array_merge( $fooModules, [
241 'feedcontributions' =>
'ApiFeedContributions',
242 'feedrecentchanges' =>
'ApiFeedRecentChanges',
252 'login' =>
'ApiLogin',
253 'logout' =>
'ApiLogout',
257 'feedcontributions' => [
'class' =>
'ApiFeedContributions' ],
258 'feedrecentchanges' => [
'class' =>
'ApiFeedRecentChanges' ],
262 $moduleManager->addModules( $fooModules,
'foo' );
263 $moduleManager->addModules( $barModules,
'bar' );
265 $this->assertEquals(
'foo', $moduleManager->getModuleGroup(
'login' ) );
266 $this->assertEquals(
'bar', $moduleManager->getModuleGroup(
'feedrecentchanges' ) );
267 $this->assertNull( $moduleManager->getModuleGroup(
'quux' ) );
275 'login' =>
'ApiLogin',
276 'logout' =>
'ApiLogout',
280 'feedcontributions' => [
'class' =>
'ApiFeedContributions' ],
281 'feedrecentchanges' => [
'class' =>
'ApiFeedRecentChanges' ],
285 $moduleManager->addModules( $fooModules,
'foo' );
286 $moduleManager->addModules( $barModules,
'bar' );
288 $groups = $moduleManager->getGroups();
297 'login' =>
'ApiLogin',
298 'logout' =>
'ApiLogout',
302 'feedcontributions' => [
'class' =>
'ApiFeedContributions' ],
303 'feedrecentchanges' => [
'class' =>
'ApiFeedRecentChanges' ],
307 $moduleManager->addModules( $fooModules,
'foo' );
308 $moduleManager->addModules( $barModules,
'bar' );
312 $moduleManager->getClassName(
'login' )
316 $moduleManager->getClassName(
'logout' )
319 'ApiFeedContributions',
320 $moduleManager->getClassName(
'feedcontributions' )
323 'ApiFeedRecentChanges',
324 $moduleManager->getClassName(
'feedrecentchanges' )
327 $moduleManager->getClassName(
'nonexistentmodule' )