3 class LanguageTest extends TestCase
9 * LanguageTest constructor.
11 public function setUp()
14 $this->langs = array_diff(scandir(resource_path('lang')), ['..', '.', 'check.php']);
17 public function test_locales_config_key_set_properly()
19 $configLocales = config('app.locales');
22 $this->assertTrue(implode(':', $this->langs) === implode(':', $configLocales), 'app.locales configuration variable matches found lang files');
25 public function test_correct_language_if_not_logged_in()
27 $loginReq = $this->get('/login');
28 $loginReq->assertSee('Log In');
30 $loginPageFrenchReq = $this->get('/login', ['Accept-Language' => 'fr']);
31 $loginPageFrenchReq->assertSee('Se Connecter');
34 public function test_js_endpoint_for_each_language()
37 $visibleKeys = ['common', 'components', 'entities', 'errors'];
40 foreach ($this->langs as $lang) {
41 setting()->putUser($this->getEditor(), 'language', $lang);
42 $transResp = $this->get('/translations');
43 foreach ($visibleKeys as $key) {
44 $transResp->assertSee($key);
49 public function test_all_lang_files_loadable()
51 $files = array_diff(scandir(resource_path('lang/en')), ['..', '.']);
52 foreach ($this->langs as $lang) {
53 foreach ($files as $file) {
56 $translations = trans(str_replace('.php', '', $file), [], $lang);
57 } catch (\Exception $e) {
60 $this->assertFalse($loadError, "Translation file {$lang}/{$file} failed to load");