wiki.techinc.nl/tests/phpunit/integration/includes/ResourceLoader/ForeignResourceStructureTest.php
Reedy c8276f731a tests: Add more use statements in namespaced classes
Change-Id: I2629cfcb09fde6f18be824779a2c12c013ea0cb5
2024-02-18 21:31:02 +00:00

43 lines
1.2 KiB
PHP

<?php
use MediaWiki\ResourceLoader\ForeignResourceManager;
use PHPUnit\Framework\TestCase;
/**
* Verify MediaWiki core's foreign-resources.yaml.
*
* This test is under integration/ instead of structure/ because the latter
* also runs in CI for skin and extension repos (T203694).
*
* @coversNothing
*/
class ForeignResourceStructureTest extends TestCase {
public function testVerifyIntegrity() {
global $IP;
$out = '';
$frm = new ForeignResourceManager(
"{$IP}/resources/lib/foreign-resources.yaml",
"{$IP}/resources/lib",
static function ( $text ) use ( &$out ) {
$out .= $text;
}
);
// The "verify" action verifies two things:
// 1. Mismatching SRI hashes.
// These throw an exception with the actual/expect values
// to place in foreign-resources.yaml.
// 2. Mismatching file contents.
// These print messages about each mismatching file,
// and then we add our help text afterward for how to
// automatically update the file resources.
$helpUpdate = '
To update a foreign resource, run:
$ php maintenance/manageForeignResources.php update <moduleName>
';
$this->assertTrue( $frm->run( 'verify', 'all' ), "$out\n$helpUpdate" );
}
}