mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
Merge branch 'MDL-59669-master-3' of git://github.com/ryanwyllie/moodle
This commit is contained in:
commit
f0e6ff9a8e
5 changed files with 818 additions and 1 deletions
|
@ -1390,6 +1390,27 @@ abstract class moodleform {
|
|||
$_POST = $simulatedsubmitteddata;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by tests to generate valid submit keys for moodle forms that are
|
||||
* submitted with ajax data.
|
||||
*
|
||||
* @throws \moodle_exception If called outside unit test environment
|
||||
* @param array $data Existing form data you wish to add the keys to.
|
||||
* @return array
|
||||
*/
|
||||
public static function mock_generate_submit_keys($data = []) {
|
||||
if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) {
|
||||
throw new \moodle_exception("This function can only be used for unit testing.");
|
||||
}
|
||||
|
||||
$formidentifier = get_called_class();
|
||||
$formidentifier = str_replace('\\', '_', $formidentifier); // See MDL-56233 for more information.
|
||||
$data['sesskey'] = sesskey();
|
||||
$data['_qf__' . $formidentifier] = 1;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue