function FormSubmitterTest::testRedirectWithoutResult

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithoutResult()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithoutResult()
  3. 10 core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithoutResult()

Tests the redirectForm() method when no redirect is expected.

@covers ::redirectForm

File

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

Class

FormSubmitterTest
@coversDefaultClass \Drupal\Core\Form\FormSubmitter[[api-linebreak]] @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testRedirectWithoutResult() : void {
  $form_submitter = $this->getFormSubmitter();
  $this->urlGenerator
    ->expects($this->never())
    ->method('generateFromRoute');
  $this->unroutedUrlAssembler
    ->expects($this->never())
    ->method('assemble');
  $container = new ContainerBuilder();
  $container->set('url_generator', $this->urlGenerator);
  $container->set('unrouted_url_assembler', $this->unroutedUrlAssembler);
  \Drupal::setContainer($container);
  $form_state = $this->createMock('Drupal\\Core\\Form\\FormStateInterface');
  $form_state->expects($this->once())
    ->method('getRedirect')
    ->willReturn(FALSE);
  $redirect = $form_submitter->redirectForm($form_state);
  $this->assertNull($redirect);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.