diff --git a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php index 5ccd8ff..4c097f7 100644 --- a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase; /** - * Tests that config overrides do not bleed through in entity forms. + * Tests that config overrides do not bleed through in entity forms and lists. * * @group config */ @@ -22,39 +22,56 @@ class ConfigEntityFormOverrideTest extends WebTestBase { public static $modules = array('config_test'); /** - * Tests that overrides do not affect forms. + * Tests that overrides do not affect forms or listing screens. */ public function testFormsWithOverrides() { - $overridden_name = 'Overridden label'; + $original_label = 'Default'; + $overridden_label = 'Overridden label'; + $edited_label = 'Edited label'; // Set up an override. $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array( - 'value' => $overridden_name, + 'value' => $overridden_label, 'required' => TRUE, ); $this->writeSettings($settings); - // Test that everything on the form is the same, but that the override - // worked for the config entity label. + // Test that the overridden label is used on a regular page. + $this->drupalGet('config_test/dotted.default'); + $this->assertText($overridden_label); + $this->assertNoText($original_label); + + // Test that the original label on the listing page is intact. $this->drupalGet('admin/structure/config_test'); - $this->assertText($overridden_name); + $this->assertText($original_label); + $this->assertNoText($overridden_label); + // Test that the original label on the editing page is intact. $this->drupalGet('admin/structure/config_test/manage/dotted.default'); $elements = $this->xpath('//input[@name="label"]'); - $this->assertIdentical((string) $elements[0]['value'], 'Default'); - $this->assertNoText($overridden_name); + $this->assertIdentical((string) $elements[0]['value'], $original_label); + $this->assertNoText($overridden_label); + + // Change to a new label and test that the listing now has the edited label. $edit = array( - 'label' => 'Custom label', + 'label' => $edited_label, ); - $this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalGet('admin/structure/config_test'); - $this->assertText($overridden_name); - $this->assertNoText($edit['label']); + $this->assertNoText($overridden_label); + $this->assertText($edited_label); + // Test that the editing page now has the edited label. $this->drupalGet('admin/structure/config_test/manage/dotted.default'); $elements = $this->xpath('//input[@name="label"]'); - $this->assertIdentical((string) $elements[0]['value'], $edit['label']); + $this->assertIdentical((string) $elements[0]['value'], $edited_label); + + // Test that the overridden label is used on a regular page regardless of + // the change to the label on the edit form. + $this->drupalGet('config_test/dotted.default'); + $this->assertText($overridden_label); + $this->assertNoText($original_label); + $this->assertNoText($edited_label); } } diff --git a/core/modules/config/tests/config_test/config_test.routing.yml b/core/modules/config/tests/config_test/config_test.routing.yml index 3a96481..1695459 100644 --- a/core/modules/config/tests/config_test/config_test.routing.yml +++ b/core/modules/config/tests/config_test/config_test.routing.yml @@ -59,6 +59,13 @@ entity.config_test.delete_form_config_test_no_status: requirements: _access: 'TRUE' +config_test.page: + path: '/config_test/{config_test}' + defaults: + _controller: '\Drupal\config_test\ConfigTestController::page' + requirements: + _access: 'TRUE' + config_test.schema_listener: path: '/config_test/schema_listener' defaults: diff --git a/core/modules/config/tests/config_test/src/ConfigTestController.php b/core/modules/config/tests/config_test/src/ConfigTestController.php index cb62642..5150f67 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestController.php +++ b/core/modules/config/tests/config_test/src/ConfigTestController.php @@ -18,6 +18,19 @@ class ConfigTestController extends ControllerBase { /** + * Route callback. + * + * @param \Drupal\config_test\Entity\ConfigTest $config_test + * The ConfigTest object. + * + * @return string + * The label of the ConfigTest object. + */ + public function page(ConfigTest $config_test) { + return $config_test->label(); + } + + /** * Route title callback. * * @param \Drupal\config_test\Entity\ConfigTest $config_test