editPage( 'Gadget definition:Test', '{"module":{"pages":["test.js"]}, "settings":{"default":true}}' ); $services = $this->getServiceContainer(); $repo = new GadgetDefinitionNamespaceRepo( $services->getMainWANObjectCache(), $services->getRevisionLookup() ); $gadget = $repo->getGadget( 'Test' ); $this->assertTrue( $gadget->isOnByDefault() ); $this->assertArrayEquals( [ "Gadget:test.js" ], $gadget->getScripts() ); } /** * @covers \MediaWiki\Extension\Gadgets\GadgetDefinitionNamespaceRepo */ public function testGetGadgetIds() { $this->editPage( 'Gadget definition:X1', '{"module":{"pages":["Gadget:test.js"]}, "settings":{"default":true}}' ); $this->editPage( 'Gadget definition:X2', '{"module":{"pages":["Gadget:test.js"]}, "settings":{"default":true}}' ); $services = $this->getServiceContainer(); $wanCache = $services->getMainWANObjectCache(); $repo = new GadgetDefinitionNamespaceRepo( $wanCache, $services->getRevisionLookup() ); $wanCache->clearProcessCache(); $this->assertArrayEquals( [ 'X1', 'X2' ], $repo->getGadgetIds() ); } }