setlocale_variation3.phpt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. --TEST--
  2. Test setlocale() function : usage variations - setting system locale = 0
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die('skip Not valid for windows');
  7. }
  8. if (setlocale(LC_ALL,'en_US.utf8') === false) {
  9. die('skip en_US.utf8 locale not available');
  10. }
  11. ?>
  12. --FILE--
  13. <?php
  14. /* If locale is "0", the locale setting is not affected, only the current setting is returned */
  15. echo "*** Testing setlocale() : usage variations - setting system locale = 0 ***\n";
  16. $locale_info_before = array();
  17. $locale_info_after = array();
  18. //initially giving the locale
  19. setlocale(LC_ALL,"en_US.utf8");
  20. echo "Locale info, before setting the locale\n";
  21. //returns current locale,before executing setlocale().
  22. $locale_info_before = localeconv();
  23. var_dump($locale_info_before);
  24. //Testing setlocale() by giving locale = 0
  25. echo "Setting system locale, category = LC_ALL and locale = 0\n";
  26. setlocale(LC_ALL, 0);
  27. echo "Locale info, after setting the locale\n";
  28. //returns current locale,after executing setlocale().
  29. $locale_info_after = localeconv();
  30. var_dump($locale_info_after);
  31. echo "Checking locale in the system, Expected : no change in the existing locale\n";
  32. echo "Test ";
  33. if($locale_info_before == $locale_info_after){
  34. echo "PASSED.";
  35. } else {
  36. echo "FAILED.";
  37. }
  38. echo "\nDone\n";
  39. ?>
  40. --EXPECT--
  41. *** Testing setlocale() : usage variations - setting system locale = 0 ***
  42. Locale info, before setting the locale
  43. array(18) {
  44. ["decimal_point"]=>
  45. string(1) "."
  46. ["thousands_sep"]=>
  47. string(1) ","
  48. ["int_curr_symbol"]=>
  49. string(4) "USD "
  50. ["currency_symbol"]=>
  51. string(1) "$"
  52. ["mon_decimal_point"]=>
  53. string(1) "."
  54. ["mon_thousands_sep"]=>
  55. string(1) ","
  56. ["positive_sign"]=>
  57. string(0) ""
  58. ["negative_sign"]=>
  59. string(1) "-"
  60. ["int_frac_digits"]=>
  61. int(2)
  62. ["frac_digits"]=>
  63. int(2)
  64. ["p_cs_precedes"]=>
  65. int(1)
  66. ["p_sep_by_space"]=>
  67. int(0)
  68. ["n_cs_precedes"]=>
  69. int(1)
  70. ["n_sep_by_space"]=>
  71. int(0)
  72. ["p_sign_posn"]=>
  73. int(1)
  74. ["n_sign_posn"]=>
  75. int(1)
  76. ["grouping"]=>
  77. array(2) {
  78. [0]=>
  79. int(3)
  80. [1]=>
  81. int(3)
  82. }
  83. ["mon_grouping"]=>
  84. array(2) {
  85. [0]=>
  86. int(3)
  87. [1]=>
  88. int(3)
  89. }
  90. }
  91. Setting system locale, category = LC_ALL and locale = 0
  92. Locale info, after setting the locale
  93. array(18) {
  94. ["decimal_point"]=>
  95. string(1) "."
  96. ["thousands_sep"]=>
  97. string(1) ","
  98. ["int_curr_symbol"]=>
  99. string(4) "USD "
  100. ["currency_symbol"]=>
  101. string(1) "$"
  102. ["mon_decimal_point"]=>
  103. string(1) "."
  104. ["mon_thousands_sep"]=>
  105. string(1) ","
  106. ["positive_sign"]=>
  107. string(0) ""
  108. ["negative_sign"]=>
  109. string(1) "-"
  110. ["int_frac_digits"]=>
  111. int(2)
  112. ["frac_digits"]=>
  113. int(2)
  114. ["p_cs_precedes"]=>
  115. int(1)
  116. ["p_sep_by_space"]=>
  117. int(0)
  118. ["n_cs_precedes"]=>
  119. int(1)
  120. ["n_sep_by_space"]=>
  121. int(0)
  122. ["p_sign_posn"]=>
  123. int(1)
  124. ["n_sign_posn"]=>
  125. int(1)
  126. ["grouping"]=>
  127. array(2) {
  128. [0]=>
  129. int(3)
  130. [1]=>
  131. int(3)
  132. }
  133. ["mon_grouping"]=>
  134. array(2) {
  135. [0]=>
  136. int(3)
  137. [1]=>
  138. int(3)
  139. }
  140. }
  141. Checking locale in the system, Expected : no change in the existing locale
  142. Test PASSED.
  143. Done