mediawiki-extensions-Cite/tests/phpunit/CiteHooksTest.php
Jon Harald Søby c66371b3d9 Move Cite-specific settings from WikiEditor
The WikiEditor extension has a button and some help text that
is only applicable if the Cite extension is enabled. Move
that (with some modifications) to the Cite extension instead.

Bug: T339973
Depends-On: I8256660f9c6886d6764b45735284e00308fc56e5
Change-Id: Ib3fdc897dd3330f69c5832003d4c3cb1e6dba2f3
2023-06-28 20:22:14 +02:00

50 lines
1.3 KiB
PHP

<?php
namespace Cite\Tests;
use ApiQuerySiteinfo;
use Cite\Hooks\CiteHooks;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\StaticUserOptionsLookup;
/**
* @coversDefaultClass \Cite\Hooks\CiteHooks
*
* @license GPL-2.0-or-later
*/
class CiteHooksTest extends \MediaWikiIntegrationTestCase {
/**
* @covers ::onResourceLoaderGetConfigVars
*/
public function testOnResourceLoaderGetConfigVars() {
$vars = [];
$config = MediaWikiServices::getInstance()->getMainConfig();
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
$citeHooks->onResourceLoaderGetConfigVars( $vars, 'vector', $config );
$this->assertArrayHasKey( 'wgCiteVisualEditorOtherGroup', $vars );
$this->assertArrayHasKey( 'wgCiteResponsiveReferences', $vars );
}
/**
* @covers ::onAPIQuerySiteInfoGeneralInfo
*/
public function testOnAPIQuerySiteInfoGeneralInfo() {
$api = $this->createMock( ApiQuerySiteinfo::class );
$api->expects( $this->once() )
->method( 'getConfig' )
->willReturn( MediaWikiServices::getInstance()->getMainConfig() );
$data = [];
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
$citeHooks->onAPIQuerySiteInfoGeneralInfo( $api, $data );
$this->assertArrayHasKey( 'citeresponsivereferences', $data );
}
}