Speed up PMA_getImage()
[phpmyadmin/roccivic.git] / test / libraries / php-gettext / Locales_test.php
blobb0a290d2a9fddc883e9fd616077e1a1c51d6121a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for gettext locales.
6 * @package PhpMyAdmin-test
7 */
8 require_once('libraries/php-gettext/gettext.inc');
10 class LocaleTest extends PHPUnit_Framework_TestCase
13 public function test_setlocale_system()
15 putenv("LC_ALL=");
16 // For an existing locale, it never needs emulation.
17 putenv("LANG=C");
18 _setlocale(LC_MESSAGES, "");
19 $this->assertEquals(0, locale_emulation());
22 public function test_setlocale_emulation()
24 putenv("LC_ALL=");
25 // If we set it to a non-existent locale, it still works, but uses
26 // emulation.
27 _setlocale(LC_MESSAGES, "xxx_XXX");
28 $this->assertEquals('xxx_XXX', _setlocale(LC_MESSAGES, 0));
29 $this->assertEquals(1, locale_emulation());
32 public function test_get_list_of_locales()
34 // For a locale containing country code, we prefer
35 // full locale name, but if that's not found, fall back
36 // to the language only locale name.
37 $this->assertEquals(array("sr_RS", "sr"),
38 get_list_of_locales("sr_RS"));
40 // If language code is used, it's the only thing returned.
41 $this->assertEquals(array("sr"),
42 get_list_of_locales("sr"));
44 // There is support for language and charset only.
45 $this->assertEquals(array("sr.UTF-8", "sr"),
46 get_list_of_locales("sr.UTF-8"));
48 // It can also split out character set from the full locale name.
49 $this->assertEquals(array("sr_RS.UTF-8", "sr_RS", "sr"),
50 get_list_of_locales("sr_RS.UTF-8"));
52 // There is support for @modifier in locale names as well.
53 $this->assertEquals(array("sr_RS.UTF-8@latin", "sr_RS@latin", "sr@latin",
54 "sr_RS.UTF-8", "sr_RS", "sr"),
55 get_list_of_locales("sr_RS.UTF-8@latin"));
57 // We can pass in only language and modifier.
58 $this->assertEquals(array("sr@latin", "sr"),
59 get_list_of_locales("sr@latin"));
62 // If locale name is not following the regular POSIX pattern,
63 // it's used verbatim.
64 $this->assertEquals(array("something"),
65 get_list_of_locales("something"));
67 // Passing in an empty string returns an empty array.
68 $this->assertEquals(array(),
69 get_list_of_locales(""));