mediawiki-extensions-Cite/tests/phpunit/unit/CiteHooksUnitTest.php
Adam Wight 8e4c83bfc6 [refactor] Rewrite context as service
Puts the ReferencePreviewsContext behind a service to improve
testability.

Bug: T363162
Change-Id: I63aa4144081a2625da1b89f4d56adb612741c8fc
2024-09-06 16:26:20 +02:00

33 lines
796 B
PHP

<?php
namespace Cite\Tests\Unit;
use Cite\Hooks\CiteHooks;
use Cite\ReferencePreviews\ReferencePreviewsContext;
use MediaWiki\Title\Title;
use MediaWiki\User\Options\StaticUserOptionsLookup;
/**
* @covers \Cite\Hooks\CiteHooks
* @license GPL-2.0-or-later
*/
class CiteHooksUnitTest extends \MediaWikiUnitTestCase {
public function testOnContentHandlerDefaultModelFor() {
$title = $this->createMock( Title::class );
$title->method( 'inNamespace' )
->willReturn( true );
$title->method( 'getText' )
->willReturn( 'Cite-tool-definition.json' );
( new CiteHooks(
$this->createMock( ReferencePreviewsContext::class ),
new StaticUserOptionsLookup( [] )
) )
->onContentHandlerDefaultModelFor( $title, $model );
$this->assertSame( CONTENT_MODEL_JSON, $model );
}
}