mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-43156 core_form: fix handling of fixture form
Also moving it from behat_forms to behat_navigation
This commit is contained in:
parent
5079271b39
commit
9da975fe21
@ -18,6 +18,7 @@
|
||||
* Test form repeat elements + defaults
|
||||
*
|
||||
* @copyright 2020 Davo Smith, Synergy Learning
|
||||
* @package core_form
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@ -27,10 +28,18 @@ defined('BEHAT_SITE_RUNNING') || die();
|
||||
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
$PAGE->set_url('/lib/form/tests/behat/fixtures/formtest.php');
|
||||
$PAGE->set_url('/lib/form/tests/behat/fixtures/repeat_defaults_form.php');
|
||||
require_login();
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
/**
|
||||
* Class repeat_defaults_form
|
||||
* @package core_form
|
||||
*/
|
||||
class repeat_defaults_form extends moodleform {
|
||||
/**
|
||||
* Form definition
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
$repeatcount = $this->_customdata['repeatcount'];
|
||||
|
@ -1,8 +1,9 @@
|
||||
@core_form @javascript
|
||||
@core_form
|
||||
Feature: Newly created repeat elements have the correct default values
|
||||
|
||||
Scenario: Clicking button to add repeat elements creates repeat elements with the correct default values
|
||||
Given I am on the repeat defaults form page
|
||||
Given I log in as "admin"
|
||||
And I am on fixture page "/lib/form/tests/behat/fixtures/repeat_defaults_form.php"
|
||||
When I press "Add repeats"
|
||||
Then the following fields match these values:
|
||||
| testcheckbox[1] | 1 |
|
||||
|
@ -731,13 +731,4 @@ class behat_forms extends behat_base {
|
||||
$node = $this->get_node_in_container('xpath_element', $xpathtarget, 'form_row', $field);
|
||||
$this->ensure_node_is_visible($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit the fixture page for testing repeat defaults.
|
||||
* @Given /^I am on the repeat defaults form page$/
|
||||
*/
|
||||
public function i_am_on_the_repeat_defaults_form_page() {
|
||||
$url = new moodle_url('/lib/form/tests/behat/fixtures/repeat_defaults_form.php');
|
||||
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
|
||||
}
|
||||
}
|
||||
|
@ -962,4 +962,21 @@ class behat_navigation extends behat_base {
|
||||
throw new ElementNotFoundException($this->getSession(),
|
||||
'Link "' . join(' > ', $nodelist) . '" in the current page edit menu"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit a fixture page for testing stuff that is not available in core.
|
||||
*
|
||||
* Please always, to prevent unwanted requests, protect behat fixture files with:
|
||||
* defined('BEHAT_SITE_RUNNING') || die();
|
||||
*
|
||||
* @Given /^I am on fixture page "(?P<url_string>(?:[^"]|\\")*)"$/
|
||||
* @param string $url local path to fixture page
|
||||
*/
|
||||
public function i_am_on_fixture_page($url) {
|
||||
$fixtureregex = '|^/[a-z0-9_\-/]*/tests/behat/fixtures/[a-z0-9_\-]*\.php$|';
|
||||
if (!preg_match($fixtureregex, $url)) {
|
||||
throw new coding_exception("URL {$url} is not a fixture URL");
|
||||
}
|
||||
$this->getSession()->visit($this->locate_path($url));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user