]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/languages/en/UtilsEnTest.php
3 require_once 'tests/UtilsTest.php';
6 class UtilsEnTest
extends UtilsTest
11 public function testDateFormat()
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, true));
18 * Test date_format() without time.
20 public function testDateFormatNoTime()
22 $date = DateTime
::createFromFormat('Ymd_His', '20170101_101112');
23 $this->assertRegExp('/January 1, 2017/', format_date($date, false, true));
27 * Test date_format() using builtin PHP function strftime.
29 public function testDateFormatDefault()
31 $date = DateTime
::createFromFormat('Ymd_His', '20170101_101112');
32 $this->assertEquals('Sun 01 Jan 2017 10:11:12 AM EAT', format_date($date, true, false));
36 * Test date_format() using builtin PHP function strftime without time.
38 public function testDateFormatDefaultNoTime()
40 $date = DateTime
::createFromFormat('Ymd_His', '20170201_101112');
41 $this->assertEquals('02/01/2017', format_date($date, false, false));
45 * Test autoLocale with a simple value
47 public function testAutoLocaleValid()
49 $current = setlocale(LC_ALL
, 0);
52 $this->assertEquals('de_DE.utf8', setlocale(LC_ALL
, 0));
54 setlocale(LC_ALL
, $current);
58 * Test autoLocale with an alternative locale value
60 public function testAutoLocaleValidAlternative()
62 $current = setlocale(LC_ALL
, 0);
63 $header = 'de_de.UTF8';
65 $this->assertEquals('de_DE.utf8', setlocale(LC_ALL
, 0));
67 setlocale(LC_ALL
, $current);
71 * Test autoLocale with multiples value, the first one is valid
73 public function testAutoLocaleMultipleFirstValid()
75 $current = setlocale(LC_ALL
, 0);
76 $header = 'de-de;en-us';
78 $this->assertEquals('de_DE.utf8', setlocale(LC_ALL
, 0));
80 setlocale(LC_ALL
, $current);
84 * Test autoLocale with multiples value, the second one is available
86 public function testAutoLocaleMultipleSecondAvailable()
88 $current = setlocale(LC_ALL
, 0);
89 $header = 'mag_IN,fr-fr';
91 $this->assertEquals('fr_FR.utf8', setlocale(LC_ALL
, 0));
93 setlocale(LC_ALL
, $current);
97 * Test autoLocale without value: defaults to en_US.
99 public function testAutoLocaleBlank()
101 $current = setlocale(LC_ALL
, 0);
103 $this->assertEquals('en_US.utf8', setlocale(LC_ALL
, 0));
105 setlocale(LC_ALL
, $current);
109 * Test autoLocale with an unavailable value: defaults to en_US.
111 public function testAutoLocaleUnavailable()
113 $current = setlocale(LC_ALL
, 0);
114 autoLocale('mag_IN');
115 $this->assertEquals('en_US.utf8', setlocale(LC_ALL
, 0));
117 setlocale(LC_ALL
, $current);