/** * Validate that the API call for moving a profile field down in export * position deals with deleted user profile fields correctly */ public function test_version1exporthandlesdeletedfieldswhenmovingdown() { global $CFG, $DB; $file = get_plugin_directory('dhexport', 'version1') . '/lib.php'; require_once $file; // Set up the category and field, along with the export mapping. $categoryid = $this->create_custom_field_category(); $firstfieldid = $this->create_profile_field('rliptext', 'text', $categoryid); $this->create_field_mapping($firstfieldid); // Set up a second mapping record without a field. $secondfieldid = 9999; $this->create_field_mapping($secondfieldid, 'Header2', 2); // Set up a third field with a mapping record. $thirdfieldid = $this->create_profile_field('rliptext3', 'text', $categoryid); $this->create_field_mapping($thirdfieldid, 'Header3', 3); // Move the first field down. $id = $DB->get_field(RLIPEXPORT_VERSION1_FIELD_TABLE, 'id', array('fieldid' => $firstfieldid)); rlipexport_version1_config::move_field($id, rlipexport_version1_config::DIR_DOWN); // Validate that the first and third fields swapped, ignoring the second field. $this->assert_record_exists(RLIPEXPORT_VERSION1_FIELD_TABLE, array('fieldid' => $firstfieldid, 'fieldorder' => 3)); $this->assert_record_exists(RLIPEXPORT_VERSION1_FIELD_TABLE, array('fieldid' => $thirdfieldid, 'fieldorder' => 1)); }