Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / structure / ExtensionJsonValidationTest.php
blobb19376d388db413b48e572f0e8ec763ee12ad7b7
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 /**
20 * Validates all loaded extensions and skins using the ExtensionRegistry
21 * against the extension.json schema in the docs/ folder.
23 class ExtensionJsonValidationTest extends PHPUnit_Framework_TestCase {
25 /**
26 * @var ExtensionJsonValidator
28 protected $validator;
30 public function setUp() {
31 parent::setUp();
33 $this->validator = new ExtensionJsonValidator( [ $this, 'markTestSkipped' ] );
34 $this->validator->checkDependencies();
36 if ( !ExtensionRegistry::getInstance()->getAllThings() ) {
37 $this->markTestSkipped(
38 'There are no extensions or skins loaded via the ExtensionRegistry'
43 public static function providePassesValidation() {
44 $values = [];
45 foreach ( ExtensionRegistry::getInstance()->getAllThings() as $thing ) {
46 $values[] = [ $thing['path'] ];
49 return $values;
52 /**
53 * @dataProvider providePassesValidation
54 * @param string $path Path to thing's json file
56 public function testPassesValidation( $path ) {
57 try {
58 $this->validator->validate( $path );
59 // All good
60 $this->assertTrue( true );
61 } catch ( ExtensionJsonValidationError $e ) {
62 $this->assertEquals( false, $e->getMessage() );