]> BookStack Code Mirror - bookstack/blob - tests/LanguageTest.php
Fixes #354, Adds the spellchecker option
[bookstack] / tests / LanguageTest.php
1 <?php namespace Tests;
2
3 class LanguageTest extends TestCase
4 {
5
6     protected $langs;
7
8     /**
9      * LanguageTest constructor.
10      */
11     public function setUp()
12     {
13         parent::setUp();
14         $this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']);
15     }
16
17     public function test_js_endpoint_for_each_language()
18     {
19
20         $visibleKeys = ['common', 'components', 'entities', 'errors'];
21
22         $this->asEditor();
23         foreach ($this->langs as $lang) {
24             setting()->putUser($this->getEditor(), 'language', $lang);
25             $transResp = $this->get('/translations');
26             foreach ($visibleKeys as $key) {
27                 $transResp->assertSee($key);
28             }
29         }
30     }
31
32     public function test_all_lang_files_loadable()
33     {
34         $files = array_diff(scandir(resource_path('lang/en')), ['..', '.']);
35         foreach ($this->langs as $lang) {
36             foreach ($files as $file) {
37                 $loadError = false;
38                 try {
39                     $translations = trans(str_replace('.php', '', $file), [], $lang);
40                 } catch (\Exception $e) {
41                     $loadError = true;
42                 }
43                 $this->assertFalse($loadError, "Translation file {$lang}/{$file} failed to load");
44             }
45         }
46     }
47
48 }