Merge pull request #20258 from MauricioFauth/settings-tests

Refactor Config\SettingsTest unit tests
This commit is contained in:
Maurício Meneghini Fauth 2026-03-27 10:04:16 -03:00 committed by GitHub
commit e1bc3d7dbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 701 additions and 335 deletions

View File

@ -1724,9 +1724,11 @@ Generic settings
.. config:option:: $cfg['MysqlSslWarningSafeHosts']
:type: array
:type: array [list of non-empty strings]
:default: ``['127.0.0.1', 'localhost']``
.. versionadded:: 5.1.0
This search is case-sensitive and will match the exact string only.
If your setup does not use SSL but is safe because you are using a
local connection or private network, you can add your hostname or :term:`IP` to the list.
@ -1734,14 +1736,11 @@ Generic settings
This check uses the value of :config:option:`$cfg['Servers'][$i]['host']`.
.. versionadded:: 5.1.0
Example configuration
Example configuration:
.. code-block:: php
$cfg['MysqlSslWarningSafeHosts'] = ['127.0.0.1', 'localhost', 'mariadb.local'];
$cfg['MysqlSslWarningSafeHosts'] = ['127.0.0.1', '::1', 'mariadb.local'];
.. config:option:: $cfg['ExecTimeLimit']
@ -3031,7 +3030,7 @@ Languages
.. config:option:: $cfg['AvailableCharsets']
:type: array
:type: array [list of strings]
:default: ``[...]``
Available character sets for MySQL conversion. You can add your own
@ -3039,6 +3038,12 @@ Languages
use. Character sets will be shown in same order as here listed, so if
you frequently use some of these move them to the top.
Example configuration:
.. code-block:: php
$cfg['AvailableCharsets'] = ['utf-8', 'iso-8859-1'];
Web server settings
-------------------

View File

@ -771,7 +771,7 @@ parameters:
-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
count: 45
count: 43
path: src/Config/Settings.php
-

View File

@ -20,6 +20,7 @@ use function defined;
use function in_array;
use function is_array;
use function is_int;
use function is_scalar;
use function is_string;
use function min;
use function sprintf;
@ -67,7 +68,7 @@ use const VERSION_CHECK_DEFAULT;
* PersistentConnections: bool,
* ExecTimeLimit: int<0, max>,
* SessionSavePath: string,
* MysqlSslWarningSafeHosts: array<string>,
* MysqlSslWarningSafeHosts: list<non-empty-string>,
* MemoryLimit: string,
* SkipLockedTables: bool,
* ShowSQL: bool,
@ -174,7 +175,7 @@ use const VERSION_CHECK_DEFAULT;
* FilterLanguages: string,
* RecodingEngine: string,
* IconvExtraParams: string,
* AvailableCharsets: array<string>,
* AvailableCharsets: list<string>,
* NavigationTreePointerEnable: bool,
* BrowsePointerEnable: bool,
* BrowseMarkerEnable: bool,
@ -563,7 +564,7 @@ final class Settings
*
* @link https://docs.phpmyadmin.net/en/latest/config.html#cfg_MysqlSslWarningSafeHosts
*
* @var string[]
* @var list<non-empty-string>
*/
public array $MysqlSslWarningSafeHosts;
@ -1894,7 +1895,7 @@ final class Settings
*
* @link https://docs.phpmyadmin.net/en/latest/config.html#cfg_AvailableCharsets
*
* @var string[]
* @var list<string>
*/
public array $AvailableCharsets;
@ -3349,7 +3350,7 @@ final class Settings
/**
* @param array<int|string, mixed> $settings
*
* @return string[]
* @return list<non-empty-string>
*/
private function setMysqlSslWarningSafeHosts(array $settings): array
{
@ -3358,8 +3359,11 @@ final class Settings
}
$hosts = [];
/** @var mixed $host */
foreach ($settings['MysqlSslWarningSafeHosts'] as $host) {
if (! is_scalar($host)) {
continue;
}
$safeHost = (string) $host;
if ($safeHost === '') {
continue;
@ -4721,7 +4725,7 @@ final class Settings
/**
* @param array<int|string, mixed> $settings
*
* @return string[]
* @return list<string>
*/
private function setAvailableCharsets(array $settings): array
{
@ -4764,8 +4768,11 @@ final class Settings
}
$availableCharsets = [];
/** @var mixed $availableCharset */
foreach ($settings['AvailableCharsets'] as $availableCharset) {
if (! is_scalar($availableCharset)) {
continue;
}
$availableCharsets[] = (string) $availableCharset;
}

File diff suppressed because it is too large Load Diff