Merge pull request #656 from yitam/localeUTF8
Modify tests related to locale testing
This commit is contained in:
commit
a77f9bd4a8
|
@ -78,8 +78,16 @@ if ($t === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
die(print_r(sqlsrv_errors(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t != "So?e sä???? ?SCII-te×t") {
|
// If connected with AE, $t may be different in Windows and other platforms
|
||||||
die("varchar(100) doesn't match So?e sä???? ?SCII-te×t");
|
// this is a workaround for now -- to make sure there are some '?' in $t
|
||||||
|
if (!AE\isColEncrypted() && $t !== "So?e sä???? ?SCII-te×t") {
|
||||||
|
die("varchar(100) \'$t\' doesn't match So?e sä???? ?SCII-te×t");
|
||||||
|
} else {
|
||||||
|
$arr = explode('?', $t);
|
||||||
|
if (count($arr) == 1) {
|
||||||
|
// this means there is no question mark in $t
|
||||||
|
die("varchar(100) value \'$t\' is unexpected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STRING('utf-8'));
|
$t = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||||
|
@ -87,7 +95,7 @@ if ($t === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
die(print_r(sqlsrv_errors(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t != $utf8) {
|
if ($t !== $utf8) {
|
||||||
die("nvarchar(100) doesn't match the inserted UTF-8 text.");
|
die("nvarchar(100) doesn't match the inserted UTF-8 text.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +104,7 @@ if ($t === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
die(print_r(sqlsrv_errors(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t != $utf8) {
|
if ($t !== $utf8) {
|
||||||
die("nvarchar(max) doesn't match the inserted UTF-8 text.");
|
die("nvarchar(max) doesn't match the inserted UTF-8 text.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +137,7 @@ if ($s === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
die(print_r(sqlsrv_errors(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t != $utf8) {
|
if ($t !== $utf8) {
|
||||||
die("Incorrect results from Utf8OutProc\n");
|
die("Incorrect results from Utf8OutProc\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +156,7 @@ if ($s === false) {
|
||||||
// retrieve all the results
|
// retrieve all the results
|
||||||
while (sqlsrv_next_result($s));
|
while (sqlsrv_next_result($s));
|
||||||
|
|
||||||
if ($t != $utf8) {
|
if ($t !== $utf8) {
|
||||||
die("Incorrect results from Utf8OutWithResultsetProc\n");
|
die("Incorrect results from Utf8OutWithResultsetProc\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +177,7 @@ if ($s === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
die(print_r(sqlsrv_errors(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t != $utf8) {
|
if ($t !== $utf8) {
|
||||||
die("Incorrect results from Utf8InOutProc 1\n");
|
die("Incorrect results from Utf8InOutProc 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -452,6 +452,14 @@ function setUSAnsiLocale()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetLocaleToDefault()
|
||||||
|
{
|
||||||
|
// Like setUSAnsiLocale() above, this method is only needed in non-Windows environment
|
||||||
|
if (!isWindows()) {
|
||||||
|
setlocale(LC_ALL, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// non-UTF8 locale support in ODBC 17 and above only
|
// non-UTF8 locale support in ODBC 17 and above only
|
||||||
// if AE enabled, only supported in Windows (AE limitations)
|
// if AE enabled, only supported in Windows (AE limitations)
|
||||||
function isLocaleSupported()
|
function isLocaleSupported()
|
||||||
|
|
|
@ -107,6 +107,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
prepareAndExecute(5);
|
prepareAndExecute(5);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -85,6 +85,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
fetchFields();
|
fetchFields();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -115,6 +115,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
fetchFields();
|
fetchFields();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -170,6 +170,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
fetchRow(1, 4);
|
fetchRow(1, 4);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -145,6 +145,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
fetchRow(0, 2);
|
fetchRow(0, 2);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -103,6 +103,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
fetchFields();
|
fetchFields();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -154,6 +154,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
fetchRow(10);
|
fetchRow(10);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -148,6 +148,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
streamRead(20, 1);
|
streamRead(20, 1);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -184,6 +184,7 @@ endTest($testName);
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
try {
|
try {
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
streamScroll(20, 1);
|
streamScroll(20, 1);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
|
@ -264,6 +264,7 @@ else {
|
||||||
|
|
||||||
// test utf8
|
// test utf8
|
||||||
setUTF8Data(true);
|
setUTF8Data(true);
|
||||||
|
resetLocaleToDefault();
|
||||||
runtest();
|
runtest();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue