Add parameter to API modules to apply change tags to log entries
[lhc/web/wiklou.git] / tests / phpunit / structure / ExtensionJsonValidationTest.php
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.
7 *
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.
12 *
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
17 */
18
19 use Composer\Spdx\SpdxLicenses;
20 use JsonSchema\Validator;
21
22 /**
23 * Validates all loaded extensions and skins using the ExtensionRegistry
24 * against the extension.json schema in the docs/ folder.
25 */
26 class ExtensionJsonValidationTest extends PHPUnit_Framework_TestCase {
27
28 /**
29 * @var ExtensionJsonValidator
30 */
31 protected $validator;
32
33 public function setUp() {
34 parent::setUp();
35
36 $this->validator = new ExtensionJsonValidator( [ $this, 'markTestSkipped' ] );
37 $this->validator->checkDependencies();
38
39 if ( !ExtensionRegistry::getInstance()->getAllThings() ) {
40 $this->markTestSkipped(
41 'There are no extensions or skins loaded via the ExtensionRegistry'
42 );
43 }
44 }
45
46 public static function providePassesValidation() {
47 $values = [];
48 foreach ( ExtensionRegistry::getInstance()->getAllThings() as $thing ) {
49 $values[] = [ $thing['path'] ];
50 }
51
52 return $values;
53 }
54
55 /**
56 * @dataProvider providePassesValidation
57 * @param string $path Path to thing's json file
58 */
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() );
66 }
67 }
68 }