mediawiki-skins-Citizen/tests/phpunit/integration/Hooks/ResourceLoaderHooksTest.php
alistair3149 03da361b97
feat(components): rewrite template data partials into CitizenComponent components (#846)
- Refactor existing template data-related partials into CitizenComponent components
- Re-implement user menu header as UserInfo
- Add description text for anon and temp user in UserMenu
---------

Co-authored-by: github-actions <github-actions@users.noreply.github.com>
2024-05-15 01:24:43 -04:00

117 lines
3.3 KiB
PHP

<?php
declare( strict_types=1 );
namespace MediaWiki\Skins\Citizen\Tests\Integration\Hooks;
use MediaWiki\ResourceLoader\Context;
use MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks;
use MediaWikiIntegrationTestCase;
/**
* @group Citizen
*/
class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
/**
* @covers \MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks
* @return void
*/
public function testCitizenResourceLoaderConfig() {
$this->overrideConfigValues( [
'CitizenEnablePreferences' => false,
'CitizenSearchModule' => false,
'CitizenTableNowrapClasses' => false,
] );
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
$config = ResourceLoaderHooks::getCitizenResourceLoaderConfig(
$rlCtxMock,
$this->getServiceContainer()->getMainConfig()
);
$this->assertArraySubmapSame( [
'wgCitizenEnablePreferences' => false,
'wgCitizenSearchModule' => false,
'wgCitizenTableNowrapClasses' => false,
], $config );
}
/**
* @covers \MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks
* @return void
*/
public function testCitizenResourceLoaderConfigAllTrue() {
$this->overrideConfigValues( [
'CitizenEnablePreferences' => true,
'CitizenSearchModule' => true,
'CitizenTableNowrapClasses' => true,
] );
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
$config = ResourceLoaderHooks::getCitizenResourceLoaderConfig(
$rlCtxMock,
$this->getServiceContainer()->getMainConfig()
);
$this->assertArraySubmapSame( [
'wgCitizenEnablePreferences' => true,
'wgCitizenSearchModule' => true,
'wgCitizenTableNowrapClasses' => true,
], $config );
}
/**
* @covers \MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks
* @return void
*/
public function testCitizenPreferencesResourceLoaderConfig() {
$this->overrideConfigValues( [
'CitizenThemeDefault' => 'dark',
] );
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
$config = ResourceLoaderHooks::getCitizenPreferencesResourceLoaderConfig(
$rlCtxMock,
$this->getServiceContainer()->getMainConfig()
);
$this->assertArraySubmapSame( [
'wgCitizenThemeDefault' => 'dark',
], $config );
}
/**
* @covers \MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks
* @return void
*/
public function testCitizenSearchResourceLoaderConfig() {
$this->overrideConfigValues( [
'CitizenSearchGateway' => 'CitizenSearchGateway',
'CitizenSearchDescriptionSource' => 'CitizenSearchDescriptionSource',
'CitizenMaxSearchResults' => 'CitizenMaxSearchResults',
'Script' => 'Script',
'ScriptPath' => 'ScriptPath',
'SearchSuggestCacheExpiry' => 'SearchSuggestCacheExpiry',
] );
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
$config = ResourceLoaderHooks::getCitizenSearchResourceLoaderConfig(
$rlCtxMock,
$this->getServiceContainer()->getMainConfig()
);
$this->assertArraySubmapSame( [
'wgCitizenSearchGateway' => 'CitizenSearchGateway',
'wgCitizenSearchDescriptionSource' => 'CitizenSearchDescriptionSource',
'wgCitizenMaxSearchResults' => 'CitizenMaxSearchResults',
'wgScript' => 'Script',
'wgScriptPath' => 'ScriptPath',
'isMediaSearchExtensionEnabled' => false,
], $config );
}
}