From f64df0497f2304cf2341a6c403377edf9576c9e6 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Mon, 6 Jan 2020 10:57:55 -0800 Subject: [PATCH] Fixed the skipif wordings and styles (#1070) --- Dockerfile-msphpsql | 1 + azure-pipelines.yml | 15 +++--- .../pdo_sqlsrv/pdo_1063_locale_configs.phpt | 8 +-- .../pdo_sqlsrv/pdo_1063_test_locale.php | 28 +++++++++-- test/functional/pdo_sqlsrv/skipif.inc | 6 +-- test/functional/pdo_sqlsrv/skipif_azure.inc | 12 ++--- .../pdo_sqlsrv/skipif_mid-refactor.inc | 34 ++++++------- test/functional/pdo_sqlsrv/skipif_not_akv.inc | 49 ++++++++++--------- test/functional/pdo_sqlsrv/skipif_unix.inc | 11 +++-- .../pdo_sqlsrv/skipif_unix_locales.inc | 13 +++-- .../pdo_sqlsrv/skipif_versions_old.inc | 21 ++++---- test/functional/sqlsrv/skipif_not_akv.inc | 48 +++++++++--------- test/functional/sqlsrv/skipif_unix.inc | 6 +-- .../functional/sqlsrv/skipif_unix_locales.inc | 9 ++-- .../functional/sqlsrv/skipif_versions_old.inc | 33 ++++++------- .../sqlsrv/srv_1063_locale_configs.phpt | 8 +-- .../sqlsrv/srv_1063_test_locale.php | 31 +++++++++--- 17 files changed, 185 insertions(+), 148 deletions(-) diff --git a/Dockerfile-msphpsql b/Dockerfile-msphpsql index 512d3cf54..31eba77a1 100644 --- a/Dockerfile-msphpsql +++ b/Dockerfile-msphpsql @@ -21,6 +21,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && \ make \ php7.3 \ php7.3-dev \ + php7.3-intl \ python-pip \ re2c \ unixodbc-dev \ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ef8f34b47..b4acecbf0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -59,6 +59,8 @@ jobs: displayName: 'Build and install drivers' - job: Linux + variables: + phpver: 7.3 pool: vmImage: 'ubuntu-18.04' steps: @@ -72,13 +74,13 @@ jobs: architecture: 'x64' - script: | - sudo update-alternatives --set php /usr/bin/php$(phpVersion) - sudo update-alternatives --set phar /usr/bin/phar$(phpVersion) - sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion) - sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion) - sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) + sudo update-alternatives --set php /usr/bin/php$(phpver) + sudo update-alternatives --set phar /usr/bin/phar$(phpver) + sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpver) + sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpver) + sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpver) php -version - displayName: 'Use PHP version $(phpVersion)' + displayName: 'Use PHP version $(phpver)' - script: | echo install ODBC and dependencies @@ -128,6 +130,7 @@ jobs: - script: | echo ready to build extensions + sudo apt-get install -y php$(phpver)-intl cd $(Build.SourcesDirectory)/source chmod a+x packagize.sh ./packagize.sh diff --git a/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt b/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt index 8d4fa73bf..8438cb7f4 100644 --- a/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt +++ b/test/functional/pdo_sqlsrv/pdo_1063_locale_configs.phpt @@ -46,7 +46,7 @@ Current LC_CTYPE: en_US.UTF-8 Setting LC_ALL: en_US.ISO-8859-1 Currency symbol: $ Thousands_sep: , -Amount formatted: USD 10,000.99 +Amount formatted: $10,000.99 Friday December 3.14159 @@ -71,7 +71,7 @@ Current LC_CTYPE: en_US.UTF-8 Setting LC_ALL: de_DE.UTF-8 Currency symbol: € Thousands_sep: . -Amount formatted: 10.000,99 EUR +Amount formatted: 10.000,99 € Freitag Dezember 3,14159 @@ -85,7 +85,7 @@ Current LC_MONETARY: en_US.UTF-8 Current LC_CTYPE: en_US.UTF-8 Currency symbol: $ Thousands_sep: , -Amount formatted: USD 10,000.99 +Amount formatted: $10,000.99 Friday December 3.14159 @@ -96,7 +96,7 @@ Current LC_CTYPE: en_US.UTF-8 Setting LC_ALL: de_DE.UTF-8 Currency symbol: € Thousands_sep: . -Amount formatted: 10.000,99 EUR +Amount formatted: 10.000,99 € Freitag Dezember 3,14159 diff --git a/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php b/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php index b789d0509..58be4d0dc 100644 --- a/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php +++ b/test/functional/pdo_sqlsrv/pdo_1063_test_locale.php @@ -6,6 +6,27 @@ function dropTable($conn, $tableName) $conn->exec($tsql); } +function printMoney($amt) +{ + // 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, '.', ''); + } else { + $fmt = new NumberFormatter($loc, NumberFormatter::CURRENCY); + $fmt->setTextAttribute(NumberFormatter::CURRENCY_CODE, $symbol); + $fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); + echo $fmt->format($amt); + } + echo PHP_EOL; +} // This test is invoked by pdo_1063_locale_configs.phpt require_once('MsSetup.inc'); @@ -21,12 +42,9 @@ function dropTable($conn, $tableName) echo "Setting LC_ALL: " . $loc . PHP_EOL; } -$info = localeconv(); -echo "Currency symbol: " . $info['currency_symbol'] . PHP_EOL; -echo "Thousands_sep: " . $info['thousands_sep'] . PHP_EOL; - $n1 = 10000.98765; -echo "Amount formatted: " . money_format("%i", $n1) . PHP_EOL; +printMoney($n1); + echo strftime("%A", strtotime("12/25/2020")) . PHP_EOL; echo strftime("%B", strtotime("12/25/2020")) . PHP_EOL; diff --git a/test/functional/pdo_sqlsrv/skipif.inc b/test/functional/pdo_sqlsrv/skipif.inc index bf4ac502b..ab29e6c59 100644 --- a/test/functional/pdo_sqlsrv/skipif.inc +++ b/test/functional/pdo_sqlsrv/skipif.inc @@ -1,4 +1,4 @@ +if (!extension_loaded("pdo_sqlsrv")) { + die("skip Extension not loaded"); +} diff --git a/test/functional/pdo_sqlsrv/skipif_azure.inc b/test/functional/pdo_sqlsrv/skipif_azure.inc index aec21ea56..e154005b6 100644 --- a/test/functional/pdo_sqlsrv/skipif_azure.inc +++ b/test/functional/pdo_sqlsrv/skipif_azure.inc @@ -1,8 +1,8 @@ +if ($daasMode) { + die("skip test not applicable in Azure\n"); +} diff --git a/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc b/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc index 5c1e87a05..a0c6032d3 100644 --- a/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc +++ b/test/functional/pdo_sqlsrv/skipif_mid-refactor.inc @@ -1,17 +1,17 @@ - \ No newline at end of file +if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv')) { + die("skip extension not loaded"); +} diff --git a/test/functional/pdo_sqlsrv/skipif_unix_locales.inc b/test/functional/pdo_sqlsrv/skipif_unix_locales.inc index 5bf6eac24..938307ba1 100644 --- a/test/functional/pdo_sqlsrv/skipif_unix_locales.inc +++ b/test/functional/pdo_sqlsrv/skipif_unix_locales.inc @@ -1,29 +1,28 @@ \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/skipif_versions_old.inc b/test/functional/pdo_sqlsrv/skipif_versions_old.inc index b6f0a5a42..00e3861d0 100644 --- a/test/functional/pdo_sqlsrv/skipif_versions_old.inc +++ b/test/functional/pdo_sqlsrv/skipif_versions_old.inc @@ -1,18 +1,15 @@ \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_not_akv.inc b/test/functional/sqlsrv/skipif_not_akv.inc index 42387d0a8..f7064bd3c 100644 --- a/test/functional/sqlsrv/skipif_not_akv.inc +++ b/test/functional/sqlsrv/skipif_not_akv.inc @@ -1,24 +1,24 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_unix_locales.inc b/test/functional/sqlsrv/skipif_unix_locales.inc index 5bf6eac24..dc44f973e 100644 --- a/test/functional/sqlsrv/skipif_unix_locales.inc +++ b/test/functional/sqlsrv/skipif_unix_locales.inc @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_versions_old.inc b/test/functional/sqlsrv/skipif_versions_old.inc index 2b9f8dedb..0dd04429d 100644 --- a/test/functional/sqlsrv/skipif_versions_old.inc +++ b/test/functional/sqlsrv/skipif_versions_old.inc @@ -1,17 +1,16 @@ - \ No newline at end of file +setTextAttribute(NumberFormatter::CURRENCY_CODE, $symbol); + $fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); + echo $fmt->format($amt); + } + echo PHP_EOL; +} + // This test is invoked by srv_1063_locale_configs.phpt require_once('MsSetup.inc'); @@ -26,12 +48,9 @@ function fatalError($message) echo "Setting LC_ALL: " . $loc . PHP_EOL; } -$info = localeconv(); -echo "Currency symbol: " . $info['currency_symbol'] . PHP_EOL; -echo "Thousands_sep: " . $info['thousands_sep'] . PHP_EOL; - $n1 = 10000.98765; -echo "Amount formatted: " . money_format("%i", $n1) . PHP_EOL; +printMoney($n1); + echo strftime("%A", strtotime("12/25/2020")) . PHP_EOL; echo strftime("%B", strtotime("12/25/2020")) . PHP_EOL; @@ -72,4 +91,4 @@ function fatalError($message) sqlsrv_close($conn); echo "**End**" . PHP_EOL; -?> \ No newline at end of file +?>