12 $this->dataDir = __DIR__ .
'/../../data/registration';
17 $path = __DIR__ .
'/doesnotexist.json';
18 $this->setExpectedException(
20 "$path does not exist!"
22 $registry->queue(
$path );
27 $path =
"{$this->dataDir}/good.json";
28 $registry->queue(
$path );
29 $this->assertArrayHasKey(
33 $registry->clearQueue();
34 $this->assertEmpty( $registry->getQueue() );
39 $registry->loadFromQueue();
40 $this->assertEmpty( $registry->getAllThings() );
46 $registry->queue(
"{$this->dataDir}/good.json" );
47 $this->setExpectedException(
49 "The following paths tried to load late: {$this->dataDir}/good.json"
51 $registry->loadFromQueue();
56 $registry->queue(
"{$this->dataDir}/good.json" );
57 $registry->loadFromQueue();
58 $this->assertArrayHasKey(
'FooBar', $registry->getAllThings() );
59 $this->assertTrue( $registry->isLoaded(
'FooBar' ) );
60 $this->assertTrue( $registry->isLoaded(
'FooBar',
'*' ) );
61 $this->assertSame( [
'test' ], $registry->getAttribute(
'FooBarAttr' ) );
62 $this->assertSame( [], $registry->getAttribute(
'NotLoadedAttr' ) );
67 $registry->queue(
"{$this->dataDir}/good_with_version.json" );
68 $registry->loadFromQueue();
69 $this->assertTrue( $registry->isLoaded(
'FooBar',
'>= 1.2.0' ) );
70 $this->assertFalse( $registry->isLoaded(
'FooBar',
'^1.3.0' ) );
78 $registry->queue(
"{$this->dataDir}/good.json" );
79 $registry->loadFromQueue();
80 $registry->isLoaded(
'FooBar',
'>= 1.2.0' );
88 $registry->readFromQueue( [
89 __DIR__ .
'/doesnotexist.json' => 1
95 $registry->readFromQueue( [
96 "{$this->dataDir}/autoload_namespaces.json" => 1
99 class_exists(
'Test\\MediaWiki\\AutoLoader\\TestFooBar' ),
100 "Registry initializes Autoloader from AutoloadNamespaces"
110 foreach ( $before
as $key =>
$value ) {
112 if ( substr( $key, 0, 2 ) ==
'mw' ) {
121 'globals' => $globals,
126 'autoloaderPaths' => []
130 $method = $class->getMethod(
'exportExtractedData' );
131 $method->setAccessible(
true );
132 $method->invokeArgs( $registry, [ $info ] );
140 foreach ( $before
as $key =>
$value ) {
141 if ( substr( $key, 0, 2 ) ==
'mw' ) {
152 'Simple non-array values',
154 'mwtestFooBarConfig' =>
true,
155 'mwtestFooBarConfig2' =>
'string',
158 'mwtestFooBarDefault' => 1234,
159 'mwtestFooBarConfig' =>
false,
162 'mwtestFooBarConfig' =>
true,
163 'mwtestFooBarConfig2' =>
'string',
164 'mwtestFooBarDefault' => 1234,
168 'No global already set, simple array',
171 'mwtestDefaultOptions' => [
176 'mwtestDefaultOptions' => [
182 'Global already set, simple array',
184 'mwtestDefaultOptions' => [
190 'mwtestDefaultOptions' => [
196 'mwtestDefaultOptions' => [
204 'Global already set, 1d array that appends',
206 'mwAvailableRights' => [
212 'mwAvailableRights' => [
217 'mwAvailableRights' => [
225 'Global already set, array with integer keys',
227 'mwNamespacesFoo' => [
233 'mwNamespacesFoo' => [
240 'mwNamespacesFoo' => [
248 'No global already set, $wgHooks',
255 'FooBarClass::onFooBarEvent'
263 'FooBarClass::onFooBarEvent'
269 'Global already set, $wgHooks',
273 'FooBarClass::onFooBarEvent'
276 'FooBarClass::onBazBarEvent',
283 'BazBarClass::onFooBarEvent',
291 'FooBarClass::onFooBarEvent',
292 'BazBarClass::onFooBarEvent',
295 'FooBarClass::onBazBarEvent',
301 'Global already set, $wgGroupPermissions',
303 'wgGroupPermissions' => [
308 'somethingtwo' =>
true,
313 'wgGroupPermissions' => [
319 'somethingtwo' =>
false,
320 'nonduplicated' =>
true,
326 'wgGroupPermissions' => [
334 'somethingtwo' =>
true,
336 'nonduplicated' =>
true,
342 'False local setting should not be overridden (T100767)',
344 'mwtestT100767' =>
false,
347 'mwtestT100767' =>
true,
350 'mwtestT100767' =>
false,
354 'test array_replace_recursive',
356 'mwtestJsonConfigs' => [
357 'JsonZeroConfig' => [
365 'mwtestJsonConfigs' => [
366 'JsonZeroConfig' => [
376 'mwtestJsonConfigs' => [
377 'JsonZeroConfig' => [
389 'global is null before',
391 'NullGlobal' =>
null,
394 'NullGlobal' =>
'not-null'