1--TEST--
2Test setlocale() function : error condition
3--INI--
4error_reporting=14335
5--SKIPIF--
6<?php
7if (substr(PHP_OS, 0, 3) == 'WIN') {
8    die('skip Not valid for windows');
9}
10?>
11--FILE--
12<?php
13/* Prototype  : string setlocale (int $category , string $locale [,string $..] )
14              : string setlocale(int $category , array $locale);
15 * Description: Sets locale information.Returns the new current locale , or FALSE if locale functionality is not implemented in this platform.
16 * Source code: ext/standard/string.c
17*/
18
19echo "*** Testing setlocale() : error conditions ***\n";
20
21// Zero argument
22echo "\n-- Testing setlocale() function with Zero arguments --";
23var_dump( setlocale());
24
25// One argument
26echo "\n-- Testing setlocale() function with One argument, 'category' = LC_ALL --";
27var_dump( setlocale(LC_ALL) );
28
29echo "\n-- Testing setlocale() function with invalid locale array, 'category' = LC_ALL --\n";
30//Invalid array of locales
31$invalid_locales = array("en_US.invalid", "en_AU.invalid", "ko_KR.invalid");
32var_dump( setlocale(LC_ALL,$invalid_locales) );
33
34echo "\n-- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL --\n";
35//Invalid array of locales
36var_dump( setlocale(LC_ALL,"en_US.invalid", "en_AU.invalid", "ko_KR.invalid") );
37
38echo "\n-- Testing setlocale() function with invalid category --\n";
39//invalid $category
40$invalid_category = "TEST";
41var_dump( setlocale($invalid_category,"en_US.utf8") );
42
43echo "\n-- Testing setlocale() function with locale name too long, 'category' = LC_ALL --";
44//Invalid locale - locale name too long
45var_dump(setlocale(LC_ALL,str_pad('',255,'A')));
46
47echo "\nDone";
48?>
49--EXPECTF--
50*** Testing setlocale() : error conditions ***
51
52-- Testing setlocale() function with Zero arguments --
53Warning: setlocale() expects at least 2 parameters, 0 given in %s on line %d
54NULL
55
56-- Testing setlocale() function with One argument, 'category' = LC_ALL --
57Warning: setlocale() expects at least 2 parameters, 1 given in %s on line %d
58NULL
59
60-- Testing setlocale() function with invalid locale array, 'category' = LC_ALL --
61bool(false)
62
63-- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL --
64bool(false)
65
66-- Testing setlocale() function with invalid category --
67
68Deprecated: setlocale(): Passing locale category name as string is deprecated. Use the LC_* -constants instead in %s on line %d
69
70Warning: 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
71bool(false)
72
73-- Testing setlocale() function with locale name too long, 'category' = LC_ALL --
74Warning: setlocale(): Specified locale name is too long in %s on line %d
75bool(false)
76
77Done
78