Details
-
Type:
Improvement
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.5
-
Component/s: Forms Library, Unit tests
-
Labels:
-
Testing Instructions:
-
Affected Branches:MOODLE_25_STABLE
-
Fixed Branches:MOODLE_24_STABLE, MOODLE_25_STABLE
-
Epic Link:
-
Pull from Repository:
-
Pull Master Branch:wip_
MDL-40176_v4 -
Pull Master Diff URL:
-
Documentation link:
Description
A mock_submit method should make the form behave as if a submit button has been pressed and get_data should then return all the values as passed into the form from set_data and setDefault etc. So that we could perform the following integration test for example :
$questiondata = test_question_maker::get_question_data('multichoice', 'single');
|
$expectedfromform = test_question_maker::get_question_form_data('multichoice', 'single');
|
$form = new qtype_multichoice_edit_form(...);
|
$form->set_data($questiondata);
|
$form->mock_submit();
|
$actualfromform = $form->get_data();
|
$this->assertEquals($expectedfromform, $actualfromform);
|
save_question($actualfromform);
|
$actualquestiondata = question_load_questions(array($actualfromform->id));
|
$this->assertEquals($questiondata, $actualquestiondata);
|