3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
19 use MediaWiki\Registration\ExtensionJsonValidationError
;
20 use MediaWiki\Registration\ExtensionJsonValidator
;
21 use MediaWiki\Registration\ExtensionRegistry
;
24 * Validates all loaded extensions and skins using the ExtensionRegistry
25 * against the extension.json schema in the docs/ folder.
28 class ExtensionJsonValidationTest
extends PHPUnit\Framework\TestCase
{
30 use MediaWikiCoversValidator
;
33 * @var ExtensionJsonValidator
37 protected function setUp(): void
{
40 $this->validator
= new ExtensionJsonValidator( [ $this, 'markTestSkipped' ] );
41 $this->validator
->checkDependencies();
43 if ( !ExtensionRegistry
::getInstance()->getAllThings() ) {
44 $this->markTestSkipped(
45 'There are no extensions or skins loaded via the ExtensionRegistry'
50 public static function providePassesValidation() {
51 $allThings = ExtensionRegistry
::getInstance()->getAllThings();
53 foreach ( $allThings as $thing ) {
54 yield
[ $thing['path'] ];
59 * @dataProvider providePassesValidation
60 * @param string $path Path to thing's json file
62 public function testPassesValidation( $path ) {
64 $this->validator
->validate( $path );
66 $this->assertTrue( true );
67 } catch ( ExtensionJsonValidationError
$e ) {
68 $this->fail( $e->getMessage() );