2016-02-28 09:19:14 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validates all loaded extensions and skins using the ExtensionRegistry
|
|
|
|
|
* against the extension.json schema in the docs/ folder.
|
|
|
|
|
*/
|
2018-02-17 12:29:13 +00:00
|
|
|
class ExtensionJsonValidationTest extends PHPUnit\Framework\TestCase {
|
2016-02-28 09:19:14 +00:00
|
|
|
|
2017-12-29 23:22:37 +00:00
|
|
|
use MediaWikiCoversValidator;
|
|
|
|
|
|
2016-12-01 07:04:27 +00:00
|
|
|
/**
|
|
|
|
|
* @var ExtensionJsonValidator
|
|
|
|
|
*/
|
|
|
|
|
protected $validator;
|
|
|
|
|
|
2020-06-14 10:51:39 +00:00
|
|
|
protected function setUp() : void {
|
2016-02-28 09:19:14 +00:00
|
|
|
parent::setUp();
|
2016-12-01 07:04:27 +00:00
|
|
|
|
|
|
|
|
$this->validator = new ExtensionJsonValidator( [ $this, 'markTestSkipped' ] );
|
|
|
|
|
$this->validator->checkDependencies();
|
2016-02-28 09:19:14 +00:00
|
|
|
|
|
|
|
|
if ( !ExtensionRegistry::getInstance()->getAllThings() ) {
|
|
|
|
|
$this->markTestSkipped(
|
|
|
|
|
'There are no extensions or skins loaded via the ExtensionRegistry'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function providePassesValidation() {
|
2021-02-12 11:01:35 +00:00
|
|
|
$allThings = ExtensionRegistry::getInstance()->getAllThings();
|
2016-02-28 09:19:14 +00:00
|
|
|
|
2021-02-12 11:01:35 +00:00
|
|
|
foreach ( $allThings as $thing ) {
|
|
|
|
|
yield [ $thing['path'] ];
|
|
|
|
|
}
|
2016-02-28 09:19:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providePassesValidation
|
|
|
|
|
* @param string $path Path to thing's json file
|
|
|
|
|
*/
|
|
|
|
|
public function testPassesValidation( $path ) {
|
2016-12-01 07:04:27 +00:00
|
|
|
try {
|
|
|
|
|
$this->validator->validate( $path );
|
|
|
|
|
// All good
|
2016-02-28 09:19:14 +00:00
|
|
|
$this->assertTrue( true );
|
2016-12-01 07:04:27 +00:00
|
|
|
} catch ( ExtensionJsonValidationError $e ) {
|
2021-02-12 11:07:57 +00:00
|
|
|
$this->fail( $e->getMessage() );
|
2016-02-28 09:19:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|