ba67960650b48e967909a279e5b3ef3df492a5e4
[yaffs-website] / web / core / modules / config / src / Tests / LanguageNegotiationFormOverrideTest.php
1 <?php
2
3 namespace Drupal\config\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Tests language-negotiation overrides are not on language-negotiation form.
9  *
10  * @group config
11  * @see \Drupal\Core\Form\ConfigFormBase
12  */
13 class LanguageNegotiationFormOverrideTest extends WebTestBase {
14
15   public static $modules = ['language', 'locale', 'locale_test'];
16
17   /**
18    * Tests that overrides do not affect language-negotiation form values.
19    */
20   public function testFormWithOverride() {
21     $this->drupalLogin($this->rootUser);
22     $overridden_value_en = 'whatever';
23     $overridden_value_es = 'loquesea';
24
25     // Set up an override.
26     $settings['config']['language.negotiation']['url']['prefixes'] = (object) [
27       'value' => ['en' => $overridden_value_en, 'es' => $overridden_value_es],
28       'required' => TRUE,
29     ];
30     $this->writeSettings($settings);
31
32     // Add predefined language.
33     $edit = [
34       'predefined_langcode' => 'es',
35     ];
36     $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
37
38     // Overridden string for language-negotiation should not exist in the form.
39     $this->drupalGet('admin/config/regional/language/detection/url');
40
41     // The language-negotiation form should be found.
42     $this->assertText('Path prefix configuration', 'Language-negotiation form found for English.');
43
44     // The English override should not be found.
45     $this->assertNoFieldByName('prefix[en]', $overridden_value_en, 'Language-negotiation config override not found in English.');
46
47     // Now check the Spanish version of the page for the same thing.
48     $this->drupalGet($overridden_value_es . '/admin/config/regional/language/detection/url');
49
50     // The language-negotiation form should be found.
51     $this->assertText('Path prefix configuration', 'Language-negotiation form found for Spanish using the overridden prefix.');
52
53     // The Spanish override should not be found.
54     $this->assertNoFieldByName('prefix[es]', $overridden_value_es, 'Language-negotiation config override not found in Spanish.');
55
56   }
57
58 }