Modified locale tests to work in both linux and mac (#1074)
This commit is contained in:
parent
f64df0497f
commit
9c9c04a43d
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
GitHub issue 1063 - make setting locale info configurable
|
||||
--DESCRIPTION--
|
||||
This test verifies that the users can configure using ini file to set application locale using the system locale or not. This test is valid for Linux and macOS systems only.
|
||||
This test assumes LC_ALL is 'en_US.UTF-8' and verifies that the users can configure using ini file to set application locale using the system locale or not. This test is valid for Linux and macOS systems only.
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -12,8 +12,8 @@ function runTest($val, $file, $locale)
|
|||
{
|
||||
print("\n***sqlsrv.SetLocaleInfo = $val\npdo_sqlsrv.set_locale_info = $val***\n\n");
|
||||
shell_exec("echo 'sqlsrv.SetLocaleInfo = $val\npdo_sqlsrv.set_locale_info = $val' > $file");
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/pdo_1063_test_locale.php "));
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/pdo_1063_test_locale.php $locale"));
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/pdo_1063_test_locale.php $val"));
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/pdo_1063_test_locale.php $val $locale"));
|
||||
}
|
||||
|
||||
$inifile = PHP_CONFIG_FILE_SCAN_DIR."/99-overrides.ini";
|
||||
|
@ -31,21 +31,12 @@ runTest(2, $inifile, $locale2);
|
|||
pdo_sqlsrv.set_locale_info = 0***
|
||||
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Currency symbol:
|
||||
Thousands_sep:
|
||||
Amount formatted: 10000.99
|
||||
Friday
|
||||
December
|
||||
3.14159
|
||||
**End**
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Setting LC_ALL: en_US.ISO-8859-1
|
||||
Currency symbol: $
|
||||
Thousands_sep: ,
|
||||
Amount formatted: $10,000.99
|
||||
Friday
|
||||
December
|
||||
|
@ -56,21 +47,12 @@ December
|
|||
pdo_sqlsrv.set_locale_info = 1***
|
||||
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Currency symbol:
|
||||
Thousands_sep:
|
||||
Amount formatted: 10000.99
|
||||
Friday
|
||||
December
|
||||
3.14159
|
||||
**End**
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Setting LC_ALL: de_DE.UTF-8
|
||||
Currency symbol: €
|
||||
Thousands_sep: .
|
||||
Amount formatted: 10.000,99 €
|
||||
Freitag
|
||||
Dezember
|
||||
|
@ -81,21 +63,12 @@ Dezember
|
|||
pdo_sqlsrv.set_locale_info = 2***
|
||||
|
||||
**Begin**
|
||||
Current LC_MONETARY: en_US.UTF-8
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Currency symbol: $
|
||||
Thousands_sep: ,
|
||||
Amount formatted: $10,000.99
|
||||
Friday
|
||||
December
|
||||
3.14159
|
||||
**End**
|
||||
**Begin**
|
||||
Current LC_MONETARY: en_US.UTF-8
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Setting LC_ALL: de_DE.UTF-8
|
||||
Currency symbol: €
|
||||
Thousands_sep: .
|
||||
Amount formatted: 10.000,99 €
|
||||
Freitag
|
||||
Dezember
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
// This test is invoked by pdo_1063_locale_configs.phpt
|
||||
|
||||
function dropTable($conn, $tableName)
|
||||
{
|
||||
|
@ -6,13 +7,9 @@ function dropTable($conn, $tableName)
|
|||
$conn->exec($tsql);
|
||||
}
|
||||
|
||||
function printMoney($amt)
|
||||
function printMoney($amt, $info)
|
||||
{
|
||||
// The money_format() function is deprecated in PHP 7.4, so use intl NumberFormatter
|
||||
$info = localeconv();
|
||||
echo "Currency symbol: " . $info['currency_symbol'] . PHP_EOL;
|
||||
echo "Thousands_sep: " . $info['thousands_sep'] . PHP_EOL;
|
||||
|
||||
$loc = setlocale(LC_MONETARY, 0);
|
||||
$symbol = $info['int_curr_symbol'];
|
||||
|
||||
|
@ -28,22 +25,67 @@ function printMoney($amt)
|
|||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
// This test is invoked by pdo_1063_locale_configs.phpt
|
||||
require_once('MsSetup.inc');
|
||||
|
||||
$locale = ($_SERVER['argv'][1] ?? '');
|
||||
$setLocaleInfo = ($_SERVER['argv'][1]);
|
||||
$locale = ($_SERVER['argv'][2] ?? '');
|
||||
|
||||
echo "**Begin**" . PHP_EOL;
|
||||
echo "Current LC_MONETARY: " . setlocale(LC_MONETARY, 0) . PHP_EOL;
|
||||
echo "Current LC_CTYPE: " . setlocale(LC_CTYPE, 0) . PHP_EOL;
|
||||
|
||||
// Assuming LC_ALL is 'en_US.UTF-8', so is LC_CTYPE
|
||||
// But default LC_MONETARY varies
|
||||
$ctype = 'en_US.UTF-8';
|
||||
switch ($setLocaleInfo) {
|
||||
case 0:
|
||||
case 1:
|
||||
$m = 'C'; $symbol = ''; $sep = '';
|
||||
break;
|
||||
case 2:
|
||||
$m = 'en_US.UTF-8'; $symbol = '$'; $sep = ',';
|
||||
break;
|
||||
default:
|
||||
die("Unexpected $setLocaleInfo\n");
|
||||
break;
|
||||
}
|
||||
|
||||
$m1 = setlocale(LC_MONETARY, 0);
|
||||
if ($m !== $m1) {
|
||||
echo "Unexpected LC_MONETARY: $m1" . PHP_EOL;
|
||||
}
|
||||
$c1 = setlocale(LC_CTYPE, 0);
|
||||
if ($ctype !== $c1) {
|
||||
echo "Unexpected LC_CTYPE: $c1" . PHP_EOL;
|
||||
}
|
||||
|
||||
// Set a different locale, if the input is not empty
|
||||
if (!empty($locale)) {
|
||||
$loc = setlocale(LC_ALL, $locale);
|
||||
echo "Setting LC_ALL: " . $loc . PHP_EOL;
|
||||
if ($loc !== $locale) {
|
||||
echo "Unexpected $loc for LC_ALL " . PHP_EOL;
|
||||
}
|
||||
|
||||
// Currency symbol and thousands separator in Linux and macOS may be different
|
||||
if ($loc === 'de_DE.UTF-8') {
|
||||
$symbol = strtoupper(PHP_OS) === 'LINUX' ? '€' : 'Eu';
|
||||
$sep = strtoupper(PHP_OS) === 'LINUX' ? '.' : '';
|
||||
} else {
|
||||
$symbol = '$';
|
||||
$sep = ',';
|
||||
}
|
||||
}
|
||||
|
||||
$info = localeconv();
|
||||
if ($symbol !== $info['currency_symbol']) {
|
||||
echo "$locale: Expected currency symbol '$symbol' but get '" . $info['currency_symbol'] . "'";
|
||||
echo PHP_EOL;
|
||||
}
|
||||
if ($sep !== $info['thousands_sep']) {
|
||||
echo "$locale: Expected thousands separator '$sep' but get '" . $info['currency_symbol'] . "'";
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
$n1 = 10000.98765;
|
||||
printMoney($n1);
|
||||
printMoney($n1, $info);
|
||||
|
||||
echo strftime("%A", strtotime("12/25/2020")) . PHP_EOL;
|
||||
echo strftime("%B", strtotime("12/25/2020")) . PHP_EOL;
|
||||
|
|
|
@ -3,9 +3,7 @@ Fetch Field Data Test verifies the data retrieved via sqlsrv_get_field
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?
|
||||
require('skipif_versions_old.inc');
|
||||
?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@ by checking all fetch type modes.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?
|
||||
require('skipif_versions_old.inc');
|
||||
?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
|
|
@ -5,9 +5,7 @@ Verifies the functionality of "sqlsrv_next_result"
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?
|
||||
require('skipif_versions_old.inc');
|
||||
?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
|
|
@ -6,9 +6,7 @@ can be successfully retrieved as streams.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?
|
||||
require('skipif_versions_old.inc');
|
||||
?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
|
|
@ -5,9 +5,7 @@ Verifies the streaming behavior with scrollable resultsets.
|
|||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?
|
||||
require('skipif_versions_old.inc');
|
||||
?>
|
||||
<?php require('skipif_versions_old.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
GitHub issue 1063 - make setting locale info configurable
|
||||
--DESCRIPTION--
|
||||
This test verifies that the users can configure using ini file to set application locale using the system locale or not. This test is valid for Linux and macOS systems only.
|
||||
This test assumes LC_ALL is 'en_US.UTF-8' and verifies that the users can configure using ini file to set application locale using the system locale or not. This test is valid for Linux and macOS systems only.
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -12,8 +12,8 @@ function runTest($val, $file, $locale)
|
|||
{
|
||||
print("\n***sqlsrv.SetLocaleInfo = $val\npdo_sqlsrv.set_locale_info = $val***\n\n");
|
||||
shell_exec("echo 'sqlsrv.SetLocaleInfo = $val\npdo_sqlsrv.set_locale_info = $val' > $file");
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/srv_1063_test_locale.php "));
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/srv_1063_test_locale.php $locale"));
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/srv_1063_test_locale.php $val"));
|
||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/srv_1063_test_locale.php $val $locale"));
|
||||
}
|
||||
|
||||
$inifile = PHP_CONFIG_FILE_SCAN_DIR."/99-overrides.ini";
|
||||
|
@ -31,21 +31,12 @@ runTest(2, $inifile, $locale2);
|
|||
pdo_sqlsrv.set_locale_info = 0***
|
||||
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Currency symbol:
|
||||
Thousands_sep:
|
||||
Amount formatted: 10000.99
|
||||
Friday
|
||||
December
|
||||
3.14159
|
||||
**End**
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Setting LC_ALL: en_US.ISO-8859-1
|
||||
Currency symbol: $
|
||||
Thousands_sep: ,
|
||||
Amount formatted: $10,000.99
|
||||
Friday
|
||||
December
|
||||
|
@ -56,21 +47,12 @@ December
|
|||
pdo_sqlsrv.set_locale_info = 1***
|
||||
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Currency symbol:
|
||||
Thousands_sep:
|
||||
Amount formatted: 10000.99
|
||||
Friday
|
||||
December
|
||||
3.14159
|
||||
**End**
|
||||
**Begin**
|
||||
Current LC_MONETARY: C
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Setting LC_ALL: de_DE.UTF-8
|
||||
Currency symbol: €
|
||||
Thousands_sep: .
|
||||
Amount formatted: 10.000,99 €
|
||||
Freitag
|
||||
Dezember
|
||||
|
@ -81,21 +63,12 @@ Dezember
|
|||
pdo_sqlsrv.set_locale_info = 2***
|
||||
|
||||
**Begin**
|
||||
Current LC_MONETARY: en_US.UTF-8
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Currency symbol: $
|
||||
Thousands_sep: ,
|
||||
Amount formatted: $10,000.99
|
||||
Friday
|
||||
December
|
||||
3.14159
|
||||
**End**
|
||||
**Begin**
|
||||
Current LC_MONETARY: en_US.UTF-8
|
||||
Current LC_CTYPE: en_US.UTF-8
|
||||
Setting LC_ALL: de_DE.UTF-8
|
||||
Currency symbol: €
|
||||
Thousands_sep: .
|
||||
Amount formatted: 10.000,99 €
|
||||
Freitag
|
||||
Dezember
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
// This test is invoked by srv_1063_locale_configs.phpt
|
||||
|
||||
function dropTable($conn, $tableName)
|
||||
{
|
||||
|
@ -12,44 +13,85 @@ function fatalError($message)
|
|||
die($message);
|
||||
}
|
||||
|
||||
function printMoney($amt)
|
||||
function printMoney($amt, $info)
|
||||
{
|
||||
// The money_format() function is deprecated in PHP 7.4, so use intl NumberFormatter
|
||||
$info = localeconv();
|
||||
echo "Currency symbol: " . $info['currency_symbol'] . PHP_EOL;
|
||||
echo "Thousands_sep: " . $info['thousands_sep'] . PHP_EOL;
|
||||
|
||||
$loc = setlocale(LC_MONETARY, 0);
|
||||
$symbol = $info['int_curr_symbol'];
|
||||
|
||||
echo "Amount formatted: ";
|
||||
if (empty($symbol)) {
|
||||
echo number_format($amt, 2, '.', '');
|
||||
echo number_format($amt, 2, '.', '') . PHP_EOL;
|
||||
} else {
|
||||
$fmt = new NumberFormatter($loc, NumberFormatter::CURRENCY);
|
||||
$fmt->setTextAttribute(NumberFormatter::CURRENCY_CODE, $symbol);
|
||||
$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);
|
||||
echo $fmt->format($amt);
|
||||
echo $fmt->format($amt) . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
require_once('MsSetup.inc');
|
||||
|
||||
$setLocaleInfo = ($_SERVER['argv'][1]);
|
||||
$locale = ($_SERVER['argv'][2] ?? '');
|
||||
|
||||
echo "**Begin**" . PHP_EOL;
|
||||
|
||||
// Assuming LC_ALL is 'en_US.UTF-8', so is LC_CTYPE
|
||||
// But default LC_MONETARY varies
|
||||
$ctype = 'en_US.UTF-8';
|
||||
switch ($setLocaleInfo) {
|
||||
case 0:
|
||||
case 1:
|
||||
$m = 'C'; $symbol = ''; $sep = '';
|
||||
break;
|
||||
case 2:
|
||||
$m = 'en_US.UTF-8'; $symbol = '$'; $sep = ',';
|
||||
break;
|
||||
default:
|
||||
fatalError("Unexpected $setLocaleInfo\n");
|
||||
break;
|
||||
}
|
||||
|
||||
$m1 = setlocale(LC_MONETARY, 0);
|
||||
if ($m !== $m1) {
|
||||
echo "Unexpected LC_MONETARY: $m1" . PHP_EOL;
|
||||
}
|
||||
$c1 = setlocale(LC_CTYPE, 0);
|
||||
if ($ctype !== $c1) {
|
||||
echo "Unexpected LC_CTYPE: $c1" . PHP_EOL;
|
||||
}
|
||||
|
||||
// Set a different locale, if the input is not empty
|
||||
if (!empty($locale)) {
|
||||
$loc = setlocale(LC_ALL, $locale);
|
||||
if ($loc !== $locale) {
|
||||
echo "Unexpected $loc for LC_ALL " . PHP_EOL;
|
||||
}
|
||||
|
||||
// Currency symbol and thousands separator in Linux and macOS may be different
|
||||
if ($loc === 'de_DE.UTF-8') {
|
||||
$symbol = strtoupper(PHP_OS) === 'LINUX' ? '€' : 'Eu';
|
||||
$sep = strtoupper(PHP_OS) === 'LINUX' ? '.' : '';
|
||||
} else {
|
||||
$symbol = '$';
|
||||
$sep = ',';
|
||||
}
|
||||
}
|
||||
|
||||
$info = localeconv();
|
||||
|
||||
if ($symbol !== $info['currency_symbol']) {
|
||||
echo "$locale: Expected currency symbol '$symbol' but get '" . $info['currency_symbol'] . "'";
|
||||
echo PHP_EOL;
|
||||
}
|
||||
if ($sep !== $info['thousands_sep']) {
|
||||
echo "$locale: Expected thousands separator '$sep' but get '" . $info['currency_symbol'] . "'";
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
// This test is invoked by srv_1063_locale_configs.phpt
|
||||
require_once('MsSetup.inc');
|
||||
|
||||
$locale = ($_SERVER['argv'][1] ?? '');
|
||||
|
||||
echo "**Begin**" . PHP_EOL;
|
||||
echo "Current LC_MONETARY: " . setlocale(LC_MONETARY, 0) . PHP_EOL;
|
||||
echo "Current LC_CTYPE: " . setlocale(LC_CTYPE, 0) . PHP_EOL;
|
||||
|
||||
if (!empty($locale)) {
|
||||
$loc = setlocale(LC_ALL, $locale);
|
||||
echo "Setting LC_ALL: " . $loc . PHP_EOL;
|
||||
}
|
||||
|
||||
$n1 = 10000.98765;
|
||||
printMoney($n1);
|
||||
printMoney($n1, $info);
|
||||
|
||||
echo strftime("%A", strtotime("12/25/2020")) . PHP_EOL;
|
||||
echo strftime("%B", strtotime("12/25/2020")) . PHP_EOL;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
--TEST--
|
||||
streaming large amounts of data into a database and getting it out as a string exactly the same.
|
||||
--SKIPIF--
|
||||
<?
|
||||
require('skipif.inc');
|
||||
?>
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
Loading…
Reference in a new issue