mediawiki-extensions-Cite/tests/phpunit/unit/CitationToolDefinitionTest.php
thiemowmde 4377f0923d More simple and consistent @covers and @license tags
Same arguments as in Iafa2412. The one reason to use more detailled
per-method @covers annotations is to avoid "accidental coverage"
where code is marked as being covered by tests that don't assert
anything that would be meaningful for this code. This is especially a
problem with older, bigger classes with lots of side effects.

But all the new classes we introduced over the years are small, with
predictable, local effects.

That's also why we keep the more detailled @covers annotations for
the original Cite class.

Bug: T353227
Bug: T353269
Change-Id: I69850f4d740d8ad5a7c2368b9068dc91e47cc797
2023-12-15 12:12:16 +01:00

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