diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index 637dd5c..e93e4d1 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -8,6 +8,8 @@ namespace Drupal\contact\Tests; use Drupal\Component\Utility\Unicode; +use Drupal\contact\Entity\ContactForm; +use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; use Drupal\Core\Entity\EntityTypeInterface; @@ -270,6 +272,32 @@ function testSiteWideContact() { $this->assertEqual($mail['subject'], t('[@label] @subject', array('@label' => $label, '@subject' => $edit['subject[0][value]']))); $this->assertTrue(strpos($mail['body'], $field_label)); $this->assertTrue(strpos($mail['body'], $edit[$field_name . '[0][value]'])); + + // Test messages and redirect. + /** @var \Drupal\contact\ContactFormInterface $form */ + $form = ContactForm::load($contact_form); + $form->setMessage('Thanks for your submission'); + $form->setRoute([ + 'route_name' => 'entity.user.canonical', + 'route_parameters' => [ + 'user' => $admin_user->id(), + ], + ]); + $form->save(); + // Check that the field is displayed. + $this->drupalGet('contact/' . $contact_form); + + // Submit the contact form and verify the content. + $edit = array( + 'subject[0][value]' => $this->randomMachineName(), + 'message[0][value]' => $this->randomMachineName(), + $field_name . '[0][value]' => $this->randomMachineName(), + ); + $this->drupalPostForm(NULL, $edit, t('Send message')); + $this->assertText('Thanks for your submission'); + $this->assertUrl(Url::fromRoute('entity.user.canonical', [ + 'user' => $admin_user->id(), + ])->toString()); } /**