setRedirectPath example

$this->submitForm($edit, 'Send message');
    $mails = $this->getMails();
    $mail = array_pop($mails);
    $this->assertEquals(t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']])$mail['subject']);
    $this->assertStringContainsString($field_label$mail['body']);
    $this->assertStringContainsString($edit[$field_name . '[0][value]']$mail['body']);

    // Test messages and redirect.     /** @var \Drupal\contact\ContactFormInterface $form */
    $form = ContactForm::load($contact_form);
    $form->setMessage('Thanks for your submission.');
    $form->setRedirectPath('/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 = [
      'subject[0][value]' => $this->randomMachineName(),
      'message[0][value]' => $this->randomMachineName(),
      $field_name . '[0][value]' => $this->randomMachineName(),
    ];
    $this->submitForm($edit, 'Send message');
    
Home | Imprint | This part of the site doesn't use cookies.