Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-40176

introduce $form->mock_submit(); method to test form submission

    Details

      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);
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    9/Sep/13