2021-10-17 13:05:15 +00:00
|
|
|
<?php
|
|
|
|
|
2022-02-06 18:54:47 +00:00
|
|
|
use MediaWiki\Extension\Gadgets\Gadget;
|
|
|
|
use MediaWiki\Extension\Gadgets\GadgetResourceLoaderModule;
|
|
|
|
use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo;
|
2021-10-17 13:05:15 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
|
|
|
class GadgetTestUtils {
|
|
|
|
/**
|
|
|
|
* @param string $line
|
|
|
|
* @return Gadget
|
|
|
|
*/
|
|
|
|
public static function makeGadget( $line ) {
|
|
|
|
$repo = new MediaWikiGadgetsDefinitionRepo();
|
2022-02-06 18:54:47 +00:00
|
|
|
return $repo->newFromDefinition( $line, 'misc' );
|
2021-10-17 13:05:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function makeGadgetModule( Gadget $g ) {
|
|
|
|
$module = TestingAccessWrapper::newFromObject(
|
|
|
|
new GadgetResourceLoaderModule( [ 'id' => null ] )
|
|
|
|
);
|
|
|
|
$module->gadget = $g;
|
|
|
|
return $module;
|
|
|
|
}
|
|
|
|
}
|