mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-12-18 09:50:37 +00:00
22752225a1
Turn GadgetRepo into a service, deprecate GadgetRepo::singleton() Change-Id: I0ab14ca936eec1eead91d4eb0970f898628c8388
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Gadgets\Gadget;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @group Gadgets
|
|
*/
|
|
class GadgetResourceLoaderModuleTest extends MediaWikiIntegrationTestCase {
|
|
use GadgetTestTrait;
|
|
|
|
/**
|
|
* @var Gadget
|
|
*/
|
|
private $gadget;
|
|
/**
|
|
* @var TestingAccessWrapper
|
|
*/
|
|
private $gadgetModule;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->gadget = $this->makeGadget( '*foo [ResourceLoader|package]|foo.js|foo.css|foo.json' );
|
|
$this->gadgetModule = $this->makeGadgetModule( $this->gadget );
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\Gadgets\GadgetResourceLoaderModule::getPages
|
|
*/
|
|
public function testGetPages() {
|
|
$pages = $this->gadgetModule->getPages( ResourceLoaderContext::newDummyContext() );
|
|
$this->assertArrayHasKey( 'MediaWiki:Gadget-foo.css', $pages );
|
|
$this->assertArrayHasKey( 'MediaWiki:Gadget-foo.js', $pages );
|
|
$this->assertArrayHasKey( 'MediaWiki:Gadget-foo.json', $pages );
|
|
$this->assertArrayEquals( $pages, [
|
|
[ 'type' => 'style' ],
|
|
[ 'type' => 'script' ],
|
|
[ 'type' => 'data' ]
|
|
] );
|
|
|
|
$nonPackageGadget = $this->makeGadget( '*foo [ResourceLoader]|foo.js|foo.css|foo.json' );
|
|
$nonPackageGadgetModule = $this->makeGadgetModule( $nonPackageGadget );
|
|
$this->assertArrayNotHasKey( 'MediaWiki:Gadget-foo.json',
|
|
$nonPackageGadgetModule->getPages( ResourceLoaderContext::newDummyContext() ) );
|
|
}
|
|
|
|
}
|