]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/languages/de/UtilsDeTest.php
lint: apply phpcbf to tests/
[github/shaarli/Shaarli.git] / tests / languages / de / UtilsDeTest.php
CommitLineData
52b50310
A
1<?php
2
3require_once 'tests/UtilsTest.php';
4
5
6class UtilsDeTest extends UtilsTest
7{
8 /**
9 * Test date_format().
10 */
11 public function testDateFormat()
12 {
13 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
81bd104d
A
14 $this->assertRegExp('/1\. Januar 2017 (um )?10:11:12 GMT\+0?3(:00)?/', format_date($date, true, true));
15 }
16
17 /**
18 * Test date_format() without time.
19 */
20 public function testDateFormatNoTime()
21 {
22 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
067c2dd8 23 $this->assertRegExp('/1\. Januar 2017/', format_date($date, false, true));
52b50310
A
24 }
25
26 /**
27 * Test date_format() using builtin PHP function strftime.
28 */
29 public function testDateFormatDefault()
30 {
31 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
81bd104d
A
32 $this->assertEquals('So 01 Jan 2017 10:11:12 EAT', format_date($date, true, false));
33 }
34
35 /**
36 * Test date_format() using builtin PHP function strftime without time.
37 */
38 public function testDateFormatDefaultNoTime()
39 {
40 $date = DateTime::createFromFormat('Ymd_His', '20170201_101112');
41 $this->assertEquals('01.02.2017', format_date($date, false, false));
52b50310 42 }
03b9cb60
A
43
44 /**
45 * Test autoLocale with a simple value
46 */
47 public function testAutoLocaleValid()
48 {
49 $current = setlocale(LC_ALL, 0);
50 $header = 'en-us';
51 autoLocale($header);
52 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
53
54 setlocale(LC_ALL, $current);
55 }
56
57 /**
58 * Test autoLocale with an alternative locale value
59 */
60 public function testAutoLocaleValidAlternative()
61 {
62 $current = setlocale(LC_ALL, 0);
63 $header = 'en_us.UTF8';
64 autoLocale($header);
65 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
66
67 setlocale(LC_ALL, $current);
68 }
69
70 /**
71 * Test autoLocale with multiples value, the first one is valid
72 */
73 public function testAutoLocaleMultipleFirstValid()
74 {
75 $current = setlocale(LC_ALL, 0);
76 $header = 'en-us,de-de';
77 autoLocale($header);
78 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
79
80 setlocale(LC_ALL, $current);
81 }
82
83 /**
b5c33d70 84 * Test autoLocale with multiples value, the second one is available
03b9cb60 85 */
b5c33d70 86 public function testAutoLocaleMultipleSecondAvailable()
03b9cb60
A
87 {
88 $current = setlocale(LC_ALL, 0);
b5c33d70 89 $header = 'mag_IN,fr-fr';
03b9cb60
A
90 autoLocale($header);
91 $this->assertEquals('fr_FR.utf8', setlocale(LC_ALL, 0));
92
93 setlocale(LC_ALL, $current);
94 }
95
96 /**
97 * Test autoLocale without value: defaults to en_US.
98 */
99 public function testAutoLocaleBlank()
100 {
101 $current = setlocale(LC_ALL, 0);
102 autoLocale('');
103 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
104
105 setlocale(LC_ALL, $current);
106 }
107
108 /**
b5c33d70 109 * Test autoLocale with an unavailable value: defaults to en_US.
03b9cb60 110 */
b5c33d70 111 public function testAutoLocaleUnavailable()
03b9cb60
A
112 {
113 $current = setlocale(LC_ALL, 0);
b5c33d70 114 autoLocale('mag_IN');
03b9cb60
A
115 $this->assertEquals('en_US.utf8', setlocale(LC_ALL, 0));
116
117 setlocale(LC_ALL, $current);
118 }
52b50310 119}