mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-15666 MDL-16177
Refactored the generator script into proper Object Oriented code. It can now be used as a CLI tool, as a web form or as an included library with a function call. Stub implementation is demonstrated in portfolio unit tests.
This commit is contained in:
parent
d3919c2551
commit
7e95408b01
1190
admin/generator.php
1190
admin/generator.php
File diff suppressed because it is too large
Load Diff
@ -129,13 +129,17 @@ class portfoliolib_test extends UnitTestCase {
|
||||
$DB->delete_records('portfolio_tempdata', array('id' => $this->exporter->get('id')));
|
||||
$fs = get_file_storage();
|
||||
$fs->delete_area_files(SYSCONTEXTID, 'portfolio_exporter', $this->exporter->get('id'));
|
||||
|
||||
$settings = array('no_data' => 1, 'post_cleanup' => 1, 'database_prefix' => 'tst_', 'quiet' => 1);
|
||||
generator_generate_data($settings);
|
||||
}
|
||||
|
||||
function test_construct_dupe_instance() {
|
||||
$gotexception = false;
|
||||
try {
|
||||
portfolio_plugin_base::create_instance('download', 'download1', array());
|
||||
portfolio_plugin_base::create_instance('download', 'download2', array());
|
||||
$plugin1 = portfolio_plugin_base::create_instance('download', 'download1', array());
|
||||
$plugin2 = portfolio_plugin_base::create_instance('download', 'download2', array());
|
||||
$test1 = new portfolio_plugin_download($plugin1->get('id'));
|
||||
} catch (portfolio_exception $e) {
|
||||
$this->assertEqual('multipledisallowed', $e->errorcode);
|
||||
$gotexception = true;
|
||||
|
@ -4,7 +4,7 @@ require_once($CFG->dirroot.'/repository/boxnet/boxlibphp5.php');
|
||||
|
||||
class portfolio_plugin_boxnet extends portfolio_plugin_push_base {
|
||||
|
||||
private $boxclient;
|
||||
public $boxclient;
|
||||
private $ticket;
|
||||
private $authtoken;
|
||||
private $folders;
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php // $Id$
|
||||
require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
|
||||
require_once($CFG->dirroot.'/portfolio/type/boxnet/lib.php');
|
||||
require_once($CFG->dirroot.'/admin/generator.php');
|
||||
|
||||
Mock::generate('boxclient', 'mock_boxclient');
|
||||
Mock::generatePartial('portfolio_plugin_boxnet', 'mock_boxnetplugin', array('ensure_ticket', 'ensure_account_tree'));
|
||||
@ -10,6 +11,8 @@ class testPortfolioPluginBoxnet extends portfoliolib_test {
|
||||
parent::setUp();
|
||||
$this->plugin = &new mock_boxnetplugin($this);
|
||||
$this->plugin->boxclient = new mock_boxclient();
|
||||
$settings = array('tiny' => 1, 'quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1);
|
||||
generator_generate_data($settings);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
|
21
portfolio/type/download/simpletest/testportfolioplugindownload.php
Executable file
21
portfolio/type/download/simpletest/testportfolioplugindownload.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php // $Id$
|
||||
require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
|
||||
require_once($CFG->dirroot.'/portfolio/type/download/lib.php');
|
||||
|
||||
Mock::generate('boxclient', 'mock_boxclient');
|
||||
Mock::generatePartial('portfolio_plugin_download', 'mock_downloadplugin', array('ensure_ticket', 'ensure_account_tree'));
|
||||
|
||||
|
||||
class testPortfolioPluginDownload extends portfoliolib_test {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->plugin = &new mock_boxnetplugin($this);
|
||||
$this->plugin->boxclient = new mock_boxclient();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
42
portfolio/type/flickr/lib.php
Executable file
42
portfolio/type/flickr/lib.php
Executable file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->dirroot.'/repository/flickr/phpFlickr.php');
|
||||
|
||||
class portfolio_plugin_flickr extends portfolio_plugin_push_base {
|
||||
|
||||
private $flickr;
|
||||
|
||||
public function prepare_package() {
|
||||
$this->flickr = new phpFlickr($this->get_config('apikey'), $this->get_config('sharedsecret'));
|
||||
return true; // don't do anything else for this plugin, we want to send all files as they are.
|
||||
}
|
||||
|
||||
public function send_package() {
|
||||
|
||||
}
|
||||
|
||||
public function get_continue_url() {
|
||||
return 'http://www.flickr.com/files#0:f:' . $this->get_export_config('folder');
|
||||
}
|
||||
|
||||
public function expected_time($callertime) {
|
||||
return $callertime;
|
||||
}
|
||||
|
||||
public static function get_allowed_config() {
|
||||
return array('apikey', 'sharedsecret');
|
||||
}
|
||||
|
||||
public static function has_admin_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function admin_config_form(&$mform) {
|
||||
$strrequired = get_string('required');
|
||||
$mform->addElement('text', 'apikey', get_string('apikey', 'portfolio_flickr'));
|
||||
$mform->addRule('apikey', $strrequired, 'required', null, 'client');
|
||||
$mform->addElement('text', 'sharedsecret', get_string('sharedsecret', 'portfolio_flickr'));
|
||||
$mform->addRule('sharedsecret', $strrequired, 'required', null, 'client');
|
||||
}
|
||||
|
||||
}
|
7
portfolio/type/flickr/version.php
Executable file
7
portfolio/type/flickr/version.php
Executable file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2008072500;
|
||||
$plugin->requires = 2008072500;
|
||||
$plugin->cron = 0;
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user