2019-11-07 19:57:00 +00:00
|
|
|
<?php
|
|
|
|
|
2019-11-12 10:45:13 +00:00
|
|
|
namespace Cite\Tests\Unit;
|
2019-11-07 19:57:00 +00:00
|
|
|
|
2019-11-19 14:12:11 +00:00
|
|
|
use Cite\Hooks\CiteHooks;
|
2019-11-07 19:57:00 +00:00
|
|
|
use ResourceLoader;
|
|
|
|
use Title;
|
|
|
|
|
|
|
|
/**
|
2019-11-19 14:12:11 +00:00
|
|
|
* @coversDefaultClass \Cite\Hooks\CiteHooks
|
2019-11-19 10:31:08 +00:00
|
|
|
*
|
|
|
|
* @license GPL-2.0-or-later
|
2019-11-07 19:57:00 +00:00
|
|
|
*/
|
2019-11-27 10:15:39 +00:00
|
|
|
class CiteHooksUnitTest extends \MediaWikiUnitTestCase {
|
2019-11-07 19:57:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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 );
|
2020-03-09 19:11:18 +00:00
|
|
|
$resourceLoader->method( 'isModuleRegistered' )
|
|
|
|
->willReturn( true );
|
2019-11-07 19:57:00 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|