Hi, This is in relation to http://drupal.org/node/360377. What I'm doing is building multiple $form_state arrays and using them to build an entire structure of a book automatically. In essence, the code looks like this (mostly from the comments above drupal_execute(), and yes, I want to create a book of articles - node type doesn't seem to matter): $parent_node = array('type' => 'article'); $form_state = array(); $form_state['values'] = array(); $form_state['values']['title'] = $number . ' - SimpleTest test node ' . $this->randomName(10); $form_state['values']['body'] = 'SimpleTest test body ' . $this-
randomName(32) . ' ' . $this->randomName(32); $form_state['values']['book'] = _book_link_defaults('new'); $form_state['values']['book']['bid'] = 'new'; $form_state['values']['op'] = t('Save'); drupal_execute($parent_node['type'] . '_node_form', $form_state, (object)$parent_node);
And repeat for the various subpages setting the various book properties so that child pages have the right parents. According to lyricnz2 on IRC (thanks!), the problem is that drupal_execute() doesn't work as expected in SimpleTest environments, as it runs against the normal database, and not the simpletest copy. Two questions then: 1) Is the original issue actually a bug, or am I abusing FAPI incorrectly? 2) Since the issue requires multiple book nodes to be inserted in one request, meaning I can't use drupalPost(), how can I write a proper test for it? It was suggested that I could create a block and run PHP in it, but I would think there has to be a better way. Thanks, --Andrew