function ProcessingTest::testDrupalFormSubmitInBatch
Tests form submission during a batch operation.
File
- 
              core/
modules/ system/ tests/ src/ Functional/ Batch/ ProcessingTest.php, line 200  
Class
- ProcessingTest
 - Tests batch processing in form and non-form workflow.
 
Namespace
Drupal\Tests\system\Functional\BatchCode
public function testDrupalFormSubmitInBatch() : void {
  // Displaying the page triggers a batch that programmatically submits a
  // form.
  $value = rand(0, 255);
  $this->drupalGet('batch-test/nested-programmatic/' . $value);
  $this->assertEquals([
    'mock form submitted with value = ' . $value,
  ], batch_test_stack(), '\\Drupal::formBuilder()->submitForm() ran successfully within a batch operation.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.