MediaWiki  1.32.5
ExtensionJsonValidatorTest.php
Go to the documentation of this file.
1 <?php
25 
29  public function testValidate( $file, $expected ) {
30  // If a dependency is missing, skip this test.
31  $validator = new ExtensionJsonValidator( function ( $msg ) {
32  $this->markTestSkipped( $msg );
33  } );
34 
35  if ( is_string( $expected ) ) {
36  $this->setExpectedException(
38  $expected
39  );
40  }
41 
42  $dir = __DIR__ . '/../../data/registration/';
43  $this->assertSame(
44  $expected,
45  $validator->validate( $dir . $file )
46  );
47  }
48 
49  public function provideValidate() {
50  return [
51  [
52  'notjson.txt',
53  'notjson.txt is not valid JSON'
54  ],
55  [
56  'duplicate_keys.json',
57  'Duplicate key: name'
58  ],
59  [
60  'no_manifest_version.json',
61  'no_manifest_version.json does not have manifest_version set.'
62  ],
63  [
64  'old_manifest_version.json',
65  'old_manifest_version.json is using a non-supported schema version'
66  ],
67  [
68  'newer_manifest_version.json',
69  'newer_manifest_version.json is using a non-supported schema version'
70  ],
71  [
72  'bad_spdx.json',
73  "bad_spdx.json did not pass validation.
74 [license-name] Invalid SPDX license identifier, see <https://spdx.org/licenses/>"
75  ],
76  [
77  'invalid.json',
78  "invalid.json did not pass validation.
79 [license-name] Array value found, but a string is required"
80  ],
81  [
82  'good.json',
83  true
84  ],
85  [
86  'bad_url.json', 'bad_url.json did not pass validation.
87 [url] Should use HTTPS for www.mediawiki.org URLs'
88  ],
89  [
90  'bad_url2.json', 'bad_url2.json did not pass validation.
91 [url] Should use www.mediawiki.org domain
92 [url] Should use HTTPS for www.mediawiki.org URLs'
93  ]
94  ];
95  }
96 
97 }
php
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
Definition: injection.txt:35
MediaWikiTestCase
Definition: MediaWikiTestCase.php:16
ExtensionJsonValidator
Validate extension.json files against their JSON schema.
Definition: ExtensionJsonValidator.php:39
ExtensionJsonValidatorTest\testValidate
testValidate( $file, $expected)
provideValidate
Definition: ExtensionJsonValidatorTest.php:29
ExtensionJsonValidatorTest\provideValidate
provideValidate()
Definition: ExtensionJsonValidatorTest.php:49
ExtensionJsonValidatorTest
Copyright (C) 2018 Kunal Mehta legoktm@member.fsf.org
Definition: ExtensionJsonValidatorTest.php:24
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:2044
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52