]> BookStack Code Mirror - bookstack/blobdiff - tests/LanguageTest.php
Add Slovak translation
[bookstack] / tests / LanguageTest.php
index ed5ee7dee14ec621b38801694da9c44b8523c337..911ac3e81588306c700ba9ee27500fe4d92084f3 100644 (file)
@@ -3,13 +3,24 @@
 class LanguageTest extends TestCase
 {
 
-    public function test_js_endpoint_for_each_language() {
+    protected $langs;
+
+    /**
+     * LanguageTest constructor.
+     */
+    public function setUp()
+    {
+        parent::setUp();
+        $this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']);
+    }
+
+    public function test_js_endpoint_for_each_language()
+    {
 
-        $langs = array_diff(scandir(resource_path('lang')), ['..', '.']);
         $visibleKeys = ['common', 'components', 'entities', 'errors'];
 
         $this->asEditor();
-        foreach ($langs as $lang) {
+        foreach ($this->langs as $lang) {
             setting()->putUser($this->getEditor(), 'language', $lang);
             $transResp = $this->get('/translations');
             foreach ($visibleKeys as $key) {
@@ -18,4 +29,20 @@ class LanguageTest extends TestCase
         }
     }
 
+    public function test_all_lang_files_loadable()
+    {
+        $files = array_diff(scandir(resource_path('lang/en')), ['..', '.']);
+        foreach ($this->langs as $lang) {
+            foreach ($files as $file) {
+                $loadError = false;
+                try {
+                    $translations = trans(str_replace('.php', '', $file), [], $lang);
+                } catch (\Exception $e) {
+                    $loadError = true;
+                }
+                $this->assertFalse($loadError, "Translation file {$lang}/{$file} failed to load");
+            }
+        }
+    }
+
 }
\ No newline at end of file