mediawiki-extensions-Gadgets/tests/phpunit/GadgetTestUtils.php
Reedy 01f6a6c34e Namespace extension
Bug: T278278
Change-Id: I49b57e68079c998419e235b1727eea8c121c234b
2022-03-05 17:03:35 +00:00

26 lines
646 B
PHP

<?php
use MediaWiki\Extension\Gadgets\Gadget;
use MediaWiki\Extension\Gadgets\GadgetResourceLoaderModule;
use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo;
use Wikimedia\TestingAccessWrapper;
class GadgetTestUtils {
/**
* @param string $line
* @return Gadget
*/
public static function makeGadget( $line ) {
$repo = new MediaWikiGadgetsDefinitionRepo();
return $repo->newFromDefinition( $line, 'misc' );
}
public static function makeGadgetModule( Gadget $g ) {
$module = TestingAccessWrapper::newFromObject(
new GadgetResourceLoaderModule( [ 'id' => null ] )
);
$module->gadget = $g;
return $module;
}
}