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