2023-08-25 21:39:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare( strict_types=1 );
|
|
|
|
|
2024-05-15 05:24:43 +00:00
|
|
|
namespace MediaWiki\Skins\Citizen\Tests\Integration\Hooks;
|
2023-08-25 21:39:37 +00:00
|
|
|
|
|
|
|
use MediaWiki\ResourceLoader\Context;
|
|
|
|
use MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks;
|
2024-05-15 05:24:43 +00:00
|
|
|
use MediaWikiIntegrationTestCase;
|
2023-08-25 21:39:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group Citizen
|
|
|
|
*/
|
2024-05-15 05:24:43 +00:00
|
|
|
class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
|
2023-08-25 21:39:37 +00:00
|
|
|
/**
|
|
|
|
* @covers \MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCitizenResourceLoaderConfig() {
|
|
|
|
$this->overrideConfigValues( [
|
|
|
|
'CitizenEnablePreferences' => false,
|
2024-05-27 21:16:23 +00:00
|
|
|
'CitizenOverflowInheritedClasses' => false,
|
2024-05-27 19:54:26 +00:00
|
|
|
'CitizenOverflowNowrapClasses' => false,
|
2023-08-25 21:39:37 +00:00
|
|
|
'CitizenSearchModule' => false,
|
|
|
|
] );
|
|
|
|
|
|
|
|
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
|
|
|
|
|
|
|
|
$config = ResourceLoaderHooks::getCitizenResourceLoaderConfig(
|
|
|
|
$rlCtxMock,
|
|
|
|
$this->getServiceContainer()->getMainConfig()
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertArraySubmapSame( [
|
|
|
|
'wgCitizenEnablePreferences' => false,
|
|
|
|
'wgCitizenSearchModule' => false,
|
2024-05-27 21:16:23 +00:00
|
|
|
'wgCitizenOverflowInheritedClasses' => false,
|
2024-05-27 19:54:26 +00:00
|
|
|
'wgCitizenOverflowNowrapClasses' => false,
|
2023-08-25 21:39:37 +00:00
|
|
|
], $config );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \MediaWiki\Skins\Citizen\Hooks\ResourceLoaderHooks
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCitizenResourceLoaderConfigAllTrue() {
|
|
|
|
$this->overrideConfigValues( [
|
|
|
|
'CitizenEnablePreferences' => true,
|
2024-05-27 21:16:23 +00:00
|
|
|
'CitizenOverflowInheritedClasses' => true,
|
2024-05-27 19:54:26 +00:00
|
|
|
'CitizenOverflowNowrapClasses' => true,
|
2023-08-25 21:39:37 +00:00
|
|
|
'CitizenSearchModule' => true,
|
|
|
|
] );
|
|
|
|
|
|
|
|
$rlCtxMock = $this->getMockBuilder( Context::class )->disableOriginalConstructor()->getMock();
|
|
|
|
|
|
|
|
$config = ResourceLoaderHooks::getCitizenResourceLoaderConfig(
|
|
|
|
$rlCtxMock,
|
|
|
|
$this->getServiceContainer()->getMainConfig()
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertArraySubmapSame( [
|
|
|
|
'wgCitizenEnablePreferences' => true,
|
2024-05-27 21:16:23 +00:00
|
|
|
'whCitizenOverflowInheritedClasses' => true,
|
2024-05-27 19:54:26 +00:00
|
|
|
'wgCitizenOverflowNowrapClasses' => true,
|
2023-08-25 21:39:37 +00:00
|
|
|
'wgCitizenSearchModule' => 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 );
|
|
|
|
}
|
|
|
|
}
|