diff --git a/core/modules/link/src/Tests/LinkFieldUITest.php b/core/modules/link/src/Tests/LinkFieldUITest.php index 5ee1045..ac349a0 100644 --- a/core/modules/link/src/Tests/LinkFieldUITest.php +++ b/core/modules/link/src/Tests/LinkFieldUITest.php @@ -90,62 +90,68 @@ function testFieldUI() { foreach ($link_types as $link_type) { // Now, test this with both the title enabled and disabled. foreach ($title_settings as $title_setting) { - // Output variation being tested for debugging purpose. - $this->verbose("Now testing - cardinality: $cardinality - link_type: - $link_type, title_setting: $title_setting"); - - // Log in an admin to set up a content type for this test. - $this->drupalLogin($this->adminUser); - - // Add a new content type. - $type = $this->drupalCreateContentType(); - $type_path = 'admin/structure/types/manage/' . $type->id(); - $add_path = 'node/add/' . $type->id(); - - // Create a field for this content type with the current cardinality - // and link field settings. - $label = $this->randomMachineName(); - $description = $this->randomMachineName(); - $field_name = Unicode::strtolower($label); - $storage_edit = ['cardinality_number' => $cardinality]; - $field_edit = [ - 'settings[link_type]' => $link_type, - 'description' => $description, - 'settings[title]' => $title_setting, - ]; - $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', $storage_edit, $field_edit); - - // Log in a user that is allowed to create this content type, see if - // the user can see the expected help text. - $this->drupalLogin($this->drupalCreateUser(['create ' . $type->id() . ' content'])); - $this->drupalGet($add_path); - - // Check that the help texts we assume should be there, is there. - switch ($link_type) { - case LinkItemInterface::LINK_GENERIC: - // Check that the text for allowing both internal and external is - // present. - $this->assertRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); - break; - - case LinkItemInterface::LINK_EXTERNAL: - // Check the external only link help text. - $this->assertRaw('This must be an external URL such as http://example.com.'); - break; - - case LinkItemInterface::LINK_INTERNAL: - // Internal links have no "system" description. Test that none of - // the above shows here. - $this->assertNoRaw('This must be an external URL such as http://example.com.'); - $this->assertNoRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); - // And assert that the field prefix is the internal URL. - $this->assertRaw(rtrim(\Drupal::url('', array(), array('absolute' => TRUE)), '/')); - break; - + // Both test empty descriptions and not empty descriptions. + foreach ([TRUE, FALSE] as $description_enabled) { + // Output variation being tested for debugging purpose. + $this->verbose("Now testing - cardinality: $cardinality - link_type: + $link_type, title_setting: $title_setting, description_enabled: + $description_enabled"); + + // Log in an admin to set up a content type for this test. + $this->drupalLogin($this->adminUser); + + // Add a new content type. + $type = $this->drupalCreateContentType(); + $type_path = 'admin/structure/types/manage/' . $type->id(); + $add_path = 'node/add/' . $type->id(); + + // Create a field for this content type with the current cardinality + // and link field settings. + $label = $this->randomMachineName(); + $description = $this->randomMachineName(); + $field_name = Unicode::strtolower($label); + $storage_edit = ['cardinality_number' => $cardinality]; + $field_edit = [ + 'settings[link_type]' => $link_type, + 'description' => $description_enabled ? $description : '', + 'settings[title]' => $title_setting, + ]; + $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', $storage_edit, $field_edit); + + // Log in a user that is allowed to create this content type, see if + // the user can see the expected help text. + $this->drupalLogin($this->drupalCreateUser(['create ' . $type->id() . ' content'])); + $this->drupalGet($add_path); + + // Check that the help texts we assume should be there, is there. + switch ($link_type) { + case LinkItemInterface::LINK_GENERIC: + // Check that the text for allowing both internal and external is + // present. + $this->assertRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); + break; + + case LinkItemInterface::LINK_EXTERNAL: + // Check the external only link help text. + $this->assertRaw('This must be an external URL such as http://example.com.'); + break; + + case LinkItemInterface::LINK_INTERNAL: + // Internal links have no "system" description. Test that none of + // the above shows here. + $this->assertNoRaw('This must be an external URL such as http://example.com.'); + $this->assertNoRaw('You can also enter an internal path such as /node/add or an external URL such as http://example.com.'); + // And assert that the field prefix is the internal URL. + $this->assertRaw(rtrim(\Drupal::url('', array(), array('absolute' => TRUE)), '/')); + break; + + } + // Also assert that the description we made is here, no matter what + // the cardinality or link setting. + if ($description_enabled) { + $this->assertRaw($description); + } } - // Also assert that the description we made is here, no matter what - // the cardinality or link setting. - $this->assertRaw($description); } } }