Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
ValidateRegistrationFile | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
4.00 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
90.00% |
9 / 10 |
|
0.00% |
0 / 1 |
3.01 |
1 | <?php |
2 | |
3 | use MediaWiki\Maintenance\Maintenance; |
4 | use MediaWiki\Registration\ExtensionJsonValidationError; |
5 | use MediaWiki\Registration\ExtensionJsonValidator; |
6 | |
7 | // @codeCoverageIgnoreStart |
8 | require_once __DIR__ . '/Maintenance.php'; |
9 | // @codeCoverageIgnoreEnd |
10 | |
11 | class ValidateRegistrationFile extends Maintenance { |
12 | public function __construct() { |
13 | parent::__construct(); |
14 | $this->addArg( |
15 | 'path', |
16 | 'Path or glob pattern to extension.json/skin.json file.', |
17 | true |
18 | ); |
19 | } |
20 | |
21 | public function execute() { |
22 | $validator = new ExtensionJsonValidator( function ( $msg ) { |
23 | $this->fatalError( $msg ); |
24 | } ); |
25 | $validator->checkDependencies(); |
26 | $paths = glob( $this->getArg( 0 ) ); |
27 | foreach ( $paths as $path ) { |
28 | try { |
29 | $validator->validate( $path ); |
30 | $this->output( "$path validates against the schema!\n" ); |
31 | } catch ( ExtensionJsonValidationError $e ) { |
32 | $this->fatalError( $e->getMessage() ); |
33 | } |
34 | } |
35 | } |
36 | } |
37 | |
38 | // @codeCoverageIgnoreStart |
39 | $maintClass = ValidateRegistrationFile::class; |
40 | require_once RUN_MAINTENANCE_IF_MAIN; |
41 | // @codeCoverageIgnoreEnd |