mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-03 19:16:09 +00:00
7157c7f494
Note this codebase appears to be dual-licensed. Some files mention MIT, but extension.json and some other files mention GPL. Since WMDE typically uses GPL, I will continue to mark the files we created as such. Change-Id: I126da10f7fb13a6d4c99e96e72d024b2e5ecee06
67 lines
1.4 KiB
PHP
67 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use CiteDataModule;
|
|
use Message;
|
|
use ResourceLoaderContext;
|
|
use WebRequest;
|
|
|
|
/**
|
|
* @covers \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;
|
|
}
|
|
|
|
}
|