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

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

XMLWordPrintable

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

            jamiesensei Jamie Pratt (Inactive)
            jamiesensei Jamie Pratt (Inactive)
            Petr Skoda Petr Skoda
            Damyon Wiese Damyon Wiese
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.