Refactor Config\SettingsTest tests
Tests properties individually. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
0fed903688
commit
df4acc931b
@ -16,6 +16,7 @@ use PhpMyAdmin\Config\Settings\Transformations;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_merge;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
@ -38,30 +39,6 @@ class SettingsTest extends TestCase
|
||||
{
|
||||
/** @var array<string, array|bool|int|string|null> */
|
||||
private array $defaultValues = [
|
||||
'PmaAbsoluteUri' => '',
|
||||
'AuthLog' => 'auto',
|
||||
'AuthLogSuccess' => false,
|
||||
'PmaNoRelation_DisableWarning' => false,
|
||||
'SuhosinDisableWarning' => false,
|
||||
'LoginCookieValidityDisableWarning' => false,
|
||||
'ReservedWordDisableWarning' => false,
|
||||
'TranslationWarningThreshold' => 80,
|
||||
'AllowThirdPartyFraming' => false,
|
||||
'blowfish_secret' => '',
|
||||
'Servers' => [],
|
||||
'ServerDefault' => 1,
|
||||
'VersionCheck' => true,
|
||||
'ProxyUrl' => '',
|
||||
'ProxyUser' => '',
|
||||
'ProxyPass' => '',
|
||||
'MaxDbList' => 100,
|
||||
'MaxTableList' => 250,
|
||||
'ShowHint' => true,
|
||||
'MaxCharactersInDisplayedSQL' => 1000,
|
||||
'OBGzip' => 'auto',
|
||||
'PersistentConnections' => false,
|
||||
'ExecTimeLimit' => 300,
|
||||
'SessionSavePath' => '',
|
||||
'MysqlSslWarningSafeHosts' => ['127.0.0.1', 'localhost'],
|
||||
'MemoryLimit' => '-1',
|
||||
'SkipLockedTables' => false,
|
||||
@ -302,13 +279,6 @@ class SettingsTest extends TestCase
|
||||
$settings = new Settings($actualValues);
|
||||
$settingsArray = $settings->asArray();
|
||||
foreach (array_keys($expectedValues) as $key) {
|
||||
if ($key === 'Servers') {
|
||||
$this->assertContainsOnlyInstancesOf(Server::class, $settings->Servers);
|
||||
$this->assertIsArray($expected[$key]);
|
||||
$this->assertSame(array_keys($expected[$key]), array_keys($settings->Servers));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($key === 'Console') {
|
||||
$this->assertInstanceOf(Console::class, $settings->Console);
|
||||
continue;
|
||||
@ -361,30 +331,6 @@ class SettingsTest extends TestCase
|
||||
return [
|
||||
'null values' => [
|
||||
[
|
||||
['PmaAbsoluteUri', null, ''],
|
||||
['AuthLog', null, 'auto'],
|
||||
['AuthLogSuccess', null, false],
|
||||
['PmaNoRelation_DisableWarning', null, false],
|
||||
['SuhosinDisableWarning', null, false],
|
||||
['LoginCookieValidityDisableWarning', null, false],
|
||||
['ReservedWordDisableWarning', null, false],
|
||||
['TranslationWarningThreshold', null, 80],
|
||||
['AllowThirdPartyFraming', null, false],
|
||||
['blowfish_secret', null, ''],
|
||||
['Servers', null, [1 => null]],
|
||||
['ServerDefault', null, 1],
|
||||
['VersionCheck', null, true],
|
||||
['ProxyUrl', null, ''],
|
||||
['ProxyUser', null, ''],
|
||||
['ProxyPass', null, ''],
|
||||
['MaxDbList', null, 100],
|
||||
['MaxTableList', null, 250],
|
||||
['ShowHint', null, true],
|
||||
['MaxCharactersInDisplayedSQL', null, 1000],
|
||||
['OBGzip', null, 'auto'],
|
||||
['PersistentConnections', null, false],
|
||||
['ExecTimeLimit', null, 300],
|
||||
['SessionSavePath', null, ''],
|
||||
['MysqlSslWarningSafeHosts', null, ['127.0.0.1', 'localhost']],
|
||||
['MemoryLimit', null, '-1'],
|
||||
['SkipLockedTables', null, false],
|
||||
@ -550,30 +496,6 @@ class SettingsTest extends TestCase
|
||||
],
|
||||
'valid values' => [
|
||||
[
|
||||
['PmaAbsoluteUri', 'https://www.phpmyadmin.net/', 'https://www.phpmyadmin.net/'],
|
||||
['AuthLog', '/path/to/file', '/path/to/file'],
|
||||
['AuthLogSuccess', true, true],
|
||||
['PmaNoRelation_DisableWarning', true, true],
|
||||
['SuhosinDisableWarning', true, true],
|
||||
['LoginCookieValidityDisableWarning', true, true],
|
||||
['ReservedWordDisableWarning', true, true],
|
||||
['TranslationWarningThreshold', 100, 100],
|
||||
['AllowThirdPartyFraming', 'sameorigin', 'sameorigin'],
|
||||
['blowfish_secret', 'blowfish_secret', 'blowfish_secret'],
|
||||
['Servers', [1 => [], 2 => []], [1 => null, 2 => null]],
|
||||
['ServerDefault', 0, 0],
|
||||
['VersionCheck', false, false],
|
||||
['ProxyUrl', 'test', 'test'],
|
||||
['ProxyUser', 'test', 'test'],
|
||||
['ProxyPass', 'test', 'test'],
|
||||
['MaxDbList', 1, 1],
|
||||
['MaxTableList', 1, 1],
|
||||
['ShowHint', false, false],
|
||||
['MaxCharactersInDisplayedSQL', 1, 1],
|
||||
['OBGzip', true, true],
|
||||
['PersistentConnections', true, true],
|
||||
['ExecTimeLimit', 0, 0],
|
||||
['SessionSavePath', 'test', 'test'],
|
||||
['MysqlSslWarningSafeHosts', ['test1', 'test2'], ['test1', 'test2']],
|
||||
['MemoryLimit', '16M', '16M'],
|
||||
['SkipLockedTables', true, true],
|
||||
@ -868,29 +790,6 @@ class SettingsTest extends TestCase
|
||||
'valid values 11' => [[['NavigationTreeDefaultTabTable2', '', '']]],
|
||||
'valid values with type coercion' => [
|
||||
[
|
||||
['PmaAbsoluteUri', 1234, '1234'],
|
||||
['AuthLog', 1234, '1234'],
|
||||
['AuthLogSuccess', 1, true],
|
||||
['PmaNoRelation_DisableWarning', 1, true],
|
||||
['SuhosinDisableWarning', 1, true],
|
||||
['LoginCookieValidityDisableWarning', 1, true],
|
||||
['ReservedWordDisableWarning', 1, true],
|
||||
['TranslationWarningThreshold', '0', 0],
|
||||
['AllowThirdPartyFraming', 1, true],
|
||||
['blowfish_secret', 1234, '1234'],
|
||||
['ServerDefault', '0', 0],
|
||||
['VersionCheck', 0, false],
|
||||
['ProxyUrl', 1234, '1234'],
|
||||
['ProxyUser', 1234, '1234'],
|
||||
['ProxyPass', 1234, '1234'],
|
||||
['MaxDbList', '1', 1],
|
||||
['MaxTableList', '1', 1],
|
||||
['ShowHint', 0, false],
|
||||
['MaxCharactersInDisplayedSQL', '1', 1],
|
||||
['OBGzip', 0, false],
|
||||
['PersistentConnections', 1, true],
|
||||
['ExecTimeLimit', '0', 0],
|
||||
['SessionSavePath', 1234, '1234'],
|
||||
['MysqlSslWarningSafeHosts', ['127.0.0.1' => 'local', false, 1234 => 1234], ['local', '1234']],
|
||||
['MemoryLimit', 1234, '1234'],
|
||||
['SkipLockedTables', 1, true],
|
||||
@ -1022,13 +921,6 @@ class SettingsTest extends TestCase
|
||||
],
|
||||
'invalid values' => [
|
||||
[
|
||||
['Servers', 'invalid', [1 => null]],
|
||||
['TranslationWarningThreshold', -1, 80],
|
||||
['ServerDefault', -1, 1],
|
||||
['MaxDbList', 0, 100],
|
||||
['MaxTableList', 0, 250],
|
||||
['MaxCharactersInDisplayedSQL', 0, 1000],
|
||||
['ExecTimeLimit', -1, 300],
|
||||
['MysqlSslWarningSafeHosts', 'invalid', ['127.0.0.1', 'localhost']],
|
||||
['CookieSameSite', 'invalid', 'Strict'],
|
||||
['LoginCookieValidity', 0, 1440],
|
||||
@ -1095,8 +987,6 @@ class SettingsTest extends TestCase
|
||||
],
|
||||
'invalid values 2' => [
|
||||
[
|
||||
['Servers', [0 => [], 2 => 'invalid', 'invalid' => [], 4 => []], [4 => null]],
|
||||
['TranslationWarningThreshold', 101, 100],
|
||||
['ForeignKeyDropdownOrder', ['id-content', 'invalid'], ['id-content']],
|
||||
['TrustedProxies', [1234 => 'invalid', 'valid' => 'valid'], ['valid' => 'valid']],
|
||||
['DefaultFunctions', [1234 => 'invalid', 'valid' => 'valid'], ['valid' => 'valid']],
|
||||
@ -1105,7 +995,6 @@ class SettingsTest extends TestCase
|
||||
],
|
||||
'invalid values 3' => [
|
||||
[
|
||||
['Servers', [0 => []], [1 => null]],
|
||||
['ForeignKeyDropdownOrder', 'invalid', ['content-id', 'id-content']],
|
||||
],
|
||||
],
|
||||
@ -1113,6 +1002,402 @@ class SettingsTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForPmaAbsoluteUriProvider */
|
||||
public function testPmaAbsoluteUri(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['PmaAbsoluteUri' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->PmaAbsoluteUri);
|
||||
$this->assertArrayHasKey('PmaAbsoluteUri', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['PmaAbsoluteUri']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForPmaAbsoluteUriProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, ''];
|
||||
yield 'valid value' => ['', ''];
|
||||
yield 'valid value 2' => ['https://www.phpmyadmin.net/', 'https://www.phpmyadmin.net/'];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForAuthLogProvider */
|
||||
public function testAuthLog(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['AuthLog' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->AuthLog);
|
||||
$this->assertArrayHasKey('AuthLog', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['AuthLog']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForAuthLogProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 'auto'];
|
||||
yield 'valid value' => ['', ''];
|
||||
yield 'valid value 2' => ['/path/to/file', '/path/to/file'];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testAuthLogSuccess(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['AuthLogSuccess' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->AuthLogSuccess);
|
||||
$this->assertArrayHasKey('AuthLogSuccess', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['AuthLogSuccess']);
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testPmaNoRelationDisableWarning(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['PmaNoRelation_DisableWarning' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->PmaNoRelation_DisableWarning);
|
||||
$this->assertArrayHasKey('PmaNoRelation_DisableWarning', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['PmaNoRelation_DisableWarning']);
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testSuhosinDisableWarning(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['SuhosinDisableWarning' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->SuhosinDisableWarning);
|
||||
$this->assertArrayHasKey('SuhosinDisableWarning', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['SuhosinDisableWarning']);
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testLoginCookieValidityDisableWarning(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['LoginCookieValidityDisableWarning' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->LoginCookieValidityDisableWarning);
|
||||
$this->assertArrayHasKey('LoginCookieValidityDisableWarning', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['LoginCookieValidityDisableWarning']);
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testReservedWordDisableWarning(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['ReservedWordDisableWarning' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ReservedWordDisableWarning);
|
||||
$this->assertArrayHasKey('ReservedWordDisableWarning', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ReservedWordDisableWarning']);
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForTranslationWarningThresholdProvider */
|
||||
public function testTranslationWarningThreshold(mixed $actual, int $expected): void
|
||||
{
|
||||
$settings = new Settings(['TranslationWarningThreshold' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->TranslationWarningThreshold);
|
||||
$this->assertArrayHasKey('TranslationWarningThreshold', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['TranslationWarningThreshold']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, int}> */
|
||||
public static function valuesForTranslationWarningThresholdProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 80];
|
||||
yield 'valid value' => [100, 100];
|
||||
yield 'valid value with type coercion' => ['0', 0];
|
||||
yield 'invalid value' => [-1, 80];
|
||||
yield 'invalid value 2' => [101, 100];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForAllowThirdPartyFramingProvider */
|
||||
public function testAllowThirdPartyFraming(mixed $actual, bool|string $expected): void
|
||||
{
|
||||
$settings = new Settings(['AllowThirdPartyFraming' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->AllowThirdPartyFraming);
|
||||
$this->assertArrayHasKey('AllowThirdPartyFraming', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['AllowThirdPartyFraming']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, bool|string}> */
|
||||
public static function valuesForAllowThirdPartyFramingProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, false];
|
||||
yield 'valid value' => [false, false];
|
||||
yield 'valid value 2' => [true, true];
|
||||
yield 'valid value 3' => ['sameorigin', 'sameorigin'];
|
||||
yield 'valid value with type coercion' => [1, true];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForBlowfishSecretProvider */
|
||||
public function testBlowfishSecret(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['blowfish_secret' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->blowfish_secret);
|
||||
$this->assertArrayHasKey('blowfish_secret', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['blowfish_secret']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForBlowfishSecretProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, ''];
|
||||
yield 'valid value' => ['', ''];
|
||||
yield 'valid value 2' => ['blowfish_secret', 'blowfish_secret'];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, Server> $expected
|
||||
*
|
||||
* @dataProvider valuesForServersProvider
|
||||
*/
|
||||
public function testServers(mixed $actual, array $expected): void
|
||||
{
|
||||
$settings = new Settings(['Servers' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertEquals($expected, $settings->Servers);
|
||||
$this->assertArrayHasKey('Servers', $settingsArray);
|
||||
$expectedArray = array_map(static fn ($server) => $server->asArray(), $expected);
|
||||
$this->assertSame($expectedArray, $settingsArray['Servers']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, array<int, Server>}> */
|
||||
public static function valuesForServersProvider(): iterable
|
||||
{
|
||||
$server = new Server();
|
||||
|
||||
yield 'null value' => [null, [1 => $server]];
|
||||
yield 'valid value' => [[1 => [], 2 => []], [1 => $server, 2 => $server]];
|
||||
yield 'valid value 2' => [[2 => ['host' => 'test']], [2 => new Server(['host' => 'test'])]];
|
||||
yield 'invalid value' => ['invalid', [1 => $server]];
|
||||
yield 'invalid value 2' => [[0 => [], 2 => 'invalid', 'invalid' => [], 4 => []], [4 => $server]];
|
||||
yield 'invalid value 3' => [[0 => []], [1 => $server]];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForServerDefaultProvider */
|
||||
public function testServerDefault(mixed $actual, int $expected): void
|
||||
{
|
||||
$settings = new Settings(['ServerDefault' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ServerDefault);
|
||||
$this->assertArrayHasKey('ServerDefault', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ServerDefault']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, int}> */
|
||||
public static function valuesForServerDefaultProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 1];
|
||||
yield 'valid value' => [0, 0];
|
||||
yield 'valid value with type coercion' => ['0', 0];
|
||||
yield 'invalid value' => [-1, 1];
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultTrueProvider */
|
||||
public function testVersionCheck(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['VersionCheck' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->VersionCheck);
|
||||
$this->assertArrayHasKey('VersionCheck', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['VersionCheck']);
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForProxyUrlProvider */
|
||||
public function testProxyUrl(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['ProxyUrl' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ProxyUrl);
|
||||
$this->assertArrayHasKey('ProxyUrl', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ProxyUrl']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForProxyUrlProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, ''];
|
||||
yield 'valid value' => ['', ''];
|
||||
yield 'valid value 2' => ['test', 'test'];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForProxyUserProvider */
|
||||
public function testProxyUser(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['ProxyUser' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ProxyUser);
|
||||
$this->assertArrayHasKey('ProxyUser', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ProxyUser']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForProxyUserProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, ''];
|
||||
yield 'valid value' => ['', ''];
|
||||
yield 'valid value 2' => ['test', 'test'];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForProxyPassProvider */
|
||||
public function testProxyPass(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['ProxyPass' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ProxyPass);
|
||||
$this->assertArrayHasKey('ProxyPass', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ProxyPass']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForProxyPassProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, ''];
|
||||
yield 'valid value' => ['', ''];
|
||||
yield 'valid value 2' => ['test', 'test'];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForMaxDbListProvider */
|
||||
public function testMaxDbList(mixed $actual, int $expected): void
|
||||
{
|
||||
$settings = new Settings(['MaxDbList' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->MaxDbList);
|
||||
$this->assertArrayHasKey('MaxDbList', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['MaxDbList']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, int}> */
|
||||
public static function valuesForMaxDbListProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 100];
|
||||
yield 'valid value' => [1, 1];
|
||||
yield 'valid value with type coercion' => ['1', 1];
|
||||
yield 'invalid value' => [0, 100];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForMaxTableListProvider */
|
||||
public function testMaxTableList(mixed $actual, int $expected): void
|
||||
{
|
||||
$settings = new Settings(['MaxTableList' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->MaxTableList);
|
||||
$this->assertArrayHasKey('MaxTableList', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['MaxTableList']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, int}> */
|
||||
public static function valuesForMaxTableListProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 250];
|
||||
yield 'valid value' => [1, 1];
|
||||
yield 'valid value with type coercion' => ['1', 1];
|
||||
yield 'invalid value' => [0, 250];
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultTrueProvider */
|
||||
public function testShowHint(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['ShowHint' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ShowHint);
|
||||
$this->assertArrayHasKey('ShowHint', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ShowHint']);
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForMaxCharactersInDisplayedSQLProvider */
|
||||
public function testMaxCharactersInDisplayedSQL(mixed $actual, int $expected): void
|
||||
{
|
||||
$settings = new Settings(['MaxCharactersInDisplayedSQL' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->MaxCharactersInDisplayedSQL);
|
||||
$this->assertArrayHasKey('MaxCharactersInDisplayedSQL', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['MaxCharactersInDisplayedSQL']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, int}> */
|
||||
public static function valuesForMaxCharactersInDisplayedSQLProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 1000];
|
||||
yield 'valid value' => [1, 1];
|
||||
yield 'valid value with type coercion' => ['1', 1];
|
||||
yield 'invalid value' => [0, 1000];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForOBGzipProvider */
|
||||
public function testOBGzip(mixed $actual, string|bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['OBGzip' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->OBGzip);
|
||||
$this->assertArrayHasKey('OBGzip', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['OBGzip']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string|bool}> */
|
||||
public static function valuesForOBGzipProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 'auto'];
|
||||
yield 'valid value' => [true, true];
|
||||
yield 'valid value 2' => [false, false];
|
||||
yield 'valid value 3' => ['auto', 'auto'];
|
||||
yield 'valid value with type coercion' => [0, false];
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testPersistentConnections(mixed $actual, bool $expected): void
|
||||
{
|
||||
$settings = new Settings(['PersistentConnections' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->PersistentConnections);
|
||||
$this->assertArrayHasKey('PersistentConnections', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['PersistentConnections']);
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForExecTimeLimitProvider */
|
||||
public function testExecTimeLimit(mixed $actual, int $expected): void
|
||||
{
|
||||
$settings = new Settings(['ExecTimeLimit' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->ExecTimeLimit);
|
||||
$this->assertArrayHasKey('ExecTimeLimit', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['ExecTimeLimit']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, int}> */
|
||||
public static function valuesForExecTimeLimitProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, 300];
|
||||
yield 'valid value' => [0, 0];
|
||||
yield 'valid value with type coercion' => ['0', 0];
|
||||
yield 'invalid value' => [-1, 300];
|
||||
}
|
||||
|
||||
/** @dataProvider valuesForSessionSavePathProvider */
|
||||
public function testSessionSavePath(mixed $actual, string $expected): void
|
||||
{
|
||||
$settings = new Settings(['SessionSavePath' => $actual]);
|
||||
$settingsArray = $settings->asArray();
|
||||
$this->assertSame($expected, $settings->SessionSavePath);
|
||||
$this->assertArrayHasKey('SessionSavePath', $settingsArray);
|
||||
$this->assertSame($expected, $settingsArray['SessionSavePath']);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{mixed, string}> */
|
||||
public static function valuesForSessionSavePathProvider(): iterable
|
||||
{
|
||||
yield 'null value' => [null, ''];
|
||||
yield 'valid value' => ['test', 'test'];
|
||||
yield 'valid value 2' => ['', ''];
|
||||
yield 'valid value with type coercion' => [1234, '1234'];
|
||||
}
|
||||
|
||||
/** @dataProvider booleanWithDefaultFalseProvider */
|
||||
public function testShowAll(mixed $actual, bool $expected): void
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user