mediawiki-extensions-Cite/tests/phpunit/unit/CitationToolDefinitionTest.php
Daimona Eaytoy c71109b97b Update tests for PHPUnit 9.6
- Avoid withConsecutive()

Bug: T342110
Change-Id: Icb951b461c5e6ea1ced2ab8a183c53265d4a2b4f
2023-11-22 00:15:20 +01:00

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;
}
}