mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-12-18 09:50:37 +00:00
ce486be160
* Separate out tests for MediaWikiGadgetsDefinitionRepo and Hooks::onGetPreferences. Removed hack in fetchStructuredList() for overriding page content for tests. * Add tests for ES6 gadgets. For this, ResourceLoaderModuleTest is converted back to an integration test. * Removed createGadgetDefinitionPage() test helper method. Now using MediaWikiIntegrationTestCase::editPage(). * Fixed GDNamespaceRepoTest failure when GDNamespaceRepo is the active repo, by clearing WAN process cache. Change-Id: I26b84576a91f6cb0ebae64c5fc1408666d767911
35 lines
982 B
PHP
35 lines
982 B
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Gadgets\Gadget;
|
|
use MediaWiki\Extension\Gadgets\GadgetResourceLoaderModule;
|
|
use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo;
|
|
use MediaWiki\Revision\RevisionLookup;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* A trait providing utility function for testing gadgets.
|
|
* This trait is intended to be used on subclasses of MediaWikiUnitTestCase
|
|
* or MediaWikiIntegrationTestCase.
|
|
*/
|
|
trait GadgetTestTrait {
|
|
/**
|
|
* @param string $line
|
|
* @return Gadget
|
|
*/
|
|
public function makeGadget( string $line ) {
|
|
$wanCache = WANObjectCache::newEmpty();
|
|
$revLookup = $this->createMock( RevisionLookup::class );
|
|
$repo = new MediaWikiGadgetsDefinitionRepo( $wanCache, $revLookup );
|
|
return $repo->newFromDefinition( $line, 'misc' );
|
|
}
|
|
|
|
public function makeGadgetModule( Gadget $g ) {
|
|
$module = TestingAccessWrapper::newFromObject(
|
|
new GadgetResourceLoaderModule( [ 'id' => null ] )
|
|
);
|
|
$module->gadget = $g;
|
|
return $module;
|
|
}
|
|
|
|
}
|