3use Wikimedia\ScopedCallback;
14 $this->dataDir = __DIR__ .
'/../../data/registration';
19 $path = __DIR__ .
'/doesnotexist.json';
20 $this->setExpectedException(
22 "$path does not exist!"
24 $registry->queue(
$path );
29 $path =
"{$this->dataDir}/good.json";
30 $registry->queue(
$path );
31 $this->assertArrayHasKey(
35 $registry->clearQueue();
36 $this->assertEmpty( $registry->getQueue() );
41 $registry->loadFromQueue();
42 $this->assertEmpty( $registry->getAllThings() );
48 $registry->queue(
"{$this->dataDir}/good.json" );
49 $this->setExpectedException(
51 "The following paths tried to load late: {$this->dataDir}/good.json"
53 $registry->loadFromQueue();
58 $registry->queue(
"{$this->dataDir}/good.json" );
59 $registry->loadFromQueue();
60 $this->assertArrayHasKey(
'FooBar', $registry->getAllThings() );
61 $this->assertTrue( $registry->isLoaded(
'FooBar' ) );
62 $this->assertTrue( $registry->isLoaded(
'FooBar',
'*' ) );
63 $this->assertSame( [
'test' ], $registry->getAttribute(
'FooBarAttr' ) );
64 $this->assertSame( [], $registry->getAttribute(
'NotLoadedAttr' ) );
69 $registry->queue(
"{$this->dataDir}/good_with_version.json" );
70 $registry->loadFromQueue();
71 $this->assertTrue( $registry->isLoaded(
'FooBar',
'>= 1.2.0' ) );
72 $this->assertFalse( $registry->isLoaded(
'FooBar',
'^1.3.0' ) );
80 $registry->queue(
"{$this->dataDir}/good.json" );
81 $registry->loadFromQueue();
82 $registry->isLoaded(
'FooBar',
'>= 1.2.0' );
90 $registry->readFromQueue( [
91 __DIR__ .
'/doesnotexist.json' => 1
97 $registry->readFromQueue( [
98 "{$this->dataDir}/autoload_namespaces.json" => 1
101 class_exists(
'Test\\MediaWiki\\AutoLoader\\TestFooBar' ),
102 "Registry initializes Autoloader from AutoloadNamespaces"
112 foreach ( $before
as $key =>
$value ) {
114 if ( substr( $key, 0, 2 ) ==
'mw' ) {
123 'globals' => $globals,
128 'autoloaderPaths' => []
131 $class =
new ReflectionClass( ExtensionRegistry::class );
132 $method = $class->getMethod(
'exportExtractedData' );
133 $method->setAccessible(
true );
134 $method->invokeArgs( $registry, [ $info ] );
142 foreach ( $before
as $key =>
$value ) {
143 if ( substr( $key, 0, 2 ) ==
'mw' ) {
154 'Simple non-array values',
156 'mwtestFooBarConfig' =>
true,
157 'mwtestFooBarConfig2' =>
'string',
160 'mwtestFooBarDefault' => 1234,
161 'mwtestFooBarConfig' =>
false,
164 'mwtestFooBarConfig' =>
true,
165 'mwtestFooBarConfig2' =>
'string',
166 'mwtestFooBarDefault' => 1234,
170 'No global already set, simple array',
173 'mwtestDefaultOptions' => [
178 'mwtestDefaultOptions' => [
184 'Global already set, simple array',
186 'mwtestDefaultOptions' => [
192 'mwtestDefaultOptions' => [
198 'mwtestDefaultOptions' => [
206 'Global already set, 1d array that appends',
208 'mwAvailableRights' => [
214 'mwAvailableRights' => [
219 'mwAvailableRights' => [
227 'Global already set, array with integer keys',
229 'mwNamespacesFoo' => [
235 'mwNamespacesFoo' => [
242 'mwNamespacesFoo' => [
250 'No global already set, $wgHooks',
257 'FooBarClass::onFooBarEvent'
265 'FooBarClass::onFooBarEvent'
271 'Global already set, $wgHooks',
275 'FooBarClass::onFooBarEvent'
278 'FooBarClass::onBazBarEvent',
285 'BazBarClass::onFooBarEvent',
293 'FooBarClass::onFooBarEvent',
294 'BazBarClass::onFooBarEvent',
297 'FooBarClass::onBazBarEvent',
303 'Global already set, $wgGroupPermissions',
305 'wgGroupPermissions' => [
310 'somethingtwo' =>
true,
315 'wgGroupPermissions' => [
321 'somethingtwo' =>
false,
322 'nonduplicated' =>
true,
328 'wgGroupPermissions' => [
336 'somethingtwo' =>
true,
338 'nonduplicated' =>
true,
344 'False local setting should not be overridden (T100767)',
346 'mwtestT100767' =>
false,
349 'mwtestT100767' =>
true,
352 'mwtestT100767' =>
false,
356 'test array_replace_recursive',
358 'mwtestJsonConfigs' => [
359 'JsonZeroConfig' => [
367 'mwtestJsonConfigs' => [
368 'JsonZeroConfig' => [
378 'mwtestJsonConfigs' => [
379 'JsonZeroConfig' => [
391 'global is null before',
393 'NullGlobal' =>
null,
396 'NullGlobal' =>
'not-null'
407 $registry->queue(
"{$this->dataDir}/good.json" );
408 $registry->loadFromQueue();
410 $this->assertSame( [
'test' ], $registry->getAttribute(
'FooBarAttr' ) );
411 $reset = $registry->setAttributeForTest(
'FooBarAttr', [
'override' ] );
413 $this->assertSame( [
'override' ], $registry->getAttribute(
'FooBarAttr' ) );
414 ScopedCallback::consume( $reset );
416 $this->assertSame( [
'test' ], $registry->getAttribute(
'FooBarAttr' ) );
425 $reset1 = $registry->setAttributeForTest(
'foo', [
'val1' ] );
426 $reset2 = $registry->setAttributeForTest(
'foo', [
'val2' ] );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
testLoadFromQueueWithConstraintWithoutVersion()
LogicException.
testLoadFromQueueWithConstraintWithVersion()
testLoadFromQueue_empty()
testReadFromQueue_nonexistent()
PHPUnit_Framework_Error.
testReadFromQueueInitializeAutoloaderWithPsr4Namespaces()
testExportExtractedDataGlobals( $desc, $before, $globals, $expected)
provideExportExtractedDataGlobals
testSetAttributeForTest()
testSetAttributeForTestDuplicate()
Exception The attribute 'foo' has already been overridden.
static provideExportExtractedDataGlobals()
const MERGE_STRATEGY
Special key that defines the merge strategy.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php