public function FormBuilderTest::testGetPostAjaxRequest in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::testGetPostAjaxRequest()
@covers ::buildForm
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ FormBuilderTest.php, line 588 - Contains \Drupal\Tests\Core\Form\FormBuilderTest.
Class
- FormBuilderTest
- @coversDefaultClass \Drupal\Core\Form\FormBuilder @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testGetPostAjaxRequest() {
$request = new Request([
FormBuilderInterface::AJAX_FORM_REQUEST => TRUE,
], [
'form_id' => 'different_form_id',
]);
$request
->setMethod('POST');
$this->requestStack
->push($request);
$form_state = (new FormState())
->setUserInput([
FormBuilderInterface::AJAX_FORM_REQUEST => TRUE,
])
->setMethod('get')
->setAlwaysProcess()
->disableRedirect()
->set('ajax', TRUE);
$form_id = '\\Drupal\\Tests\\Core\\Form\\TestForm';
$expected_form = (new TestForm())
->buildForm([], $form_state);
$form = $this->formBuilder
->buildForm($form_id, $form_state);
$this
->assertFormElement($expected_form, $form, 'test');
$this
->assertSame('test-form', $form['#id']);
}