We have a few modules that contain batch processes that are intended to be run both programmatically and from forms, in various contexts. We keep the operations in the *.form.inc files so that the entire execution process makes sense when looking at the code for the form. The batch processes work okay both ways.

With the latest update to 7.28, tests that execute these batches programmatically have stopped working properly when testing from within a browser. Running the tests via drush works fine, but when running the tests from admin/config/development/testing, the first test that executes one of these batch operation that live in a form but are executed programmatically show some weird behaviour - the batch process is delayed until the end of the entire testing run, and may or may not execute properly at all.

I've actually written a simple module to demonstrate this; I've put it up on a repository on my GitHub account. This module simply adds a few entries to the database via a batch process. You can do it via the form at the test_thing menu path (I didn't actually complete this to make it work, I've just included it as an example), or do it manually via something like:

module_load_include('inc', 'test_thing', 'includes/magic');
$stuff = array(
  'thing 1',
  'thing 2',
  'thing 3',
);
test_thing_run_fake_batch($stuff);

Both methods should add some entries to the test_whatever table in the database. test_thing_run_fake_batch() refers to the form to grab its list of batch operations, which works fine.

The file tests/whatsit.test includes two tests, both of which do the exact same thing: add a few entries to the database, and then assert that they exist. Running these tests via drush test-run --uri=http://localhost "Test Thing" shows success. If they are run from the SimpleTest browser interface, however, the tests run, and then after the test batch completes, SimpleTest shows the first instance of test_thing_run_fake_batch() running, after which it either hangs or fails to complete the batch.

Is this a bug, or is there something wrong with the example implementation I've given that could be fixed?

Comments

qadan’s picture

Issue summary: View changes

Version: 7.28 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.