I am trying to write a SimpleTest for a form that already exists. The form passes tests for GET, valid HTML and having the select element, which looks like this:
<select id="edit-buid" name="buid" class="form-select"> <option value="1">New Business Unit</option> </select>
The relevant code from my test case is:
$this->drupalGet('path/to/form'); $this->assertFieldByName('buid', NULL, 'form has buid field'); $edit = array( 'buid' => 1, ); $this->drupalPost('path/to/form', $edit, t('Save'));
I have tried passing the string "1" and array(1) and array("1") as well, but the test always fails with:
"Failed to set field buid to 1"
How can I make the test pass with the correct option selected?