I have a form with several sets of multi-value checkboxes and a text field. These inputs are used to build a query.
<input class="entry" name="search_text" />
<input type="checkbox" name="arrSource[pn_oem]" value="pn_oem" />
<input type="checkbox" name="arrSource[descr]" value="descr" />
<input type="checkbox" name="arrSource[supplier_pn]" value="supplier_pn" />
<!--- etc -->
<input type="checkbox" name="arrSupplier[]" value="307" /> Adam
<input type="checkbox" name="arrSupplier[]" value="113" /> Alan
<input type="checkbox" name="arrSupplier[]" value="2" /> Alex
<input type="checkbox" name="arrSupplier[]" value="3" /> Archie
<!--- etc -->
<input class="submit" value="Search" type="submit" name="Search" />
<input class="submit" value="Reset" type="submit" name="Reset" />
I've been testing the form by running a search and comparing the results with my own SQL on the database. It seems to work perfectly. But I haven't been able to get SimpleTest to agree (following these somewhat sparse instructions). The form submittal looks like this:
$this->setField('arrSource[]', array("supplier_pn", "pn_oem"));
$this->setField('arrSupplier[]', array(15,92));
$this->setField('search_text', "pax");
$this->click('Search');
SimpleTest produces a result of 2 but other methods say 9. Here are some variations:
2 but should be 9: setField('arrSource[]', array("supplier_pn", "pn_oem"));
2 but should be 0: setField('arrSource[]', array("pn_oem"));
23 but should be 2: setField('arrSource[]', array("supplier_pn"));
I was able to make the UI show 2 results by setting no Supplier criteria and Source criteria as 'pn_oem' only. This is equivalent to un-checking all the checkboxes, because the query assumes pn_oem
is wanted if nothing is checked for Source. Here's how that looks in SimpleTest -- and SimpleTest agreed on a result of 2:
$this->setField('arrSource[]', array("pn_oem"));
$this->setField('search_text', "pax");
$this->click('Search');
It appears I'm signaling to SimpleTest that I don't want any checkboxes. However, I've built other tests using other sets of multi-value checkboxes on this same form. They don't have this problem.
Your thoughts?