SECURITY: blacklist CSS var()
[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 /**
20 * Validates all loaded extensions and skins using the ExtensionRegistry
21 * against the extension.json schema in the docs/ folder.
22 *
23 * @coversNothing
24 */
25 class ExtensionJsonValidationTest extends PHPUnit\Framework\TestCase {
26
27 use MediaWikiCoversValidator;
28
29 /**
30 * @var ExtensionJsonValidator
31 */
32 protected $validator;
33
34 public function setUp() {
35 parent::setUp();
36
37 $this->validator = new ExtensionJsonValidator( [ $this, 'markTestSkipped' ] );
38 $this->validator->checkDependencies();
39
40 if ( !ExtensionRegistry::getInstance()->getAllThings() ) {
41 $this->markTestSkipped(
42 'There are no extensions or skins loaded via the ExtensionRegistry'
43 );
44 }
45 }
46
47 public static function providePassesValidation() {
48 $values = [];
49 foreach ( ExtensionRegistry::getInstance()->getAllThings() as $thing ) {
50 $values[] = [ $thing['path'] ];
51 }
52
53 return $values;
54 }
55
56 /**
57 * @dataProvider providePassesValidation
58 * @param string $path Path to thing's json file
59 */
60 public function testPassesValidation( $path ) {
61 try {
62 $this->validator->validate( $path );
63 // All good
64 $this->assertTrue( true );
65 } catch ( ExtensionJsonValidationError $e ) {
66 $this->assertEquals( false, $e->getMessage() );
67 }
68 }
69 }