diff --git a/core/modules/link/tests/src/Functional/LinkFieldUITest.php b/core/modules/link/tests/src/Functional/LinkFieldUITest.php index 91d906f..0f37f38 100644 --- a/core/modules/link/tests/src/Functional/LinkFieldUITest.php +++ b/core/modules/link/tests/src/Functional/LinkFieldUITest.php @@ -58,13 +58,13 @@ function testFieldUI() { $field_edit = [ 'description' => $description, ]; - $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', array(), $field_edit); + $this->fieldUIAddNewField($type_path, $field_name, $label, 'link', [], $field_edit); // Load the formatter page to check that the settings summary does not // generate warnings. // @todo Mess with the formatter settings a bit here. $this->drupalGet("$type_path/display"); - $this->assertText(t('Link text trimmed to @limit characters', array('@limit' => 80))); + $this->assertText(t('Link text trimmed to @limit characters', ['@limit' => 80])); // There are many combinations of UI settings, where the description should // show: variation on internal, external, both; cardinality (where the @@ -83,8 +83,17 @@ function testFieldUI() { $help_texts = [ LinkItemInterface::LINK_EXTERNAL => 'This must be an external URL such as http://example.com.', LinkItemInterface::LINK_GENERIC => 'You can also enter an internal path such as /node/add or an external URL such as http://example.com. Enter <front> to link to the front page.', - LinkItemInterface::LINK_INTERNAL => rtrim(\Drupal::url('', array(), array('absolute' => TRUE)), '/'), + LinkItemInterface::LINK_INTERNAL => rtrim(\Drupal::url('', [], ['absolute' => TRUE]), '/'), ]; + + // 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(); + $field_count = 0; // Test all variations of link types on all cardinalities. foreach ($cardinalities as $cardinality) { @@ -94,18 +103,6 @@ function testFieldUI() { // Both test empty descriptions and not empty descriptions. foreach ([TRUE, FALSE] as $description_enabled) { $field_count++; - // 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. @@ -119,20 +116,29 @@ function testFieldUI() { '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); + // 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); + + $field_count = 0; + // Test all variations of link types on all cardinalities. + foreach ($cardinalities as $cardinality) { + foreach ($link_types as $link_type) { + // Now, test this with both the title enabled and disabled. + foreach ($title_settings as $title_setting) { + // Both test empty descriptions and not empty descriptions. + foreach ([TRUE, FALSE] as $description_enabled) { + $field_count++; + $description = 'link field description with html ' . $field_count; // Check that the help texts we assume should be there, is there. $this->assertRaw($help_texts[$link_type]); - if ($link_type === LinkItemInterface::LINK_INTERNAL) { - // Internal links have no "system" description. Test that none - // of the other help texts show here. - $this->assertNoRaw($help_texts[LinkItemInterface::LINK_EXTERNAL]); - $this->assertNoRaw($help_texts[LinkItemInterface::LINK_GENERIC]); - } // Also assert that the description we made is here, no matter what // the cardinality or link setting. if ($description_enabled) {