19th May 2011 - 5 minutes read time
Sometimes the most complex part of using SimpleTest is making sure that everything is working as it should before you start your tests. This means setting up the correct modules and creating the correct content types in advance. Because SimpleTest works by issuing CURL requests to pages the most reliable way of doing certain tasks is to use the administration forms as you normally would. Taking an example, if you want to enable a block from a module you should submit the block form, adding the blocks you need to the various different regions this like.
// Enable the different blocks
$blocks = array(
'my_awesome_block' => 'header'
);
$this->drupalPost('admin/build/block', $blocks, 'Save blocks');
However, if you haven't given the current user 'administer blocks' access, or have forgotten to log them in, then you will get an access denied error when you try to do this.