]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/languages/en/UtilsEnTest.php
7c829ac7e5856cd003e979949572d7c1551397da
[github/shaarli/Shaarli.git] / tests / languages / en / UtilsEnTest.php
1 <?php
2
3 require_once 'tests/UtilsTest.php';
4
5
6 class UtilsEnTest extends UtilsTest
7 {
8 /**
9 * Test date_format().
10 */
11 public function testDateFormat()
12 {
13 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
14 $this->assertRegExp('/January 1, 2017 (at )?10:11:12 AM GMT\+0?3(:00)?/', format_date($date, true));
15 }
16
17 /**
18 * Test date_format() using builtin PHP function strftime.
19 */
20 public function testDateFormatDefault()
21 {
22 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
23 $this->assertEquals('Sun 01 Jan 2017 10:11:12 AM EAT', format_date($date, false));
24 }
25
26 /**
27 * Test autoLocale with a simple value
28 */
29 public function testAutoLocaleValid()
30 {
31 $current = setlocale(LC_ALL, 0);
32 $header = 'de-de';
33 autoLocale($header);
34 $this->assertEquals('de_DE.utf8', setlocale(LC_ALL, 0));
35
36 setlocale(LC_ALL, $current);
37 }
38
39 /**
40 * Test autoLocale with an alternative locale value
41 */
42 public function testAutoLocaleValidAlternative()
43 {
44 $current = setlocale(LC_ALL, 0);
45 $header = 'de_de.UTF8';
46 autoLocale($header);
47 $this->assertEquals('de_DE.utf8', setlocale(LC_ALL, 0));
48
49 setlocale(LC_ALL, $current);
50 }
51
52 /**
53 * Test autoLocale with multiples value, the first one is valid
54 */
55 public function testAutoLocaleMultipleFirstValid()
56 {
57 $current = setlocale(LC_ALL, 0);
58 $header = 'de-de;en-us';
59 autoLocale($header);
60 $this->assertEquals('de_DE.utf8', setlocale(LC_ALL, 0));
61
62 setlocale(LC_ALL, $current);
63 }
64
65 /**
66 * Test autoLocale with multiples value, the second one is valid
67 */
68 public function testAutoLocaleMultipleSecondValid()
69 {
70 $current = setlocale(LC_ALL, 0);
71 $header = 'pt_BR,fr-fr';
72 autoLocale($header);
73 $this->assertEquals('fr_FR.utf8', setlocale(LC_ALL, 0));
74
75 setlocale(LC_ALL, $current);
76 }
77
78 /**
79 * Test autoLocale without value: defaults to en_US.
80 */
81 public function testAutoLocaleBlank()
82 {
83 $current = setlocale(LC_ALL, 0);
84 autoLocale('');
85 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
86
87 setlocale(LC_ALL, $current);
88 }
89
90 /**
91 * Test autoLocale with an invalid value: defaults to en_US.
92 */
93 public function testAutoLocaleInvalid()
94 {
95 $current = setlocale(LC_ALL, 0);
96 autoLocale('pt_BR');
97 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
98
99 setlocale(LC_ALL, $current);
100 }
101 }