mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 09:40:49 +00:00
ce27a400e1
The isModuleRegistered() method was introduced a few years ago, when the load order in ResourceLoader was undergoing a change. It used to be that hooks like were run first to register modules, and then wgResourceModules was registered afterwards. This was reversed to disallow mutating the config at run-time from foreign modules and to allow better caching and error detection. It's been several years since then, so this redundant check is no longer needed. ServiceWiring.php in MW core for ResourceLoader always processes config and extension.json first before this hook is called. Bug: T247265 Change-Id: I466f1fa70b8f0e9fe5e8e8df90bb0001b3329b87
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\Hooks\CiteHooks;
|
|
use ResourceLoader;
|
|
use Title;
|
|
|
|
/**
|
|
* @coversDefaultClass \Cite\Hooks\CiteHooks
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class CiteHooksUnitTest extends \MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @covers ::onContentHandlerDefaultModelFor
|
|
*/
|
|
public function testOnContentHandlerDefaultModelFor() {
|
|
$title = $this->createMock( Title::class );
|
|
$title->method( 'inNamespace' )
|
|
->willReturn( true );
|
|
$title->method( 'getText' )
|
|
->willReturn( 'Cite-tool-definition.json' );
|
|
|
|
CiteHooks::onContentHandlerDefaultModelFor( $title, $model );
|
|
|
|
$this->assertSame( CONTENT_MODEL_JSON, $model );
|
|
}
|
|
|
|
/**
|
|
* @covers ::onResourceLoaderTestModules
|
|
*/
|
|
public function testOnResourceLoaderTestModules() {
|
|
$testModules = [];
|
|
$resourceLoader = $this->createMock( ResourceLoader::class );
|
|
$resourceLoader->method( 'isModuleRegistered' )
|
|
->willReturn( true );
|
|
|
|
CiteHooks::onResourceLoaderTestModules( $testModules, $resourceLoader );
|
|
|
|
$this->assertArrayHasKey( 'ext.cite.visualEditor.test', $testModules['qunit'] );
|
|
}
|
|
|
|
/**
|
|
* @covers ::onResourceLoaderRegisterModules
|
|
*/
|
|
public function testOnResourceLoaderRegisterModules() {
|
|
$resourceLoader = $this->createMock( ResourceLoader::class );
|
|
$resourceLoader->expects( $this->atLeastOnce() )
|
|
->method( 'register' );
|
|
|
|
CiteHooks::onResourceLoaderRegisterModules( $resourceLoader );
|
|
}
|
|
|
|
}
|