mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-04 19:38:16 +00:00
c71109b97b
- Avoid withConsecutive() Bug: T342110 Change-Id: Icb951b461c5e6ea1ced2ab8a183c53265d4a2b4f
46 lines
1.1 KiB
PHP
46 lines
1.1 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' )
|
|
->willReturnMap( [
|
|
[ 'cite-tool-definition.json', $msg ],
|
|
[ 'visualeditor-cite-tool-definition.json', $msg ],
|
|
[ 'visualeditor-cite-tool-name-n', $msg ]
|
|
] );
|
|
$context->method( 'encodeJson' )->willReturnCallback( 'json_encode' );
|
|
return $context;
|
|
}
|
|
|
|
}
|