diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 0b07f54..3e94416 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -680,7 +680,7 @@ function locale_form_system_file_system_settings_alter(&$form, FormStateInterfac $form['translation_path'] = array( '#type' => 'textfield', '#title' => t('Interface translations directory'), - '#default_value' => \Drupal::config('locale.settings')->get('translation.path'), + '#default_value' => \Drupal::configFactory()->getEditable('locale.settings')->get('translation.path'), '#maxlength' => 255, '#description' => t('A local file system path where interface translation files will be stored.'), '#required' => TRUE, @@ -705,7 +705,7 @@ function locale_system_file_system_settings_submit(&$form, FormStateInterface $f locale_translation_clear_status(); } - \Drupal::config('locale.settings') + \Drupal::configFactory()->getEditable('locale.settings') ->set('translation.path', $form_state->getValue('translation_path')) ->save(); } diff --git a/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php b/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php new file mode 100644 index 0000000..1a5f75a --- /dev/null +++ b/core/modules/locale/src/Tests/LocaleFileSystemFormTest.php @@ -0,0 +1,75 @@ +adminUser = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($this->adminUser); + } + + /** + * Tests translation settings at the FileSystemForm. + */ + function testFileConfigurationPage() { + // Gets File System Settings Form. + $this->drupalGet('admin/config/media/file-system'); + + // There is not a translation path field. + $this->assertNoFieldByName('translation_path'); + + // It enables the module - locale. + $module_installer = $this->container->get('module_installer'); + $module_installer->install(['locale']); + + // There is the translation path field. + $this->drupalGet('admin/config/media/file-system'); + $this->assertFieldByName('translation_path'); + + // It saves new settings. + $file_path = $this->publicFilesDirectory; + $translation_path = $file_path . '/translations_changed'; + $fields = array( + 'file_temporary_path' => $file_path . '/file_config_page_test/temporary', + 'file_default_scheme' => 'private', + 'translation_path' => $translation_path + ); + $this->drupalPostForm(NULL, $fields, t('Save configuration')); + + // It checks if translation path is saved successuly. + $this->drupalGet('admin/config/media/file-system'); + $this->assertFieldByName('translation_path', $translation_path); + $config_factory = $this->container->get('config.factory'); + $this->assertTrue($translation_path == $config_factory->get('locale.settings')->get('translation.path')); + } + +}