Loading core/modules/link/tests/src/Functional/LinkFieldTest.php +10 −10 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class LinkFieldTest extends BrowserTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'classy'; protected $defaultTheme = 'link_test_theme'; /** * A field to use in this test class. Loading Loading @@ -223,7 +223,7 @@ protected function assertValidEntries(string $field_name, array $valid_entries): $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); $this->assertSession()->responseContains('"' . $string . '"'); } } Loading Loading @@ -316,7 +316,7 @@ public function testLinkTitle() { "{$field_name}[0][title]" => 'Example', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('The URL field is required when the Link text field is specified.'); $this->assertSession()->statusMessageContains('The URL field is required when the Link text field is specified.', 'error'); } if ($title_setting === DRUPAL_REQUIRED) { // Verify that the link text is required, if the URL is non-empty. Loading @@ -324,14 +324,14 @@ public function testLinkTitle() { "{$field_name}[0][uri]" => 'http://www.example.com', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('Link text field is required if there is URL input.'); $this->assertSession()->statusMessageContains('Link text field is required if there is URL input.', 'error'); // Verify that the link text is not required, if the URL is empty. $edit = [ "{$field_name}[0][uri]" => '', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextNotContains('Link text field is required.'); $this->assertSession()->statusMessageNotContains('Link text field is required.'); // Verify that a URL and link text meets requirements. $this->drupalGet('entity_test/add'); Loading @@ -340,7 +340,7 @@ public function testLinkTitle() { "{$field_name}[0][title]" => 'Example', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextNotContains('Link text field is required.'); $this->assertSession()->statusMessageNotContains('Link text field is required.'); } } } Loading @@ -354,7 +354,7 @@ public function testLinkTitle() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); $output = $this->renderTestEntity($id); $expected_link = (string) Link::fromTextAndUrl($value, Url::fromUri($value))->toString(); Loading @@ -367,7 +367,7 @@ public function testLinkTitle() { ]; $this->drupalGet("entity_test/manage/{$id}/edit"); $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been updated.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been updated.', 'status'); $output = $this->renderTestEntity($id); $expected_link = (string) Link::fromTextAndUrl($title, Url::fromUri($value))->toString(); Loading Loading @@ -439,7 +439,7 @@ public function testLinkFormatter() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); // Verify that the link is output according to the formatter settings. // Not using generatePermutations(), since that leads to 32 cases, which Loading Loading @@ -590,7 +590,7 @@ public function testLinkSeparateFormatter() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); // Verify that the link is output according to the formatter settings. $options = [ Loading core/modules/link/tests/src/Functional/LinkFieldUITest.php +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ class LinkFieldUITest extends BrowserTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'classy'; protected $defaultTheme = 'stark'; /** * A user that can edit content types. Loading core/modules/link/tests/themes/link_test_theme/link_test_theme.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'Link Test Theme' type: theme description: 'Theme for testing link module' version: VERSION base theme: stark core/modules/link/tests/themes/link_test_theme/templates/link-formatter-link-separate.html.twig 0 → 100644 +22 −0 Original line number Diff line number Diff line {# /** * @file * Theme override of a link with separate title and URL elements. * * Available variables: * - link: The link that has already been formatted by l(). * - title: (optional) A descriptive or alternate title for the link, which may * be different than the actual link text. * * @see template_preprocess() * @see template_preprocess_link_formatter_link_separate() */ #} {% apply spaceless %} <div class="link-item"> {% if title %} <div class="link-title">{{ title }}</div> {% endif %} <div class="link-url">{{ link }}</div> </div> {% endapply %} Loading
core/modules/link/tests/src/Functional/LinkFieldTest.php +10 −10 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class LinkFieldTest extends BrowserTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'classy'; protected $defaultTheme = 'link_test_theme'; /** * A field to use in this test class. Loading Loading @@ -223,7 +223,7 @@ protected function assertValidEntries(string $field_name, array $valid_entries): $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); $this->assertSession()->responseContains('"' . $string . '"'); } } Loading Loading @@ -316,7 +316,7 @@ public function testLinkTitle() { "{$field_name}[0][title]" => 'Example', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('The URL field is required when the Link text field is specified.'); $this->assertSession()->statusMessageContains('The URL field is required when the Link text field is specified.', 'error'); } if ($title_setting === DRUPAL_REQUIRED) { // Verify that the link text is required, if the URL is non-empty. Loading @@ -324,14 +324,14 @@ public function testLinkTitle() { "{$field_name}[0][uri]" => 'http://www.example.com', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('Link text field is required if there is URL input.'); $this->assertSession()->statusMessageContains('Link text field is required if there is URL input.', 'error'); // Verify that the link text is not required, if the URL is empty. $edit = [ "{$field_name}[0][uri]" => '', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextNotContains('Link text field is required.'); $this->assertSession()->statusMessageNotContains('Link text field is required.'); // Verify that a URL and link text meets requirements. $this->drupalGet('entity_test/add'); Loading @@ -340,7 +340,7 @@ public function testLinkTitle() { "{$field_name}[0][title]" => 'Example', ]; $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextNotContains('Link text field is required.'); $this->assertSession()->statusMessageNotContains('Link text field is required.'); } } } Loading @@ -354,7 +354,7 @@ public function testLinkTitle() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); $output = $this->renderTestEntity($id); $expected_link = (string) Link::fromTextAndUrl($value, Url::fromUri($value))->toString(); Loading @@ -367,7 +367,7 @@ public function testLinkTitle() { ]; $this->drupalGet("entity_test/manage/{$id}/edit"); $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been updated.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been updated.', 'status'); $output = $this->renderTestEntity($id); $expected_link = (string) Link::fromTextAndUrl($title, Url::fromUri($value))->toString(); Loading Loading @@ -439,7 +439,7 @@ public function testLinkFormatter() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); // Verify that the link is output according to the formatter settings. // Not using generatePermutations(), since that leads to 32 cases, which Loading Loading @@ -590,7 +590,7 @@ public function testLinkSeparateFormatter() { $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertSession()->statusMessageContains('entity_test ' . $id . ' has been created.', 'status'); // Verify that the link is output according to the formatter settings. $options = [ Loading
core/modules/link/tests/src/Functional/LinkFieldUITest.php +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ class LinkFieldUITest extends BrowserTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'classy'; protected $defaultTheme = 'stark'; /** * A user that can edit content types. Loading
core/modules/link/tests/themes/link_test_theme/link_test_theme.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'Link Test Theme' type: theme description: 'Theme for testing link module' version: VERSION base theme: stark
core/modules/link/tests/themes/link_test_theme/templates/link-formatter-link-separate.html.twig 0 → 100644 +22 −0 Original line number Diff line number Diff line {# /** * @file * Theme override of a link with separate title and URL elements. * * Available variables: * - link: The link that has already been formatted by l(). * - title: (optional) A descriptive or alternate title for the link, which may * be different than the actual link text. * * @see template_preprocess() * @see template_preprocess_link_formatter_link_separate() */ #} {% apply spaceless %} <div class="link-item"> {% if title %} <div class="link-title">{{ title }}</div> {% endif %} <div class="link-url">{{ link }}</div> </div> {% endapply %}