mediawiki-skins-Vector/tests/phpunit/structure/BundleSizeTest.php
Moh'd Khier Abualruz 20b9d04b2f Performance budget's should consider modules added by hooks
- Add ModulesSizeTest.php that checks the total loaded scripts and styles budget sizes and checks if they exceed the budgets assigned in bundlesize.config.json.
- Changed the json structure of bundlesize.config.json to support both ModulesSizeTest.php and BundleSizeTest.php.
- Handled the new data structure in the BundleSizeTest.php so the dataProvider gets proper data.

Bug: T346813
Change-Id: Id5c28ecec20c4a74a113dd8781b6a022391ae443
2023-11-01 20:50:48 +00:00

20 lines
542 B
PHP

<?php
namespace MediaWiki\Skins\Vector\Tests\Structure;
class BundleSizeTest extends \MediaWiki\Tests\Structure\BundleSizeTest {
/** @inheritDoc */
public function getBundleSizeConfig(): string {
return dirname( __DIR__, 3 ) . '/bundlesize.config.json';
}
/** @inheritDoc */
public function provideBundleSize() {
$bundleSizeConfig = json_decode( file_get_contents( $this->getBundleSizeConfig() ), true );
foreach ( $bundleSizeConfig[ 'modules' ] as $testCase ) {
yield $testCase['resourceModule'] => [ $testCase ];
}
}
}