Added right locales and updated locale tests to handle errors (#1168)
This commit is contained in:
parent
e9090a4c2b
commit
cb489c3e69
|
@ -45,6 +45,8 @@ RUN sed -i 's/# en_US ISO-8859-1/en_US ISO-8859-1/g' /etc/locale.gen
|
||||||
RUN sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen
|
RUN sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen
|
||||||
RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
RUN sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
||||||
RUN sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
|
RUN sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
|
||||||
|
RUN sed -i 's/# zh_CN GB2312/zh_CN GB2312/g' /etc/locale.gen
|
||||||
|
RUN sed -i 's/# zh_CN.GB18030 GB18030/zh_CN.GB18030 GB18030/g' /etc/locale.gen
|
||||||
RUN locale-gen
|
RUN locale-gen
|
||||||
|
|
||||||
# set locale to utf-8
|
# set locale to utf-8
|
||||||
|
|
|
@ -114,6 +114,8 @@ jobs:
|
||||||
sudo sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen
|
sudo sed -i 's/# fr_FR@euro ISO-8859-15/fr_FR@euro ISO-8859-15/g' /etc/locale.gen
|
||||||
sudo sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
sudo sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
|
||||||
sudo sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
|
sudo sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
|
||||||
|
sudo sed -i 's/# zh_CN GB2312/zh_CN GB2312/g' /etc/locale.gen
|
||||||
|
sudo sed -i 's/# zh_CN.GB18030 GB18030/zh_CN.GB18030 GB18030/g' /etc/locale.gen
|
||||||
sudo locale-gen
|
sudo locale-gen
|
||||||
export LANG='en_US.UTF-8'
|
export LANG='en_US.UTF-8'
|
||||||
export LANGUAGE='en_US:en'
|
export LANGUAGE='en_US:en'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test Chinese locale in Linux
|
Test Chinese locale in Linux
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
This test will invoke another php scirpt that is saved as GB2312(Simplified Chinese) ANSI format,
|
This test requires ODBC Driver 17.6 or above and will invoke another php script that
|
||||||
namely pdo_test_gb18030.php.
|
is saved as GB2312(Simplified Chinese) ANSI format, namely pdo_test_gb18030.php.
|
||||||
To run this test, create a temporary database first with the correct collation
|
To run this test, create a temporary database first with the correct collation
|
||||||
CREATE DATABASE [GB18030test]
|
CREATE DATABASE [GB18030test]
|
||||||
COLLATE Chinese_PRC_CI_AS
|
COLLATE Chinese_PRC_CI_AS
|
||||||
|
@ -19,6 +19,28 @@ $loc = setlocale(LC_ALL, 'zh_CN.gb18030');
|
||||||
if (empty($loc)) {
|
if (empty($loc)) {
|
||||||
die("skip required gb18030 locale not available");
|
die("skip required gb18030 locale not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once('MsSetup.inc');
|
||||||
|
try {
|
||||||
|
$conn = new PDO("sqlsrv:server=$server", $uid, $pwd);
|
||||||
|
$msodbcsqlVer = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)['DriverVer'];
|
||||||
|
$version = explode(".", $msodbcsqlVer);
|
||||||
|
|
||||||
|
$msodbcsqlMaj = $version[0];
|
||||||
|
$msodbcsqlMin = $version[1];
|
||||||
|
|
||||||
|
if ($msodbcsqlMaj < 17) {
|
||||||
|
die("skip Unsupported ODBC driver version");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($msodbcsqlMaj == 17 && $msodbcsqlMin < 6) {
|
||||||
|
die("skip Unsupported ODBC driver version");
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("skip Something went wrong during SKIPIF.");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
function runTest($conn, $tempDB)
|
function runTest($conn, $tempDB)
|
||||||
|
@ -43,9 +65,11 @@ try {
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
echo $e->getMessage() . PHP_EOL;
|
echo $e->getMessage() . PHP_EOL;
|
||||||
} finally {
|
} finally {
|
||||||
$query = "DROP DATABASE $tempDB";
|
if ($conn) {
|
||||||
$conn->exec($query);
|
$query = "DROP DATABASE $tempDB";
|
||||||
unset($conn);
|
$conn->exec($query);
|
||||||
|
unset($conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test Chinese locale in Linux
|
Test Chinese locale in Linux
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
This test will invoke another php scirpt that is saved as GB2312(Simplified Chinese) ANSI format,
|
This test requires ODBC Driver 17.6 or above and will invoke another php script that
|
||||||
namely sqlsrv_test_gb18030.php.
|
is saved as GB2312(Simplified Chinese) ANSI format, namely sqlsrv_test_gb18030.php.
|
||||||
To run this test, create a temporary database first with the correct collation
|
To run this test, create a temporary database first with the correct collation
|
||||||
CREATE DATABASE [GB18030test]
|
CREATE DATABASE [GB18030test]
|
||||||
COLLATE Chinese_PRC_CI_AS
|
COLLATE Chinese_PRC_CI_AS
|
||||||
|
@ -14,42 +14,68 @@ Drop the temporary database when the test is finished.
|
||||||
PHPT_EXEC=true
|
PHPT_EXEC=true
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
require('skipif_unix_ansitests.inc');
|
require_once('skipif_unix_ansitests.inc');
|
||||||
$loc = setlocale(LC_ALL, 'zh_CN.gb18030');
|
$loc = setlocale(LC_ALL, 'zh_CN.gb18030');
|
||||||
if (empty($loc)) {
|
if (empty($loc)) {
|
||||||
die("skip required gb18030 locale not available");
|
die("skip required gb18030 locale not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once('MsSetup.inc');
|
||||||
|
$connectionInfo = array("UID"=>$userName, "PWD"=>$userPassword);
|
||||||
|
$conn = sqlsrv_connect($server, $connectionInfo);
|
||||||
|
if ($conn === false) {
|
||||||
|
die("skip Could not connect during SKIPIF.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$msodbcsqlVer = sqlsrv_client_info($conn)["DriverVer"];
|
||||||
|
$msodbcsqlMaj = explode(".", $msodbcsqlVer)[0];
|
||||||
|
$msodbcsqlMin = explode(".", $msodbcsqlVer)[1];
|
||||||
|
|
||||||
|
if ($msodbcsqlMaj < 17) {
|
||||||
|
die("skip Unsupported ODBC driver version");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($msodbcsqlMaj == 17 && $msodbcsqlMin < 6) {
|
||||||
|
die("skip Unsupported ODBC driver version");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
function runTest()
|
|
||||||
{
|
|
||||||
require_once('MsSetup.inc');
|
|
||||||
|
|
||||||
|
require_once('MsSetup.inc');
|
||||||
|
|
||||||
|
try {
|
||||||
$options = array("Database"=>"master", "UID"=>$userName, "PWD"=>$userPassword);
|
$options = array("Database"=>"master", "UID"=>$userName, "PWD"=>$userPassword);
|
||||||
$conn = sqlsrv_connect($server, $options);
|
$conn = sqlsrv_connect($server, $options);
|
||||||
if( $conn === false ) {
|
if( $conn === false ) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
throw new Error("Failed to connect");
|
||||||
}
|
}
|
||||||
|
|
||||||
$tempDB = 'GB18030test' . rand(1, 100);
|
$tempDB = 'GB18030test' . rand(1, 100);
|
||||||
$query = "CREATE DATABASE $tempDB COLLATE Chinese_PRC_CI_AS";
|
$query = "CREATE DATABASE $tempDB COLLATE Chinese_PRC_CI_AS";
|
||||||
$stmt = sqlsrv_query($conn, $query);
|
$stmt = sqlsrv_query($conn, $query);
|
||||||
if ($stmt === false) {
|
if ($stmt === false) {
|
||||||
echo "Failed to create the database $tempDB\n";
|
throw new Error("Failed to create the database $tempDB");
|
||||||
}
|
}
|
||||||
|
|
||||||
shell_exec("export LC_ALL=zh_CN.gb18030");
|
shell_exec("export LC_ALL=zh_CN.gb18030");
|
||||||
shell_exec("iconv -c -f GB2312 -t GB18030 sqlsrv_test_gb18030.php > test_gb18030.php");
|
shell_exec("iconv -c -f GB2312 -t GB18030 sqlsrv_test_gb18030.php > test_gb18030.php");
|
||||||
|
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/test_gb18030.php $tempDB"));
|
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/test_gb18030.php $tempDB"));
|
||||||
|
} catch (Error $err) {
|
||||||
$query = "DROP DATABASE $tempDB";
|
echo $err->getMessage() . PHP_EOL;
|
||||||
sqlsrv_query($conn, $query);
|
print_r(sqlsrv_errors());
|
||||||
sqlsrv_close($conn);
|
} finally {
|
||||||
|
if ($conn) {
|
||||||
|
if (!empty($tempDB)) {
|
||||||
|
$query = "DROP DATABASE $tempDB";
|
||||||
|
sqlsrv_query($conn, $query);
|
||||||
|
}
|
||||||
|
sqlsrv_close($conn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runTest();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Done
|
Done
|
||||||
|
|
Loading…
Reference in a new issue