You are here

public function FormSubmitterTest::testRedirectWithResponseObject in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithResponseObject()
  2. 9 core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithResponseObject()

Tests the redirectForm() method with a response object.

@covers ::redirectForm

File

core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php, line 181

Class

FormSubmitterTest
@coversDefaultClass \Drupal\Core\Form\FormSubmitter @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testRedirectWithResponseObject() {
  $form_submitter = $this
    ->getFormSubmitter();
  $redirect = new RedirectResponse('/example');
  $form_state = $this
    ->createMock('Drupal\\Core\\Form\\FormStateInterface');
  $form_state
    ->expects($this
    ->once())
    ->method('getRedirect')
    ->willReturn($redirect);
  $result_redirect = $form_submitter
    ->redirectForm($form_state);
  $this
    ->assertSame($redirect, $result_redirect);
}