2019-11-07 19:57:00 +00:00
|
|
|
<?php
|
|
|
|
|
2019-11-12 10:45:13 +00:00
|
|
|
namespace Cite\Tests;
|
2019-11-07 19:57:00 +00:00
|
|
|
|
|
|
|
use ApiQuerySiteinfo;
|
2019-11-19 14:12:11 +00:00
|
|
|
use Cite\Hooks\CiteHooks;
|
2023-06-21 14:40:12 +00:00
|
|
|
use MediaWiki\User\StaticUserOptionsLookup;
|
2019-11-07 19:57:00 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-19 14:12:11 +00:00
|
|
|
* @coversDefaultClass \Cite\Hooks\CiteHooks
|
2019-11-19 10:31:08 +00:00
|
|
|
*
|
|
|
|
* @license GPL-2.0-or-later
|
2019-11-07 19:57:00 +00:00
|
|
|
*/
|
|
|
|
class CiteHooksTest extends \MediaWikiIntegrationTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::onResourceLoaderGetConfigVars
|
|
|
|
*/
|
|
|
|
public function testOnResourceLoaderGetConfigVars() {
|
|
|
|
$vars = [];
|
|
|
|
|
2023-10-26 19:55:00 +00:00
|
|
|
$config = $this->getServiceContainer()->getMainConfig();
|
2023-06-21 14:40:12 +00:00
|
|
|
|
|
|
|
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
|
2020-12-28 15:40:47 +00:00
|
|
|
$citeHooks->onResourceLoaderGetConfigVars( $vars, 'vector', $config );
|
2019-11-07 19:57:00 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'wgCiteVisualEditorOtherGroup', $vars );
|
|
|
|
$this->assertArrayHasKey( 'wgCiteResponsiveReferences', $vars );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::onAPIQuerySiteInfoGeneralInfo
|
|
|
|
*/
|
|
|
|
public function testOnAPIQuerySiteInfoGeneralInfo() {
|
|
|
|
$api = $this->createMock( ApiQuerySiteinfo::class );
|
2020-12-28 15:40:47 +00:00
|
|
|
$api->expects( $this->once() )
|
|
|
|
->method( 'getConfig' )
|
2023-10-26 19:55:00 +00:00
|
|
|
->willReturn( $this->getServiceContainer()->getMainConfig() );
|
2020-12-28 15:40:47 +00:00
|
|
|
|
2019-11-07 19:57:00 +00:00
|
|
|
$data = [];
|
|
|
|
|
2023-06-21 14:40:12 +00:00
|
|
|
$citeHooks = new CiteHooks( new StaticUserOptionsLookup( [] ) );
|
2020-12-28 15:40:47 +00:00
|
|
|
$citeHooks->onAPIQuerySiteInfoGeneralInfo( $api, $data );
|
2019-11-07 19:57:00 +00:00
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'citeresponsivereferences', $data );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|