function FormSubmitterTest::testRedirectWithNull
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithNull()
- 10 core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithNull()
- 11.x core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithNull()
Tests the redirectForm() method when the redirect is NULL.
@covers ::redirectForm
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ FormSubmitterTest.php, line 108
Class
- FormSubmitterTest
- @coversDefaultClass \Drupal\Core\Form\FormSubmitter @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testRedirectWithNull() {
$form_submitter = $this->getFormSubmitter();
$form_state = $this->createMock('Drupal\\Core\\Form\\FormStateInterface');
$form_state->expects($this->once())
->method('getRedirect')
->willReturn(NULL);
$this->urlGenerator
->expects($this->once())
->method('generateFromRoute')
->with('<current>', [], [
'query' => [],
'absolute' => TRUE,
])
->willReturn('http://localhost/test-path');
$redirect = $form_submitter->redirectForm($form_state);
// If we have no redirect, we redirect to the current URL.
$this->assertSame('http://localhost/test-path', $redirect->getTargetUrl());
$this->assertSame(303, $redirect->getStatusCode());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.