? modules/simpletest/tests/form_test.info
? modules/simpletest/tests/form_test.module
? sites/default/files
? sites/default/settings.php
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.310
diff -u -r1.310 form.inc
--- includes/form.inc	30 Dec 2008 16:43:14 -0000	1.310
+++ includes/form.inc	5 Jan 2009 17:07:55 -0000
@@ -757,7 +757,7 @@
 
   foreach ($handlers as $function) {
     if (drupal_function_exists($function))  {
-      if ($type == 'submit' && ($batch =& batch_get())) {
+      if ($type == 'submit' && ($batch =& batch_get()) && !isset($batch['current_set'])) {
         // Some previous _submit handler has set a batch. We store the call
         // in a special 'control' batch set, for execution at the correct
         // time during the batch processing workflow.
Index: modules/simpletest/tests/form.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form.test,v
retrieving revision 1.1
diff -u -r1.1 form.test
--- modules/simpletest/tests/form.test	14 Aug 2008 09:18:28 -0000	1.1
+++ modules/simpletest/tests/form.test	5 Jan 2009 19:49:30 -0000
@@ -72,3 +72,34 @@
     drupal_get_messages();
   }
 }
+
+class FormAPITestCase extends DrupalWebTestCase {
+
+  function getInfo() {
+    return array(
+      'name' => t('Drupal Execute and Batch API'),
+      'description' => t('Tests the compatibility of drupal_execute and the Batch API'),
+      'group' => t('Form API'),
+    );
+  }
+  
+  /**
+   * Check that we can run drupal_execute during a batch.
+   */
+  function testRequiredFields() {
+    variable_set('form_test_mock_submit', FALSE);
+    $state = array();
+    $state['values'] = array();
+    // We get run in a batch, so can just call drupal execute:
+    drupal_execute('form_test_mock_form', $state);
+    $this->assertTrue(variable_get('form_test_mock_submit', FALSE), t('Check drupal_execute called submit handlers when running in a batch'));
+  }
+  
+  /**
+   * Implementation of setUp().
+   */
+  function setUp() {
+    parent::setUp('form_test');
+  }
+  
+}
--- modules/simpletest/tests/form_test.info
+++ modules/simpletest/tests/form_test.info
@@ -0,0 +1,8 @@
+; $Id: $

+name = "Form Test"

+description = "Support module for Form tests."

+package = Testing

+version = VERSION

+core = 7.x

+files[] = form_test.module

+hidden = TRUE


--- modules/simpletest/tests/form_test.module
+++ modules/simpletest/tests/form_test.module
@@ -0,0 +1,21 @@
+<?php

+

+function form_test_mock_form($form_state) {

+  $form = array();

+  

+  $form['submit'] = array(

+    '#type' => 'submit',

+    '#value' => t('Submit'),

+  );

+  

+  return $form;

+

+}

+

+function form_test_mock_form_validate($form, &$form_state) {

+

+}

+

+function form_test_mock_form_submit($form, &$form_state) {

+  variable_set('form_test_mock_submit', TRUE);

+}


