From 5e3fca4d3b70e7f412a7e43f9fffaa3928259d8f Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 1 May 2015 09:18:37 +0800 Subject: [PATCH] MDL-50055 tests: Add new step to deal with Single Selects --- lib/tests/behat/behat_forms.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index f7a5a529e65..d9ce8ea9548 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -369,4 +369,21 @@ class behat_forms extends behat_base { $field->set_value($value); } + /** + * Select a value from single select and redirect. + * + * @Given /^I select "(?P(?:[^"]|\\")*)" from the "(?P(?:[^"]|\\")*)" singleselect$/ + */ + public function i_select_from_the_singleselect($option, $singleselect) { + $actions = array( + new Given('I set the field "' . $this->escape($singleselect) . '" to "' . $this->escape($option) . '"'), + ); + + if (!$this->running_javascript()) { + $actions[] = new Given('I press "' . get_string('go') . '"'); + } + + return $actions; + } + }