LocaleFileSystemFormTest.php 1.61 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\locale\Functional;
4

5
use Drupal\Tests\BrowserTestBase;
6 7 8 9 10 11

/**
 * Tests the locale functionality in the altered file settings form.
 *
 * @group locale
 */
12
class LocaleFileSystemFormTest extends BrowserTestBase {
13 14 15 16 17 18

  /**
   * Modules to enable.
   *
   * @var array
   */
19
  public static $modules = ['system'];
20 21 22 23

  /**
   * {@inheritdoc}
   */
24
  protected function setUp() {
25
    parent::setUp();
26
    $account = $this->drupalCreateUser(['administer site configuration']);
27 28 29 30 31 32
    $this->drupalLogin($account);
  }

  /**
   * Tests translation directory settings on the file settings form.
   */
33
  public function testFileConfigurationPage() {
34 35 36 37 38 39 40 41 42 43 44 45 46
    // By default there should be no setting for the translation directory.
    $this->drupalGet('admin/config/media/file-system');
    $this->assertNoFieldByName('translation_path');

    // With locale module installed, the setting should appear.
    $module_installer = $this->container->get('module_installer');
    $module_installer->install(['locale']);
    $this->rebuildContainer();
    $this->drupalGet('admin/config/media/file-system');
    $this->assertFieldByName('translation_path');

    // The setting should persist.
    $translation_path = $this->publicFilesDirectory . '/translations_changed';
47
    $fields = [
48
      'translation_path' => $translation_path
49
    ];
50 51 52 53 54 55 56
    $this->drupalPostForm(NULL, $fields, t('Save configuration'));
    $this->drupalGet('admin/config/media/file-system');
    $this->assertFieldByName('translation_path', $translation_path);
    $this->assertEqual($translation_path, $this->config('locale.settings')->get('translation.path'));
  }

}