MDL-53848 forms: additions to the behat test
This commit is contained in:
committed by
Davo Smith
parent
d20498625c
commit
f3da329da4
@@ -15,38 +15,52 @@ Feature: hideIf functionality in forms
|
||||
When I set the field "Select yesno example" to "Yes"
|
||||
Then I should see "Test eq hideif"
|
||||
And "#id_testeqhideif" "css_element" should be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 6"
|
||||
And I should see "[testeqhideif] =>"
|
||||
|
||||
Scenario: When 'eq' hideIf conditions are met, the relevant elements are hidden
|
||||
When I set the field "Select yesno example" to "No"
|
||||
Then I should not see "Test eq hideif"
|
||||
And "#id_testeqhideif" "css_element" should not be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 5"
|
||||
And I should not see "[testeqhideif] =>"
|
||||
|
||||
Scenario: When 'checked' hideIf conditions are not met, the relevant elements are shown
|
||||
When I set the field "Checkbox example" to "0"
|
||||
Then I should see "Test checked hideif"
|
||||
And I should not see "Test not checked hideif"
|
||||
And "#id_testcheckedhideif" "css_element" should be visible
|
||||
And "#id_testnotcheckedhideif" "css_element" should not be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 5"
|
||||
And I should see "[testcheckedhideif] =>"
|
||||
And I should not see "[testnotcheckedhideif] =>"
|
||||
|
||||
Scenario: When 'checked' hideIf conditions are met, the relevant elements are hidden
|
||||
When I set the field "Checkbox example" to "1"
|
||||
Then I should not see "Test checked hideif"
|
||||
And I should see "Test not checked hideif"
|
||||
And "#id_testcheckedhideif" "css_element" should not be visible
|
||||
|
||||
Scenario: When 'notchecked' hideIf conditions are not met, the relevant elements are shown
|
||||
When I set the field "Checkbox example" to "1"
|
||||
Then I should see "Test not checked hideif"
|
||||
And "#id_testnotcheckedhideif" "css_element" should be visible
|
||||
|
||||
Scenario: When 'notchecked' hideIf conditions are met, the relevant elements are hidden
|
||||
When I set the field "Checkbox example" to "0"
|
||||
Then I should not see "Test not checked hideif"
|
||||
And "#id_testnotcheckedhideif" "css_element" should not be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 5"
|
||||
And I should not see "[testcheckedhideif] =>"
|
||||
And I should see "[testnotcheckedhideif] =>"
|
||||
|
||||
Scenario: When 'in' hideIf conditions are not met, the relevant elements are shown
|
||||
When I set the field "Select example" to "3"
|
||||
Then I should see "Test in hideif"
|
||||
And "#id_testinhideif" "css_element" should be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 6"
|
||||
And I should see "[testinhideif] =>"
|
||||
|
||||
Scenario: When 'in' hideIf conditions are met, the relevant elements are hidden
|
||||
When I set the field "Select example" to "2"
|
||||
Then I should not see "Test in hideif"
|
||||
And "#id_testinhideif" "css_element" should not be visible
|
||||
And I press "Submit"
|
||||
And I should see "Number of submitted form elements: 5"
|
||||
And I should not see "[testinhideif] =>"
|
||||
|
||||
+8
-2
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../../config.php');
|
||||
require_once(__DIR__.'/../../../../config.php');
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
@@ -71,13 +71,19 @@ class hideif_form extends moodleform {
|
||||
$mform->addElement('text', 'testinhideif', 'Test in hideif');
|
||||
$mform->setType('testinhideif', PARAM_TEXT);
|
||||
$mform->hideIf('testinhideif', 'selectexample', 'in', [1, 2, 5]);
|
||||
|
||||
$mform->addElement('submit', 'submitform', 'Submit');
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_url('/lib/tests/fixtures/form_hideif.php');
|
||||
$PAGE->set_url('/lib/form/tests/fixtures/formhideiftestpage.php');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$form = new hideif_form();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($data = $form->get_data()) {
|
||||
echo "<p>Number of submitted form elements: " . count((array)$data) . "</p>";
|
||||
print_object($data);
|
||||
}
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+2
-2
@@ -2448,7 +2448,7 @@ require(["core/event", "jquery"], function(Event, $) {
|
||||
if ($element == $dependentOn) {
|
||||
continue;
|
||||
}
|
||||
$result[$dependentOn][$condition][$value][0][] = $element;
|
||||
$result[$dependentOn][$condition][$value][self::DEP_DISABLE][] = $element;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2470,7 +2470,7 @@ require(["core/event", "jquery"], function(Event, $) {
|
||||
if ($element == $dependenton) {
|
||||
continue;
|
||||
}
|
||||
$result[$dependenton][$condition][$value][1][] = $element;
|
||||
$result[$dependenton][$condition][$value][self::DEP_HIDE][] = $element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user