]> granicus.if.org Git - php/commitdiff
MFB: fixed tests. money_format() is implemented in underlying system, not in php...
authorAlexey Zakhlestin <indeyets@php.net>
Fri, 17 Jul 2009 16:21:00 +0000 (16:21 +0000)
committerAlexey Zakhlestin <indeyets@php.net>
Fri, 17 Jul 2009 16:21:00 +0000 (16:21 +0000)
ext/standard/tests/strings/money_format_basic1.phpt
ext/standard/tests/strings/money_format_basic2.phpt [deleted file]
ext/standard/tests/strings/money_format_basic3.phpt [deleted file]
ext/standard/tests/strings/money_format_error.phpt
ext/standard/tests/strings/money_format_variation1.phpt
ext/standard/tests/strings/money_format_variation2.phpt

index f46315196b269cd7831410ffcafddc7fc75b71d0..61070eff8316c434bbd3f143826f62069294affb 100644 (file)
@@ -1,14 +1,10 @@
 --TEST--
-Test money_format() function : basic functionality using national currency symbols
+Test money_format() function : basic functionality
 --SKIPIF--
 <?php
-       if (!function_exists('money_format') || !function_exists('setlocale')) {
+       if (!function_exists('money_format')) {
                die("SKIP money_format - not supported\n");
        }
-       
-       if (setlocale(LC_MONETARY, 'en_US') == false) {
-               die("SKIP en_US locale not available\n");
-       }       
 ?>
 --FILE--
 <?php
@@ -17,9 +13,11 @@ Test money_format() function : basic functionality using national currency symbo
  * Source code: ext/standard/string.c
 */
 
-echo "*** Testing money_format() : basic functionality using national currency symbols***\n";
+// ===========================================================================================
+// = We do not test for exact return-values, as those might be different between OS-versions =
+// ===========================================================================================
 
-$original = setlocale(LC_MONETARY, 'en_US');
+echo "*** Testing money_format() : basic functionality***\n";
 
 $value = 1234.5678;
 $negative_value = -1234.5678;
@@ -28,60 +26,54 @@ $negative_value = -1234.5678;
 // left precision, 2 of right precision using national 
 // format for en_US
 echo "Format values with 14 positions, 8 digits to left, 2 to right using national format\n";
-var_dump( money_format('%14#8.2n', $value));
-var_dump( money_format('%14#8.2n', $negative_value));
+echo gettype(money_format('%14#8.2n', $value))."\n";
+echo gettype(money_format('%14#8.2n', $negative_value))."\n";
 
 // Same again but use '(' for negative values 
 echo "Format again but with ( for negative values\n";
-var_dump( money_format('%(14#8.2n', $value));
-var_dump( money_format('%(14#8.2n', $negative_value));
+echo gettype(money_format('%(14#8.2n', $value))."\n";
+echo gettype(money_format('%(14#8.2n', $negative_value))."\n";
 
 // Same again but use a '0' for padding character
 echo "Format with 0 for padding character\n";
-var_dump( money_format('%=014#8.2n', $value));
-var_dump( money_format('%=014#8.2n', $negative_value));
+echo gettype(money_format('%=014#8.2n', $value))."\n";
+echo gettype(money_format('%=014#8.2n', $negative_value))."\n";
 
 // Same again but use a '*' for padding character
 echo "Format again with * for padding character\n";
-var_dump( money_format('%=*14#8.2n', $value));
-var_dump( money_format('%=*14#8.2n', $negative_value));
+echo gettype(money_format('%=*14#8.2n', $value))."\n";
+echo gettype(money_format('%=*14#8.2n', $negative_value))."\n";
 
 // Same again but disable grouping character
 echo "Format again but disable grouping character\n"; 
-var_dump( money_format('%=*^14#8.2n', $value));
-var_dump( money_format('%=*^14#8.2n', $negative_value));
+echo gettype(money_format('%=*^14#8.2n', $value))."\n";
+echo gettype(money_format('%=*^14#8.2n', $negative_value))."\n";
 
 // Same again but suppress currency symbol
 echo "Format again suppress currency symbol\n"; 
-var_dump( money_format('%=*!14#8.2n', $value));
-var_dump( money_format('%=*!14#8.2n', $negative_value));
-
-setlocale(LC_MONETARY, $original);
+echo gettype(money_format('%=*!14#8.2n', $value))."\n";
+echo gettype(money_format('%=*!14#8.2n', $negative_value))."\n";
 
 ?>
 ===DONE===
 --EXPECTF--
-*** Testing money_format() : basic functionality using national currency symbols***
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
+*** Testing money_format() : basic functionality***
 Format values with 14 positions, 8 digits to left, 2 to right using national format
-unicode(15) " $     1,234.57"
-unicode(15) "-$     1,234.57"
+unicode
+unicode
 Format again but with ( for negative values
-unicode(15) " $     1,234.57"
-unicode(16) "($     1,234.57)"
+unicode
+unicode
 Format with 0 for padding character
-unicode(15) " $000001,234.57"
-unicode(15) "-$000001,234.57"
+unicode
+unicode
 Format again with * for padding character
-unicode(15) " $*****1,234.57"
-unicode(15) "-$*****1,234.57"
+unicode
+unicode
 Format again but disable grouping character
-unicode(14) "  $****1234.57"
-unicode(14) " -$****1234.57"
+unicode
+unicode
 Format again suppress currency symbol
-unicode(14) " *****1,234.57"
-unicode(14) "-*****1,234.57"
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
+unicode
+unicode
 ===DONE===
diff --git a/ext/standard/tests/strings/money_format_basic2.phpt b/ext/standard/tests/strings/money_format_basic2.phpt
deleted file mode 100644 (file)
index 83603a1..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Test money_format() function : basic functionality using international currency symbols
---SKIPIF--
-<?php
-       if (!function_exists('money_format') || !function_exists('setlocale')) {
-               die("SKIP money_format - not supported\n");
-       }
-       
-       if (setlocale(LC_MONETARY, 'en_US') == false) {
-               die("SKIP en_US locale not available\n");
-       }       
-?>
---FILE--
-<?php
-/* Prototype  : string money_format  ( string $format  , float $number  )
- * Description: Formats a number as a currency string
- * Source code: ext/standard/string.c
-*/
-
-echo "*** Testing money_format() : basic functionality using international currency symbols***\n";
-
-$original = setlocale(LC_MONETARY, 'en_US');
-
-$value = 1234.5678;
-$negative_value = -1234.5678;
-
-// Format with 14 positions of width, 8 digits of
-// left precision, 2 of right precision using national 
-// format for en_US
-echo "Format with 14 positions, 8 digits to left, 2 to right using national format\n";
-var_dump( money_format('%14#8.2i', $value));
-var_dump( money_format('%14#8.2i', $negative_value));
-
-// Same again but use '(' for negative values 
-echo "Format with ( for negative values\n";
-var_dump( money_format('%(14#8.2i', $value));
-var_dump( money_format('%(14#8.2i', $negative_value));
-
-// Same again but use a '0' for padding character
-echo "Format with 0 for padding character\n";
-var_dump( money_format('%=014#8.2i', $value));
-var_dump( money_format('%=014#8.2i', $negative_value));
-
-// Same again but use a '*' for padding character
-echo "Format with * for padding character\n";
-var_dump( money_format('%=*14#8.2i', $value));
-var_dump( money_format('%=*14#8.2i', $negative_value));
-
-// Same again but disable grouping character
-echo "Format again but disable grouping character\n"; 
-var_dump( money_format('%=*^14#8.2i', $value));
-var_dump( money_format('%=*^14#8.2i', $negative_value));
-
-// Same again but suppress currency symbol
-echo "Format again but suppress currency symbol\n"; 
-var_dump( money_format('%=*!14#8.2i', $value));
-var_dump( money_format('%=*!14#8.2i', $negative_value));
-
-setlocale(LC_MONETARY, $original);
-
-?>
-===DONE===
---EXPECTF--
-*** Testing money_format() : basic functionality using international currency symbols***
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
-Format with 14 positions, 8 digits to left, 2 to right using national format
-unicode(18) " USD      1,234.57"
-unicode(18) "-USD      1,234.57"
-Format with ( for negative values
-unicode(18) " USD      1,234.57"
-unicode(19) "(USD      1,234.57)"
-Format with 0 for padding character
-unicode(18) " USD 000001,234.57"
-unicode(18) "-USD 000001,234.57"
-Format with * for padding character
-unicode(18) " USD *****1,234.57"
-unicode(18) "-USD *****1,234.57"
-Format again but disable grouping character
-unicode(16) " USD ****1234.57"
-unicode(16) "-USD ****1234.57"
-Format again but suppress currency symbol
-unicode(14) " *****1,234.57"
-unicode(14) "-*****1,234.57"
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
-===DONE===
diff --git a/ext/standard/tests/strings/money_format_basic3.phpt b/ext/standard/tests/strings/money_format_basic3.phpt
deleted file mode 100644 (file)
index 54ee7c0..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Test money_format() function : basic functionality using national currency symbols and de_DE locale
---SKIPIF--
-<?php
-       if (!function_exists('money_format') || !function_exists('setlocale')) {
-               die("SKIP money_format - not supported\n");
-       }
-       
-       if (setlocale(LC_MONETARY, 'de_DE') == false) {
-               die("SKIP de_DE locale not available\n");
-       }       
-?>
---FILE--
-<?php
-/* Prototype  : string money_format  ( string $format  , float $number  )
- * Description: Formats a number as a currency string
- * Source code: ext/standard/string.c
-*/
-
-echo "*** Testing money_format() : basic functionality using national currency symbols and de_DE locale***\n";
-
-$original = setlocale(LC_MONETARY, 'de_DE');
-
-$value = 1234.5678;
-$negative_value = -1234.5678;
-
-// Format with 14 positions of width, 8 digits of
-// left precision, 2 of right precision using national 
-// format for en_US
-echo "Format values with 14 positions, 8 digits to left, 2 to right using national format\n";
-var_dump( money_format('%14#8.2n', $value));
-var_dump( money_format('%14#8.2n', $negative_value));
-
-// Same again but use '(' for negative values 
-echo "Format again but with ( for negative values\n";
-var_dump( money_format('%(14#8.2n', $value));
-var_dump( money_format('%(14#8.2n', $negative_value));
-
-// Same again but use a '0' for padding character
-echo "Format with 0 for padding character\n";
-var_dump( money_format('%=014#8.2n', $value));
-var_dump( money_format('%=014#8.2n', $negative_value));
-
-// Same again but use a '*' for padding character
-echo "Format again with * for padding character\n";
-var_dump( money_format('%=*14#8.2n', $value));
-var_dump( money_format('%=*14#8.2n', $negative_value));
-
-// Same again but disable grouping character
-echo "Format again but disable grouping character\n"; 
-var_dump( money_format('%=*^14#8.2n', $value));
-var_dump( money_format('%=*^14#8.2n', $negative_value));
-
-// Same again but suppress currency symbol
-echo "Format again suppress currency symbol\n"; 
-var_dump( money_format('%=*!14#8.2n', $value));
-var_dump( money_format('%=*!14#8.2n', $negative_value));
-
-setlocale(LC_MONETARY, $original);
-
-?>
-===DONE===
---EXPECTF--
-*** Testing money_format() : basic functionality using national currency symbols and de_DE locale***
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
-Format values with 14 positions, 8 digits to left, 2 to right using national format
-unicode(18) "      1.234,57 EUR"
-unicode(18) "-     1.234,57 EUR"
-Format again but with ( for negative values
-unicode(18) "      1.234,57 EUR"
-unicode(19) "(     1.234,57 EUR)"
-Format with 0 for padding character
-unicode(18) " 000001.234,57 EUR"
-unicode(18) "-000001.234,57 EUR"
-Format again with * for padding character
-unicode(18) " *****1.234,57 EUR"
-unicode(18) "-*****1.234,57 EUR"
-Format again but disable grouping character
-unicode(16) " ****1234,57 EUR"
-unicode(16) "-****1234,57 EUR"
-Format again suppress currency symbol
-unicode(14) " *****1.234,57"
-unicode(14) "-*****1.234,57"
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
-===DONE===
\ No newline at end of file
index fac89d1b55301db14cad2c6bdee32a49ed83aa9c..cf110b43ab59804abcf413227fc7939343311839 100644 (file)
@@ -13,6 +13,10 @@ Test money_format() function : error conditions
  * Source code: ext/standard/string.c
 */
 
+// ===========================================================================================
+// = We do not test for exact return-values, as those might be different between OS-versions =
+// ===========================================================================================
+
 $string = '%14#8.2n';
 $value = 1234.56;
 $extra_arg = 10;
index ec3f583a1b829d4452d1d9a330dd428ac3f1c235..eaf05ef9cf9e89dc8a713802a17b5418e27a54d4 100644 (file)
@@ -2,13 +2,9 @@
 Test money_format() function :  usage variations - test values for $format argument
 --SKIPIF--
 <?php
-       if (!function_exists('money_format') || !function_exists('setlocale')) {
+       if (!function_exists('money_format')) {
                die("SKIP money_format - not supported\n");
        }
-       
-       if (setlocale(LC_MONETARY, 'de_DE') == false) {
-               die("SKIP de_DE locale not available\n");
-       }       
 ?>
 --FILE--
 <?php
@@ -17,8 +13,9 @@ Test money_format() function :  usage variations - test values for $format argum
  * Source code: ext/standard/string.c
 */
 
-$original = setlocale(LC_MONETARY, 'en_US');
-
+// ===========================================================================================
+// = We do not test for exact return-values, as those might be different between OS-versions =
+// ===========================================================================================
 
 echo "*** Testing money_format() function: with unexpected inputs for 'format' argument ***\n";
 
@@ -97,39 +94,34 @@ $value = 1234.56;
 
 foreach($formats as $format) {
   echo "-- Iteration $count --\n";
-  var_dump( money_format($format, $value) );
+  echo gettype( money_format($format, $value) )."\n";
   $count ++;
 }
 
 // close the file handle
 fclose($file_handle);  
-
-// restore original locale
-setlocale(LC_MONETARY, $original);
-
 ?>
 ===DONE===
 --EXPECTF--
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
 *** Testing money_format() function: with unexpected inputs for 'format' argument ***
 -- Iteration 1 --
-unicode(1) "0"
+unicode
 -- Iteration 2 --
-unicode(1) "1"
+unicode
 -- Iteration 3 --
-unicode(3) "255"
+unicode
 -- Iteration 4 --
-unicode(3) "256"
+unicode
 -- Iteration 5 --
-unicode(10) "2147483647"
+unicode
 -- Iteration 6 --
-unicode(11) "-2147483648"
+unicode
 -- Iteration 7 --
-unicode(3) "0.5"
+unicode
 -- Iteration 8 --
-unicode(5) "-20.5"
+unicode
 -- Iteration 9 --
-unicode(12) "101234567000"
+unicode
 -- Iteration 10 --
 
 Warning: money_format() expects parameter 1 to be binary string, array given in %s on line %d
@@ -143,39 +135,37 @@ NULL
 Warning: money_format() expects parameter 1 to be binary string, array given in %s on line %d
 NULL
 -- Iteration 13 --
-unicode(1) "1"
+unicode
 -- Iteration 14 --
-unicode(0) ""
+unicode
 -- Iteration 15 --
-unicode(1) "1"
+unicode
 -- Iteration 16 --
-unicode(0) ""
+unicode
 -- Iteration 17 --
-unicode(0) ""
+unicode
 -- Iteration 18 --
-unicode(0) ""
+unicode
 -- Iteration 19 --
-unicode(4) "abcd"
+unicode
 -- Iteration 20 --
-unicode(4) "abcd"
+unicode
 -- Iteration 21 --
-unicode(5) "0x12f"
+unicode
 -- Iteration 22 --
-unicode(18) " *****1,234.56abcd"
+unicode
 -- Iteration 23 --
 
 Warning: money_format() expects parameter 1 to be binary string, object given in %s on line %d
 NULL
 -- Iteration 24 --
-unicode(17) "  sample object  "
+unicode
 -- Iteration 25 --
 
 Warning: money_format() expects parameter 1 to be binary string, resource given in %s on line %d
 NULL
 -- Iteration 26 --
-unicode(0) ""
+unicode
 -- Iteration 27 --
-unicode(0) ""
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
+unicode
 ===DONE===
\ No newline at end of file
index a1a2d292caefc785ea92973e01a87697a7db724f..fc928ab98f7f317abc0f02f169c391200074b29c 100644 (file)
@@ -2,13 +2,9 @@
 Test money_format() function :  usage variations - test values for $number argument
 --SKIPIF--
 <?php
-       if (!function_exists('money_format') || !function_exists('setlocale')) {
+       if (!function_exists('money_format')) {
                die("SKIP money_format - not supported\n");
        }
-       
-       if (setlocale(LC_MONETARY, 'de_DE') == false) {
-               die("SKIP de_DE locale not available\n");
-       }       
 ?>
 --FILE--
 <?php
@@ -17,8 +13,9 @@ Test money_format() function :  usage variations - test values for $number argum
  * Source code: ext/standard/string.c
 */
 
-$original = setlocale(LC_MONETARY, 'en_US');
-
+// ===========================================================================================
+// = We do not test for exact return-values, as those might be different between OS-versions =
+// ===========================================================================================
 
 echo "*** Testing money_format() function: with unexpected inputs for 'number' argument ***\n";
 
@@ -97,39 +94,34 @@ $format = '%14#8.2i';
 
 foreach($numbers as $number) {
   echo "-- Iteration $count --\n";
-  var_dump( money_format($format, $number) );
+  echo gettype( money_format($format, $number) )."\n";
   $count ++;
 }
 
 // close the file handle
 fclose($file_handle);  
-
-// restore original locale
-setlocale(LC_MONETARY, $original);
-
 ?>
 ===DONE===
 --EXPECTF--
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
 *** Testing money_format() function: with unexpected inputs for 'number' argument ***
 -- Iteration 1 --
-unicode(18) " USD          0.00"
+unicode
 -- Iteration 2 --
-unicode(18) " USD          1.00"
+unicode
 -- Iteration 3 --
-unicode(18) " USD        255.00"
+unicode
 -- Iteration 4 --
-unicode(18) " USD        256.00"
+unicode
 -- Iteration 5 --
-unicode(21) " USD 2,147,483,647.00"
+unicode
 -- Iteration 6 --
-unicode(21) "-USD 2,147,483,648.00"
+unicode
 -- Iteration 7 --
-unicode(18) " USD         10.50"
+unicode
 -- Iteration 8 --
-unicode(18) "-USD         20.50"
+unicode
 -- Iteration 9 --
-unicode(23) " USD 101,234,567,000.00"
+unicode
 -- Iteration 10 --
 
 Warning: money_format() expects parameter 2 to be double, array given in %s on line %d
@@ -143,17 +135,17 @@ NULL
 Warning: money_format() expects parameter 2 to be double, array given in %s on line %d
 NULL
 -- Iteration 13 --
-unicode(18) " USD          1.00"
+unicode
 -- Iteration 14 --
-unicode(18) " USD          0.00"
+unicode
 -- Iteration 15 --
-unicode(18) " USD          1.00"
+unicode
 -- Iteration 16 --
-unicode(18) " USD          0.00"
+unicode
 -- Iteration 17 --
-unicode(18) " USD          0.00"
+unicode
 -- Iteration 18 --
-unicode(18) " USD          0.00"
+unicode
 -- Iteration 19 --
 
 Warning: money_format() expects parameter 2 to be double, Unicode string given in %s on line %d
@@ -163,7 +155,7 @@ NULL
 Warning: money_format() expects parameter 2 to be double, Unicode string given in %s on line %d
 NULL
 -- Iteration 21 --
-unicode(18) " USD        303.00"
+unicode
 -- Iteration 22 --
 
 Warning: money_format() expects parameter 2 to be double, Unicode string given in %s on line %d
@@ -181,9 +173,7 @@ NULL
 Warning: money_format() expects parameter 2 to be double, resource given in %s on line %d
 NULL
 -- Iteration 26 --
-unicode(18) " USD          0.00"
+unicode
 -- Iteration 27 --
-unicode(18) " USD          0.00"
-
-Deprecated: setlocale(): deprecated in Unicode mode, please use ICU locale functions in %s on line %d
+unicode
 ===DONE===
\ No newline at end of file