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 <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormSubmitter.php/class/FormSubmitter/11.x" title="Provides submission processing for forms." class="local">\Drupal\Core\Form\FormSubmitter</a> @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.