3 namespace Drupal\config\Tests;
5 use Drupal\simpletest\WebTestBase;
8 * Tests that config overrides do not bleed through in entity forms and lists.
12 class ConfigEntityFormOverrideTest extends WebTestBase {
17 public static $modules = ['config_test'];
20 * Tests that overrides do not affect forms or listing screens.
22 public function testFormsWithOverrides() {
23 $this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
25 $original_label = 'Default';
26 $overridden_label = 'Overridden label';
27 $edited_label = 'Edited label';
29 $config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
31 // Set up an override.
32 $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
33 'value' => $overridden_label,
36 $this->writeSettings($settings);
38 // Test that the overridden label is loaded with the entity.
39 $this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);
41 // Test that the original label on the listing page is intact.
42 $this->drupalGet('admin/structure/config_test');
43 $this->assertText($original_label);
44 $this->assertNoText($overridden_label);
46 // Test that the original label on the editing page is intact.
47 $this->drupalGet('admin/structure/config_test/manage/dotted.default');
48 $elements = $this->xpath('//input[@name="label"]');
49 $this->assertIdentical((string) $elements[0]['value'], $original_label);
50 $this->assertNoText($overridden_label);
52 // Change to a new label and test that the listing now has the edited label.
54 'label' => $edited_label,
56 $this->drupalPostForm(NULL, $edit, t('Save'));
57 $this->drupalGet('admin/structure/config_test');
58 $this->assertNoText($overridden_label);
59 $this->assertText($edited_label);
61 // Test that the editing page now has the edited label.
62 $this->drupalGet('admin/structure/config_test/manage/dotted.default');
63 $elements = $this->xpath('//input[@name="label"]');
64 $this->assertIdentical((string) $elements[0]['value'], $edited_label);
66 // Test that the overridden label is still loaded with the entity.
67 $this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);