Exemple #1
0
 /**
  * Test instantiating a form to edit a store instance.
  */
 public function test_get_edit_store_form()
 {
     $config = cache_config_writer::instance();
     $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
     $form = cache_administration_helper::get_edit_store_form('file', 'summariesstore');
     $this->assertInstanceOf('moodleform', $form);
     try {
         $form = cache_administration_helper::get_edit_store_form('somethingstupid', 'moron');
         $this->fail('You should not be able to create an edit form for a store plugin that does not exist.');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('coding_exception', $e);
     }
     try {
         $form = cache_administration_helper::get_edit_store_form('file', 'blisters');
         $this->fail('You should not be able to create an edit form for a store plugin that does not exist.');
     } catch (moodle_exception $e) {
         $this->assertInstanceOf('coding_exception', $e);
     }
 }
Exemple #2
0
            if ($notifysuccess) {
                if (!$confirm) {
                    $title = get_string('confirmlockdeletion', 'cache');
                    $params = array('lock' => $lock, 'confirm' => 1, 'action' => $action, 'sesskey' => sesskey());
                    $url = new moodle_url($PAGE->url, $params);
                    $button = new single_button($url, get_string('deletelock', 'cache'));
                    $PAGE->set_title($title);
                    $PAGE->set_heading($SITE->fullname);
                    echo $OUTPUT->header();
                    echo $OUTPUT->heading($title);
                    $confirmation = get_string('deletelockconfirmation', 'cache', $lock);
                    echo $OUTPUT->confirm($confirmation, $button, $PAGE->url);
                    echo $OUTPUT->footer();
                    exit;
                } else {
                    $writer = cache_config_writer::instance();
                    $writer->delete_lock_instance($lock);
                    redirect($PAGE->url, get_string('deletelocksuccess', 'cache'), 5);
                }
            }
            break;
    }
}
$PAGE->set_title($title);
$PAGE->set_heading($SITE->fullname);
$renderer = $PAGE->get_renderer('core_cache');
echo $renderer->header();
echo $renderer->heading($title);
if (!is_null($notification)) {
    echo $renderer->notification($notification, $notifysuccess ? 'notifysuccess' : 'notifyproblem');
}
 /**
  * Test setting some definition mappings.
  */
 public function test_set_definition_mappings()
 {
     $config = cache_config_testing::instance(true);
     $config->phpunit_add_definition('phpunit/testdefinition', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'testdefinition'));
     $config = cache_config_writer::instance();
     $this->assertTrue($config->add_store_instance('setdefinitiontest', 'file'));
     $this->assertInternalType('array', $config->get_definition_by_id('phpunit/testdefinition'));
     $config->set_definition_mappings('phpunit/testdefinition', array('setdefinitiontest', 'default_application'));
     try {
         $config->set_definition_mappings('phpunit/testdefinition', array('something that does not exist'));
         $this->fail('You should not be able to set a mapping for a store that does not exist.');
     } catch (Exception $e) {
         $this->assertInstanceOf('coding_exception', $e);
     }
     try {
         $config->set_definition_mappings('something/crazy', array('setdefinitiontest'));
         $this->fail('You should not be able to set a mapping for a definition that does not exist.');
     } catch (Exception $e) {
         $this->assertInstanceOf('coding_exception', $e);
     }
 }