Using more than one function for a batch surely works, as one of the test functions for the batch API contains the following call.
batch_set(_batch_test_batch_3());
_batch_test_batch_3() contains the following code.
// Ensure the batch takes at least two iterations.
$total = 10;
$sleep = (1000000 / $total) * 2;
$operations = array();
for ($i = 1; $i <= round($total / 2); $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
}
$operations[] = array('_batch_test_callback_2', array(1, $total / 2, $sleep));
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
}
$operations[] = array('_batch_test_callback_2', array(6, $total / 2, $sleep));
$batch = array(
'operations' => $operations,
'finished' => '_batch_test_finished_3',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
return $batch;
What is wrong in your code is how you set $batch['operations']
.
The correct code is the following one.
$operations[] = array('test_function1', array($new_node));
$operations[] = array('test_function2', array($new_node));
$batch = array(
'operations' => $operations,
);
batch_set($batch);