22Test money_format() function : basic functionality using national currency symbols
33--SKIPIF--
44<?php
5- if (!function_exists ('money_format ' ) || ! function_exists ( ' setlocale ' ) ) {
5+ if (!function_exists ('money_format ' )) {
66die ("SKIP money_format - not supported \n" );
77}
8-
9- if (setlocale (LC_MONETARY , 'en_US ' ) == false ) {
10- die ("SKIP en_US locale not available \n" );
11- }
128?>
139--FILE--
1410<?php
@@ -17,9 +13,11 @@ Test money_format() function : basic functionality using national currency symbo
1713 * Source code: ext/standard/string.c
1814*/
1915
20- echo "*** Testing money_format() : basic functionality using national currency symbols*** \n" ;
16+ // ===========================================================================================
17+ // = We do not test for exact return-values, as those might be different between OS-versions =
18+ // ===========================================================================================
2119
22- $ original = setlocale ( LC_MONETARY , ' en_US ' ) ;
20+ echo " *** Testing money_format() : basic functionality*** \n" ;
2321
2422$ value = 1234.5678 ;
2523$ negative_value = -1234.5678 ;
@@ -28,57 +26,55 @@ $negative_value = -1234.5678;
2826// left precision, 2 of right precision using national
2927// format for en_US
3028echo "Format values with 14 positions, 8 digits to left, 2 to right using national format \n" ;
31- var_dump ( money_format ('%14#8.2n ' , $ value ));
32- var_dump ( money_format ('%14#8.2n ' , $ negative_value ));
29+ echo gettype ( money_format ('%14#8.2n ' , $ value )). "\n" ;
30+ echo gettype ( money_format ('%14#8.2n ' , $ negative_value )). "\n" ;
3331
3432// Same again but use '(' for negative values
3533echo "Format again but with ( for negative values \n" ;
36- var_dump ( money_format ('%(14#8.2n ' , $ value ));
37- var_dump ( money_format ('%(14#8.2n ' , $ negative_value ));
34+ echo gettype ( money_format ('%(14#8.2n ' , $ value )). "\n" ;
35+ echo gettype ( money_format ('%(14#8.2n ' , $ negative_value )). "\n" ;
3836
3937// Same again but use a '0' for padding character
4038echo "Format with 0 for padding character \n" ;
41- var_dump ( money_format ('%=014#8.2n ' , $ value ));
42- var_dump ( money_format ('%=014#8.2n ' , $ negative_value ));
39+ echo gettype ( money_format ('%=014#8.2n ' , $ value )). "\n" ;
40+ echo gettype ( money_format ('%=014#8.2n ' , $ negative_value )). "\n" ;
4341
4442// Same again but use a '*' for padding character
4543echo "Format again with * for padding character \n" ;
46- var_dump ( money_format ('%=*14#8.2n ' , $ value ));
47- var_dump ( money_format ('%=*14#8.2n ' , $ negative_value ));
44+ echo gettype ( money_format ('%=*14#8.2n ' , $ value )). "\n" ;
45+ echo gettype ( money_format ('%=*14#8.2n ' , $ negative_value )). "\n" ;
4846
4947// Same again but disable grouping character
5048echo "Format again but disable grouping character \n" ;
51- var_dump ( money_format ('%=*^14#8.2n ' , $ value ));
52- var_dump ( money_format ('%=*^14#8.2n ' , $ negative_value ));
49+ echo gettype ( money_format ('%=*^14#8.2n ' , $ value )). "\n" ;
50+ echo gettype ( money_format ('%=*^14#8.2n ' , $ negative_value )). "\n" ;
5351
5452// Same again but suppress currency symbol
5553echo "Format again suppress currency symbol \n" ;
56- var_dump ( money_format ('%=*!14#8.2n ' , $ value ));
57- var_dump ( money_format ('%=*!14#8.2n ' , $ negative_value ));
58-
59- setlocale (LC_MONETARY , $ original );
54+ echo gettype (money_format ('%=*!14#8.2n ' , $ value ))."\n" ;
55+ echo gettype (money_format ('%=*!14#8.2n ' , $ negative_value ))."\n" ;
6056
6157?>
6258===DONE===
6359--EXPECT--
64- *** Testing money_format() : basic functionality using national currency symbols ***
60+ *** Testing money_format() : basic functionality***
6561Format values with 14 positions, 8 digits to left, 2 to right using national format
66- string(15) " $ 1,234.57"
67- string(15) "-$ 1,234.57"
62+ string
63+ string
6864Format again but with ( for negative values
69- string(15) " $ 1,234.57"
70- string(16) "($ 1,234.57)"
65+ string
66+ string
7167Format with 0 for padding character
72- string(15) " $000001,234.57"
73- string(15) "-$000001,234.57"
68+ string
69+ string
7470Format again with * for padding character
75- string(15) " $*****1,234.57"
76- string(15) "-$*****1,234.57"
71+ string
72+ string
7773Format again but disable grouping character
78- string(14) " $****1234.57"
79- string(14) " -$****1234.57"
74+ string
75+ string
8076Format again suppress currency symbol
81- string(14) " *****1,234.57"
82- string(14) "-*****1,234.57"
77+ string
78+ string
8379===DONE===
8480
0 commit comments