/** * Validate that the API call for obtaining the recordset of available * export fields works as expected */ public function test_version1exportreportsavailablefields() { global $CFG; $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 field without mapping record. $secondfieldid = $this->create_profile_field('rliptext2', 'text', $categoryid); // Track whether each expected record was found. $foundsecond = false; // Look through the available fields recordset. if ($recordset = rlipexport_version1_config::get_available_fields()) { foreach ($recordset as $record) { // Condition for matching the expected record. $issecond = $secondfieldid && ($record->name = 'rliptext2'); if ($issecond) { // Expected record found. $foundsecond = true; } else { // Invalid record found. $this->assertEquals(true, false); } } } else { // Problem fetching recordset. $this->assertEquals(true, false); } // Validate that the record was found. $this->assertEquals($foundsecond, true); }
//button to revert headers to last saved state $attributes = array('type' => 'submit', 'value' => get_string('revertheaders', 'dhexport_version1'), 'name' => 'revertfields'); echo html_writer::empty_tag('input', $attributes); echo $OUTPUT->spacer(null, true); echo $OUTPUT->spacer(null, true); //button to save changes to headers $attributes = array('type' => 'submit', 'value' => get_string('updateheaders', 'dhexport_version1'), 'name' => 'updatefields'); echo html_writer::empty_tag('input', $attributes); echo $OUTPUT->spacer(null, true); echo $OUTPUT->spacer(null, true); //close form echo html_writer::end_tag('form'); } //fetch all available profile fields $options = array(); if ($recordset = rlipexport_version1_config::get_available_fields()) { foreach ($recordset as $record) { $options[$record->id] = $record->name; } } if (empty($options)) { if (empty($table->data)) { echo html_writer::tag('span', get_string('profilefieldnotconfig', 'dhexport_version1')); } else { echo html_writer::tag('span', get_string('profilefieldalladded', 'dhexport_version1')); } } else { echo html_writer::tag('span', get_string('addfieldinstructions', 'dhexport_version1')); echo $OUTPUT->spacer(null, true); $displaystring = get_string('addprofilefield', 'dhexport_version1'); echo $OUTPUT->single_select($baseurl, 'field', $options, '', array('' => $displaystring));