Merge remote-tracking branch 'origin/support/2.7' into support/3.0

# Conflicts:
#	tests/php-unit-tests/post-build-integration-tests/SetupCssIntegrityChecklistTest.php
#	tests/php-unit-tests/unitary-tests/core/CMDBSource/CMDBSourceTest.php
This commit is contained in:
Pierre Goiffon
2024-01-03 10:41:12 +01:00
6 changed files with 128 additions and 57 deletions

View File

@@ -81,29 +81,44 @@ class DBBackupTest extends ItopTestCase
}
/**
* Host is localhost, we should be forced into tcp
*
* @return void
* @dataProvider GetMysqlCliPortAndTransportOptionsProvider
* @since 2.7.10 3.0.4 3.1.2 3.2.0 test for N°6123 and N°6889
*/
public function testGetMysqlCliTransportOptionWithLocalhost()
public function testGetMysqlCliPortAndTransportOptions(string $sDbHost, ?int $iPort, ?int $iExpectedPortValue, string $sExpectedProtocolCliOption)
{
$sHost= 'localhost';
$sTransport = DBBackup::GetMysqlCliTransportOption($sHost);
if (is_null($iExpectedPortValue)) {
$sExpectedPortCliOption = '';
} else {
$sEscapedPortValue = \DBBackup::EscapeShellArg($iExpectedPortValue);
$sExpectedPortCliOption = ' --port=' . $sEscapedPortValue;
}
$this->assertStringStartsWith('--protocol=tcp', $sTransport);
$this->assertStringEndsWith('--protocol=tcp', $sTransport);
$sActualCliOptions = $this->InvokeNonPublicStaticMethod(DBBackup::class, 'GetMysqlCliPortAndTransportOptions', [$sDbHost, $iPort]);
$this->assertEquals($sExpectedPortCliOption . $sExpectedProtocolCliOption, $sActualCliOptions);
}
/**
* Host is not localhost, we shouldn't be forced into tcp
*
* @return void
*/
public function testGetMysqlCliTransportOptionWithoutLocalhost()
public function GetMysqlCliPortAndTransportOptionsProvider()
{
$sHost= '127.0.0.1';
$sTransport = DBBackup::GetMysqlCliTransportOption($sHost);
$iTestPort = 333306;
$iDefaultPort = 3306; // cannot access \CMDBSource::MYSQL_DEFAULT_PORT in dataprovider :(
$this->assertEmpty($sTransport);
return [
'Localhost no port' => ['localhost', null, null, ''],
'Localhost with port' => ['localhost', $iTestPort, $iTestPort, ' --protocol=tcp'],
// we want both port and protocol for 127.0.0.1, because it is an ip address so using tcp/ip stack !
'127.0.0.1 no port' => ['127.0.0.1', null, $iDefaultPort, ''],
'127.0.0.1 with port' => ['127.0.0.1', $iTestPort, $iTestPort, ''],
'IP no port' => ['192.168.1.15', null, $iDefaultPort, ''],
'IP with port' => ['192.168.1.15', $iTestPort, $iTestPort, ''],
'DNS no port' => ['dbserver.mycompany.com', null, $iDefaultPort, ''],
'DNS with port' => ['dbserver.mycompany.com', $iTestPort, $iTestPort, ''],
'Windows name no port' => ['dbserver', null, $iDefaultPort, ''],
'Windows name with port' => ['dbserver', $iTestPort, $iTestPort, ''],
];
}
}