1--TEST--
2Test setlocale() function : error condition
3--INI--
4error_reporting=E_ALL
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 locale name too long, 'category' = LC_ALL --";
39//Invalid locale - locale name too long
40var_dump(setlocale(LC_ALL,str_pad('',255,'A')));
41
42echo "\nDone";
43?>
44--EXPECTF--
45*** Testing setlocale() : error conditions ***
46
47-- Testing setlocale() function with Zero arguments --
48Warning: setlocale() expects at least 2 parameters, 0 given in %s on line %d
49NULL
50
51-- Testing setlocale() function with One argument, 'category' = LC_ALL --
52Warning: setlocale() expects at least 2 parameters, 1 given in %s on line %d
53NULL
54
55-- Testing setlocale() function with invalid locale array, 'category' = LC_ALL --
56bool(false)
57
58-- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL --
59bool(false)
60
61-- Testing setlocale() function with locale name too long, 'category' = LC_ALL --
62Warning: setlocale(): Specified locale name is too long in %s on line %d
63bool(false)
64
65Done
66