Remove FileRepoStatus references
[mediawiki.git] / tests / phpunit / structure / ExtensionJsonValidationTest.php
blob8ba2aeb241fb3a4b6ae3c85deade0c892452e576
1 <?php
2 /**
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 Composer\Spdx\SpdxLicenses;
20 use JsonSchema\Validator;
22 /**
23 * Validates all loaded extensions and skins using the ExtensionRegistry
24 * against the extension.json schema in the docs/ folder.
26 class ExtensionJsonValidationTest extends PHPUnit_Framework_TestCase {
28 /**
29 * @var ExtensionJsonValidator
31 protected $validator;
33 public function setUp() {
34 parent::setUp();
36 $this->validator = new ExtensionJsonValidator( [ $this, 'markTestSkipped' ] );
37 $this->validator->checkDependencies();
39 if ( !ExtensionRegistry::getInstance()->getAllThings() ) {
40 $this->markTestSkipped(
41 'There are no extensions or skins loaded via the ExtensionRegistry'
46 public static function providePassesValidation() {
47 $values = [];
48 foreach ( ExtensionRegistry::getInstance()->getAllThings() as $thing ) {
49 $values[] = [ $thing['path'] ];
52 return $values;
55 /**
56 * @dataProvider providePassesValidation
57 * @param string $path Path to thing's json file
59 public function testPassesValidation( $path ) {
60 try {
61 $this->validator->validate( $path );
62 // All good
63 $this->assertTrue( true );
64 } catch ( ExtensionJsonValidationError $e ) {
65 $this->assertEquals( false, $e->getMessage() );