diff core/modules/link/tests/src/Functional/LinkFieldTest.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 1fec387a4317
children 129ea1e6d783
line wrap: on
line diff
--- a/core/modules/link/tests/src/Functional/LinkFieldTest.php	Thu Apr 26 11:26:54 2018 +0100
+++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php	Tue Jul 10 15:07:59 2018 +0100
@@ -121,6 +121,10 @@
       '/?example=llama' => '<front>?example=llama',
       '/#example' => '<front>#example',
 
+      // Trailing spaces should be ignored.
+      '/ ' => '<front>',
+      '/path with spaces ' => '/path with spaces',
+
       // @todo '<front>' is valid input for BC reasons, may be removed by
       //   https://www.drupal.org/node/2421941
       '<front>' => '&lt;front&gt;',
@@ -200,7 +204,7 @@
       preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
       $id = $match[1];
       $this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
-      $this->assertRaw($string);
+      $this->assertRaw('"' . $string . '"');
     }
   }
 
@@ -281,6 +285,14 @@
         $this->assertRaw('placeholder="Enter the text for this link"');
 
         $this->assertFieldByName("{$field_name}[0][title]", '', 'Link text field found.');
+        if ($title_setting === DRUPAL_OPTIONAL) {
+          // Verify that the URL is required, if the link text is non-empty.
+          $edit = [
+            "{$field_name}[0][title]" => 'Example',
+          ];
+          $this->drupalPostForm(NULL, $edit, t('Save'));
+          $this->assertText(t('The URL field is required when the @title field is specified.', ['@title' => t('Link text')]));
+        }
         if ($title_setting === DRUPAL_REQUIRED) {
           // Verify that the link text is required, if the URL is non-empty.
           $edit = [