protected function RoboFile::submitForm in Panopoly 7
Uses Mink to submit a form.
Parameters
\Behat\Mink\Element\DocumentElement $page: The page via Mink.
string $form_id: The form id.
string[] $values: The values to set.
string $op: The ID or value of the button to press.
Throws
\Behat\Mink\Exception\ElementNotFoundException
2 calls to RoboFile::submitForm()
- RoboFile::createRelease in ./
RoboFile.php - Uses Mink to create a release on Drupal.org.
- RoboFile::releasePublish in ./
RoboFile.php - Release Stage 3: Publishes new releases on Drupal.org.
File
- ./
RoboFile.php, line 843
Class
- RoboFile
- This is project's console commands configuration for Robo task runner.
Code
protected function submitForm(\Behat\Mink\Element\DocumentElement $page, $form_id, array $values, $op) {
$form = $page
->findById($form_id);
if (!$form) {
throw new \Exception("Couldn't find form with id: {$form_id}");
}
foreach ($values as $name => $value) {
if ($field = $form
->findField($name)) {
if ($field
->getTagName() === 'select') {
$field
->selectOption($value);
}
else {
$field
->setValue($value);
}
}
else {
// We let individual fields fail, since some are not present depending
// on configuration.
//throw new \Exception("Couldn't find field with name: $name");
}
}
$button = $form
->findButton($op);
if (!$button) {
throw new \Exception("Unable to find button {$op} on {$form_id}");
}
$button
->click();
}