/**
  * Validate that the method to get tabs works correctly
  *
  * @param $index Position in the tabs array to use
  * @param $entitytype The type of entity that tab represents
  *
  * @dataProvider gettabsprovider
  */
 public function test_gettabsreturnsvalidobjects($index, $entitytype)
 {
     global $CFG;
     // Get collection of tabs.
     $baseurl = 'base';
     $tabs = rlipimport_version1_get_tabs($baseurl);
     $this->assertEquals(count($tabs), 3);
     // The string displayed on the tab.
     $displaystring = get_string($entitytype . 'tab', 'dhimport_version1');
     // Data validation.
     $tab = $tabs[$index];
     $this->assertEquals($tab->link->out(), $baseurl . '?tab=' . $entitytype);
     $this->assertEquals($tab->text, $displaystring);
     $this->assertEquals($tab->title, $displaystring);
 }
示例#2
0
$plugindir = get_plugin_directory('dhimport', 'version1');
require_once $plugindir . '/version1.class.php';
require_once $plugindir . '/lib.php';
require_once $CFG->dirroot . '/local/datahub/form/rlip_importfield_form.class.php';
//permissions checking
require_login();
$context = context_system::instance();
require_capability('moodle/site:config', $context);
$pluginwwwroot = str_replace($CFG->dirroot, $CFG->wwwroot, $plugindir);
$baseurl = $pluginwwwroot . '/config_fields.php';
$tab = optional_param('tab', 'user', PARAM_CLEAN);
//page header
rlipimport_version1_page_setup($baseurl);
echo $OUTPUT->header();
//tabs
$tabs = rlipimport_version1_get_tabs($baseurl);
print_tabs(array($tabs), $tab);
//data from db
$mappingdata = rlipimport_version1_get_mapping($tab);
//options
$plugin = new rlip_importplugin_version1(NULL, false);
$options = $plugin->get_available_fields($tab);
//body
$form = new rlip_importfield_form(null, $options);
//handle data submission
if ($data = $form->get_data()) {
    if (isset($data->submitbutton)) {
        rlipimport_version1_save_mapping($tab, $options, $data);
        //notify to the user that settings were saved
        echo $OUTPUT->heading(get_string('mappingssaved', 'dhimport_version1'));
    } else {