function FormSubmitterTest::testHandleFormSubmissionWithResponses

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

@covers ::doSubmitForm

@dataProvider providerTestHandleFormSubmissionWithResponses

File

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

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 testHandleFormSubmissionWithResponses($class, $form_state_key) : void {
    $response = $this->getMockBuilder($class)
        ->disableOriginalConstructor()
        ->getMock();
    $response->expects($this->any())
        ->method('prepare')
        ->willReturn($response);
    $form_state = (new FormState())->setSubmitted()
        ->setFormState([
        $form_state_key => $response,
    ]);
    $form_submitter = $this->getFormSubmitter();
    $form = [];
    $return = $form_submitter->doSubmitForm($form, $form_state);
    $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $return);
}

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