mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
ab3063fee5
This patch does intentionally not touch any file name. Some of the file names are a little weird now, e.g. \Cite\Cite. These can more easily be renamed in later patches. I used https://codesearch.wmflabs.org/search/?q=new%20Cite%5C( and it looks like this code is not used anywhere else. Change-Id: I5f93a224e9cacf45b7a0d68c216a78723364dd96
67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\ResourceLoader\CiteDataModule;
|
|
use Message;
|
|
use ResourceLoaderContext;
|
|
use WebRequest;
|
|
|
|
/**
|
|
* @covers \Cite\ResourceLoader\CiteDataModule
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class CiteDataModuleTest extends \MediaWikiUnitTestCase {
|
|
|
|
protected function setUp() : void {
|
|
global $wgRequest;
|
|
|
|
parent::setUp();
|
|
$wgRequest = $this->createMock( WebRequest::class );
|
|
}
|
|
|
|
public function testGetScript() {
|
|
$module = new CiteDataModule();
|
|
$context = $this->createResourceLoaderContext();
|
|
|
|
$this->assertSame(
|
|
've.init.platform.addMessages({"cite-tool-definition.json":"[{\"title\":\"\"}]"});',
|
|
$module->getScript( $context )
|
|
);
|
|
}
|
|
|
|
public function testGetDependencies() {
|
|
$module = new CiteDataModule();
|
|
|
|
$this->assertContainsOnly( 'string', $module->getDependencies() );
|
|
}
|
|
|
|
public function testGetDefinitionSummary() {
|
|
$module = new CiteDataModule();
|
|
$context = $this->createResourceLoaderContext();
|
|
|
|
$this->assertSame(
|
|
$module->getScript( $context ),
|
|
$module->getDefinitionSummary( $context )[0]['script']
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return ResourceLoaderContext
|
|
*/
|
|
private function createResourceLoaderContext() {
|
|
$msg = $this->createMock( Message::class );
|
|
$msg->method( 'inContentLanguage' )
|
|
->willReturnSelf();
|
|
$msg->method( 'plain' )
|
|
->willReturn( '[{"title":""}]' );
|
|
|
|
$context = $this->createMock( ResourceLoaderContext::class );
|
|
$context->method( 'msg' )
|
|
->willReturn( $msg );
|
|
return $context;
|
|
}
|
|
|
|
}
|