]>
git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/I18n.php
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2013-2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
28 * @package GaletteTests
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
38 namespace Galette\Core\test\units
;
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2013-2014 The Galette Team
50 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
51 * @link http://galette.tuxfamily.org
54 class I18n
extends atoum
61 * @param string $testMethod Tested method name
65 public function beforeTestMethod($testMethod)
67 $this->i18n
= new \Galette\Core\
I18n(
68 \Galette\Core\I18n
::DEFAULT_LANG
73 * Test lang autodetect
77 public function testAutoLang()
79 $this->i18n
= new \Galette\Core\
I18n();
81 $this->variable($this->i18n
->getID())
82 ->isIdenticalTo('fr_FR');
84 //simulate fr from browser
85 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr_BE';
86 $this->i18n
= new \Galette\Core\
I18n();
88 $this->variable($this->i18n
->getID())
89 ->isIdenticalTo('fr_FR');
91 //simulate en from browser
92 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_GB';
93 $this->i18n
= new \Galette\Core\
I18n();
95 $this->variable($this->i18n
->getID())
96 ->isIdenticalTo('en_US');
98 //simulate unknown lang from browser
99 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_ES';
100 $this->i18n
= new \Galette\Core\
I18n();
102 $this->variable($this->i18n
->getID())
103 ->isIdenticalTo('fr_FR');
107 * Test languages list
111 public function testGetList()
113 $list = $this->i18n
->getList();
116 ->size
->isGreaterThan(3);
118 foreach ($list as $elt) {
120 ->isInstanceOf('\Galette\Core\I18n');
125 * Test languages list as array
129 public function testGetArrayList()
131 $list = $this->i18n
->getArrayList();
134 ->size
->isGreaterThan(3);
138 * Test getting language name from its ID
142 public function testGetNameFromid()
144 $lang = $this->i18n
->getNameFromId('en_US');
146 $this->variable($lang)
147 ->isIdenticalTo('English');
151 * Test retrieving language informations
155 public function testGetLangInfos()
157 $id = $this->i18n
->getID();
158 $longid = $this->i18n
->getLongID();
159 $name = $this->i18n
->getName();
160 $abbrev = $this->i18n
->getAbbrev();
163 ->isIdenticalTo('fr_FR');
164 $this->variable($longid)
165 ->isIdenticalTo('fr_FR.utf8');
166 $this->variable($name)
167 ->isIdenticalTo('français');
168 $this->variable($abbrev)
169 ->isIdenticalTo('fr');
173 * Change to an unknown language
177 public function testChangeUnknownLanguage()
179 $this->i18n
->changeLanguage('un_KN');
180 $id = $this->i18n
->getID();
183 ->isIdenticalTo('fr_FR');
187 * Check (non) UTF strings
191 public function testSeemUtf8()
193 $is_utf = $this->i18n
->seemUtf8('HéhéHÉHÉâ-ô߬- ©»«<ëßßä€êþÿûîœô');
194 $is_iso = $this->i18n
->seemUtf8(utf8_decode('Héhé'));
196 $this->boolean($is_utf)->isTrue();
197 $this->boolean($is_iso)->isFalse();