コード例 #1
0
 /**
  * Test saving the minimum and max year settings for the user datetime field.
  *
  * @param string $type the calendar type we want to test
  * @param array $date the date variables
  */
 private function datetime_field_submission_test($type, $date)
 {
     $this->set_calendar_type($type);
     // Get the data we are submitting for the form.
     $formdata = array();
     $formdata['id'] = 0;
     $formdata['shortname'] = 'Shortname';
     $formdata['name'] = 'Name';
     $formdata['param1'] = $date['inputminyear'];
     $formdata['param2'] = $date['inputmaxyear'];
     // Mock submitting this.
     field_form::mock_submit($formdata);
     // Create the user datetime form.
     $form = new field_form(null, 'datetime');
     // Get the data from the submission.
     $submissiondata = $form->get_data();
     // On the user profile field page after get_data, the function define_save is called
     // in the field base class, which then calls the field's function define_save_preprocess.
     $field = new profile_define_datetime();
     $submissiondata = $field->define_save_preprocess($submissiondata);
     // Create an array we want to compare with the date passed.
     $comparedate = $date;
     $comparedate['expectedminyear'] = $submissiondata->param1;
     $comparedate['expectedmaxyear'] = $submissiondata->param2;
     $this->assertEquals($comparedate, $date);
 }