mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-24 04:22:51 +00:00
5315297f38
Depends-On: I97d61b5793159cea365740e0563f7b733e0f16de Bug: T47514 Change-Id: Iabfbb6751707813b7ec68f49b35441ab5dbb5622
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Cite\Tests\Unit;
|
|
|
|
use Cite\ResourceLoader\CitationToolDefinition;
|
|
use MediaWiki\ResourceLoader\Context;
|
|
use Message;
|
|
|
|
/**
|
|
* @covers \Cite\ResourceLoader\CitationToolDefinition
|
|
*
|
|
* @license GPL-2.0-or-later
|
|
*/
|
|
class CitationToolDefinitionTest extends \MediaWikiUnitTestCase {
|
|
|
|
public function testGetScript() {
|
|
$context = $this->createResourceLoaderContext();
|
|
|
|
$this->assertSame(
|
|
've.ui.mwCitationTools = [{"name":"n","title":"t"}];',
|
|
CitationToolDefinition::makeScript( $context )
|
|
);
|
|
}
|
|
|
|
private function createResourceLoaderContext(): Context {
|
|
$msg = $this->createMock( Message::class );
|
|
$msg->method( 'inContentLanguage' )
|
|
->willReturnSelf();
|
|
$msg->method( 'plain' )
|
|
->willReturnOnConsecutiveCalls( '', '[{"name":"n"}]' );
|
|
$msg->method( 'text' )
|
|
->willReturn( 't' );
|
|
|
|
$context = $this->createStub( Context::class );
|
|
$context->method( 'msg' )
|
|
->withConsecutive(
|
|
[ 'cite-tool-definition.json' ],
|
|
[ 'visualeditor-cite-tool-definition.json' ],
|
|
[ 'visualeditor-cite-tool-name-n' ]
|
|
)
|
|
->willReturn( $msg );
|
|
$context->method( 'encodeJson' )->willReturnCallback( 'json_encode' );
|
|
return $context;
|
|
}
|
|
|
|
}
|