Пример #1
0
 public function test_detect_plugin_component()
 {
     global $CFG;
     $installer = tool_installaddon_installer::instance();
     $zipfile = $CFG->libdir . '/tests/fixtures/update_validator/zips/bar.zip';
     $this->assertEquals('foo_bar', $installer->detect_plugin_component($zipfile));
     $zipfile = $CFG->libdir . '/tests/fixtures/update_validator/zips/invalidroot.zip';
     $this->assertFalse($installer->detect_plugin_component($zipfile));
 }
Пример #2
0
 public function test_move_directory()
 {
     $jobid = md5(rand() . uniqid('test_', true));
     $jobroot = make_temp_directory('tool_installaddon/' . $jobid);
     $contentsdir = make_temp_directory('tool_installaddon/' . $jobid . '/contents/sub/folder');
     file_put_contents($contentsdir . '/readme.txt', 'Hello world!');
     $installer = tool_installaddon_installer::instance();
     $installer->move_directory($jobroot . '/contents', $jobroot . '/moved', 0777, 0666);
     $this->assertFalse(is_dir($jobroot . '/contents'));
     $this->assertTrue(is_file($jobroot . '/moved/sub/folder/readme.txt'));
     $this->assertSame('Hello world!', file_get_contents($jobroot . '/moved/sub/folder/readme.txt'));
 }
Пример #3
0
$zipcontentpath = $CFG->tempdir.'/tool_installaddon/'.$jobid.'/contents';

if (!is_dir($zipcontentpath)) {
    debugging('Invalid location of the extracted ZIP package: '.s($zipcontentpath), DEBUG_DEVELOPER);
    redirect(new moodle_url('/admin/tool/installaddon/index.php'),
        get_string('invaliddata', 'core_error'));
}

if (!is_dir($zipcontentpath.'/'.$pluginname)) {
    debugging('Invalid location of the plugin root directory: '.$zipcontentpath.'/'.$pluginname, DEBUG_DEVELOPER);
    redirect(new moodle_url('/admin/tool/installaddon/index.php'),
        get_string('invaliddata', 'core_error'));
}

$installer = tool_installaddon_installer::instance();

if (!$installer->is_plugintype_writable($plugintype)) {
    debugging('Plugin type location not writable', DEBUG_DEVELOPER);
    redirect(new moodle_url('/admin/tool/installaddon/index.php'),
        get_string('invaliddata', 'core_error'));
}

$plugintypepath = $installer->get_plugintype_root($plugintype);

if (file_exists($plugintypepath.'/'.$pluginname)) {
    debugging('Target location already exists', DEBUG_DEVELOPER);
    redirect(new moodle_url('/admin/tool/installaddon/index.php'),
        get_string('invaliddata', 'core_error'));
}
Пример #4
0
 public function test_detect_plugin_component()
 {
     $jobid = md5(rand() . uniqid('test_', true));
     $workdir = make_temp_directory('tool_installaddon/' . $jobid . '/version');
     $zipfile = __DIR__ . '/fixtures/zips/bar.zip';
     $installer = tool_installaddon_installer::instance();
     $this->assertEquals('foo_bar', $installer->detect_plugin_component($zipfile, $workdir));
 }