MediaWiki REL1_31
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(
37 ExtensionJsonValidationError::class,
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 'no_manifest_version.json',
57 'no_manifest_version.json does not have manifest_version set.'
58 ],
59 [
60 'old_manifest_version.json',
61 'old_manifest_version.json is using a non-supported schema version'
62 ],
63 [
64 'newer_manifest_version.json',
65 'newer_manifest_version.json is using a non-supported schema version'
66 ],
67 [
68 'bad_spdx.json',
69 "bad_spdx.json did not pass validation.
70[license-name] Invalid SPDX license identifier, see <https://spdx.org/licenses/>"
71 ],
72 [
73 'invalid.json',
74 "invalid.json did not pass validation.
75[license-name] Array value found, but a string is required"
76 ],
77 [
78 'good.json',
79 true
80 ],
81 ];
82 }
83
84}
Copyright (C) 2018 Kunal Mehta legoktm@member.fsf.org
testValidate( $file, $expected)
provideValidate
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:2006