summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/setlocale_error.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/strings/setlocale_error.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/strings/setlocale_error.phpt')
-rw-r--r--ext/standard/tests/strings/setlocale_error.phpt69
1 files changed, 69 insertions, 0 deletions
diff --git a/ext/standard/tests/strings/setlocale_error.phpt b/ext/standard/tests/strings/setlocale_error.phpt
new file mode 100644
index 0000000..e3f3765
--- /dev/null
+++ b/ext/standard/tests/strings/setlocale_error.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Test setlocale() function : error condition
+--INI--
+error_reporting=14335
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : string setlocale (int $category , string $locale [,string $..] )
+ : string setlocale(int $category , array $locale);
+ * Description: Sets locale information.Returns the new current locale , or FALSE if locale functinality is not implemented in this platform.
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing setlocale() : error conditions ***\n";
+
+// Zero argument
+echo "\n-- Testing setlocale() function with Zero arguments --";
+var_dump( setlocale());
+
+// One argument
+echo "\n-- Testing setlocale() function with One argument, 'category' = LC_ALL --";
+var_dump( setlocale(LC_ALL) );
+
+echo "\n-- Testing setlocale() function with invalid locale array, 'category' = LC_ALL --\n";
+//Invalid array of locales
+$invalid_locales = array("en_US.invalid", "en_AU.invalid", "ko_KR.invalid");
+var_dump( setlocale(LC_ALL,$invalid_locales) );
+
+echo "\n-- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL --\n";
+//Invalid array of locales
+var_dump( setlocale(LC_ALL,"en_US.invalid", "en_AU.invalid", "ko_KR.invalid") );
+
+echo "\n-- Testing setlocale() function with invalid category --\n";
+//invalid $category
+$invalid_category = "TEST";
+var_dump( setlocale($invalid_category,"en_US.utf8") );
+
+echo "\nDone";
+?>
+--EXPECTF--
+*** Testing setlocale() : error conditions ***
+
+-- Testing setlocale() function with Zero arguments --
+Warning: setlocale() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+-- Testing setlocale() function with One argument, 'category' = LC_ALL --
+Warning: setlocale() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+-- Testing setlocale() function with invalid locale array, 'category' = LC_ALL --
+bool(false)
+
+-- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL --
+bool(false)
+
+-- Testing setlocale() function with invalid category --
+
+Deprecated: setlocale(): Passing locale category name as string is deprecated. Use the LC_* -constants instead in %s on line %d
+
+Warning: setlocale(): Invalid locale category name TEST, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME in %s on line %d
+bool(false)
+
+Done