mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 05:28:30 +01:00
MDL-39477 repository: Introducing data generators for repositories
This commit is contained in:
parent
73f560c7b2
commit
9b5e61ac1e
@ -555,6 +555,37 @@ EOD;
|
||||
return groups_assign_grouping($record['groupingid'], $record['groupid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a repository.
|
||||
*
|
||||
* @param string type of repository to create an instance for.
|
||||
* @param array|stdClass $record data to use to up set the instance.
|
||||
* @param array $options options
|
||||
* @return stdClass repository instance record
|
||||
* @since 2.6
|
||||
*/
|
||||
public function create_repository($type, $record=null, array $options = null) {
|
||||
global $CFG;
|
||||
$generator = $this->get_plugin_generator('repository_'.$type);
|
||||
return $generator->create_instance($record, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of a repository.
|
||||
*
|
||||
* @param string type of repository to create an instance for.
|
||||
* @param array|stdClass $record data to use to up set the instance.
|
||||
* @param array $options options
|
||||
* @return repository_type object
|
||||
* @since 2.6
|
||||
*/
|
||||
public function create_repository_type($type, $record=null, array $options = null) {
|
||||
global $CFG;
|
||||
$generator = $this->get_plugin_generator('repository_'.$type);
|
||||
return $generator->create_type($record, $options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a test scale
|
||||
* @param array|stdClass $record
|
||||
|
@ -29,4 +29,5 @@ require_once(__DIR__.'/data_generator.php');
|
||||
require_once(__DIR__.'/component_generator_base.php');
|
||||
require_once(__DIR__.'/module_generator.php');
|
||||
require_once(__DIR__.'/block_generator.php');
|
||||
require_once(__DIR__.'/repository_generator.php');
|
||||
|
||||
|
191
lib/testing/generator/repository_generator.php
Normal file
191
lib/testing/generator/repository_generator.php
Normal file
@ -0,0 +1,191 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Repository data generator
|
||||
*
|
||||
* @package repository
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Repository data generator class
|
||||
*
|
||||
* @package core
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 2.6
|
||||
*/
|
||||
class testing_repository_generator extends component_generator_base {
|
||||
|
||||
/**
|
||||
* Number of instances created
|
||||
* @var int
|
||||
*/
|
||||
protected $instancecount = 0;
|
||||
|
||||
/**
|
||||
* To be called from data reset code only,
|
||||
* do not use in tests.
|
||||
* @return void
|
||||
*/
|
||||
public function reset() {
|
||||
$this->instancecount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns repository type name
|
||||
*
|
||||
* @return string name of the type of repository
|
||||
* @throws coding_exception if class invalid
|
||||
*/
|
||||
public function get_typename() {
|
||||
$matches = null;
|
||||
if (!preg_match('/^repository_([a-z0-9_]+)_generator$/', get_class($this), $matches)) {
|
||||
throw new coding_exception('Invalid repository generator class name: '.get_class($this));
|
||||
}
|
||||
if (empty($matches[1])) {
|
||||
throw new coding_exception('Invalid repository generator class name: '.get_class($this));
|
||||
}
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
if (!isset($record['name'])) {
|
||||
$record['name'] = $this->get_typename() . ' ' . $this->instancecount;
|
||||
}
|
||||
if (!isset($record['contextid'])) {
|
||||
$record['contextid'] = context_system::instance()->id;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
if (!isset($record['pluginname'])) {
|
||||
$record['pluginname'] = '';
|
||||
}
|
||||
if (!isset($record['enableuserinstances'])) {
|
||||
$record['enableuserinstances'] = 1;
|
||||
}
|
||||
if (!isset($record['enablecourseinstances'])) {
|
||||
$record['enablecourseinstances'] = 1;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test repository instance.
|
||||
*
|
||||
* @param array|stdClass $record
|
||||
* @param array $options
|
||||
* @return stdClass repository instance record
|
||||
*/
|
||||
public function create_instance($record = null, array $options = null) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
|
||||
$this->instancecount++;
|
||||
$record = (array) $record;
|
||||
|
||||
$typeid = $DB->get_field('repository', 'id', array('type' => $this->get_typename()), MUST_EXIST);
|
||||
$instanceoptions = repository::static_function($this->get_typename(), 'get_instance_option_names');
|
||||
|
||||
if (empty($instanceoptions)) {
|
||||
// There can only be one instance of this repository, and it should have been created along with the type.
|
||||
$id = $DB->get_field('repository_instances', 'id', array('typeid' => $typeid), MUST_EXIST);
|
||||
} else {
|
||||
// Create the new instance, but first make sure all the required parameters are set.
|
||||
$record = $this->prepare_record($record);
|
||||
|
||||
if (empty($record['contextid'])) {
|
||||
throw new coding_exception('contextid must be present in testing_repository_generator::create_instance() $record');
|
||||
}
|
||||
|
||||
foreach ($instanceoptions as $option) {
|
||||
if (!isset($record[$option])) {
|
||||
throw new coding_exception("$option must be present in testing_repository_generator::create_instance() \$record");
|
||||
}
|
||||
}
|
||||
|
||||
$context = context::instance_by_id($record['contextid']);
|
||||
unset($record['contextid']);
|
||||
if (!in_array($context->contextlevel, array(CONTEXT_SYSTEM, CONTEXT_COURSE, CONTEXT_USER))) {
|
||||
throw new coding_exception('Wrong contextid passed in testing_repository_generator::create_instance() $record');
|
||||
}
|
||||
|
||||
$id = repository::static_function($this->get_typename(), 'create', $this->get_typename(), 0, $context, $record);
|
||||
}
|
||||
|
||||
return $DB->get_record('repository_instances', array('id' => $id), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the type of repository.
|
||||
*
|
||||
* @param stdClass|array $record data to use to set up the type
|
||||
* @param array $options options for the set up of the type
|
||||
*
|
||||
* @return stdClass repository type record
|
||||
*/
|
||||
public function create_type($record = null, array $options = null) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
|
||||
$record = (array) $record;
|
||||
$type = $this->get_typename();
|
||||
|
||||
$typeoptions = repository::static_function($type, 'get_type_option_names');
|
||||
$instanceoptions = repository::static_function($type, 'get_instance_option_names');
|
||||
|
||||
// The type allow for user and course instances.
|
||||
if (!empty($instanceoptions)) {
|
||||
$typeoptions[] = 'enableuserinstances';
|
||||
$typeoptions[] = 'enablecourseinstances';
|
||||
}
|
||||
|
||||
// Make sure all the parameters are set.
|
||||
$record = $this->prepare_type_record($record);
|
||||
foreach ($typeoptions as $option) {
|
||||
if (!isset($record[$option])) {
|
||||
throw new coding_exception("$option must be present in testing::create_repository_type() $record");
|
||||
}
|
||||
}
|
||||
|
||||
// Limit to allowed options.
|
||||
$record = array_intersect_key($record, array_flip($typeoptions));
|
||||
|
||||
// Create the type.
|
||||
$plugintype = new repository_type($type, $record);
|
||||
$plugintype->create(false);
|
||||
|
||||
return $DB->get_record('repository', array('type' => $type));
|
||||
}
|
||||
}
|
50
repository/alfresco/tests/generator/lib.php
Normal file
50
repository/alfresco/tests/generator/lib.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Alfresco repository data generator
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alfresco repository data generator class
|
||||
*
|
||||
* @package repository_alfresco
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_alfresco_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
$record = parent::prepare_record($record);
|
||||
if (!isset($record['alfresco_url'])) {
|
||||
$record['alfresco_url'] = 'http://no.where.com/alfresco/api';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
50
repository/boxnet/tests/generator/lib.php
Normal file
50
repository/boxnet/tests/generator/lib.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Box.net repository data generator
|
||||
*
|
||||
* @package repository_boxnet
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Box.net repository data generator class
|
||||
*
|
||||
* @package repository_boxnet
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_boxnet_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['api_key'])) {
|
||||
$record['api_key'] = 'api_key';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
35
repository/coursefiles/tests/generator/lib.php
Normal file
35
repository/coursefiles/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Course files repository data generator
|
||||
*
|
||||
* @package repository_coursefiles
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Course files repository data generator class
|
||||
*
|
||||
* @package repository_coursefiles
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_coursefiles_generator extends testing_repository_generator {
|
||||
}
|
56
repository/dropbox/tests/generator/lib.php
Normal file
56
repository/dropbox/tests/generator/lib.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Dropbox repository data generator
|
||||
*
|
||||
* @package repository_dropbox
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dropbox repository data generator class
|
||||
*
|
||||
* @package repository_dropbox
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_dropbox_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['dropbox_key'])) {
|
||||
$record['dropbox_key'] = 'key';
|
||||
}
|
||||
if (!isset($record['dropbox_secret'])) {
|
||||
$record['dropbox_secret'] = 'secret';
|
||||
}
|
||||
if (!isset($record['dropbox_cachelimit'])) {
|
||||
$record['dropbox_cachelimit'] = 0;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
62
repository/equella/tests/generator/lib.php
Normal file
62
repository/equella/tests/generator/lib.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Equella repository data generator
|
||||
*
|
||||
* @package repository_equella
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Equella repository data generator class
|
||||
*
|
||||
* @package repository_equella
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_equella_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
$record = parent::prepare_record($record);
|
||||
if (!isset($record['equella_url'])) {
|
||||
$record['equella_url'] = 'http://dummy.url.com';
|
||||
}
|
||||
if (!isset($record['equella_select_restriction'])) {
|
||||
$record['equella_select_restriction'] = 'none';
|
||||
}
|
||||
if (!isset($record['equella_options'])) {
|
||||
$record['equella_options'] = '';
|
||||
}
|
||||
if (!isset($record['equella_shareid'])) {
|
||||
$record['equella_shareid'] = 'id';
|
||||
}
|
||||
if (!isset($record['equella_sharesecret'])) {
|
||||
$record['equella_url'] = 'secret';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
50
repository/filesystem/tests/generator/lib.php
Normal file
50
repository/filesystem/tests/generator/lib.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File system repository data generator
|
||||
*
|
||||
* @package repository_filesystem
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* File system repository data generator class
|
||||
*
|
||||
* @package repository_filesystem
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_filesystem_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
$record = parent::prepare_record($record);
|
||||
if (!isset($record['fs_path'])) {
|
||||
$record['fs_path'] = '/i/do/not/exist';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
53
repository/flickr/tests/generator/lib.php
Normal file
53
repository/flickr/tests/generator/lib.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Flickr repository data generator
|
||||
*
|
||||
* @package repository_flickr
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Flickr repository data generator class
|
||||
*
|
||||
* @package repository_flickr
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_flickr_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['api_key'])) {
|
||||
$record['api_key'] = 'api_key';
|
||||
}
|
||||
if (!isset($record['secret'])) {
|
||||
$record['secret'] = 'secret';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
67
repository/flickr_public/tests/generator/lib.php
Normal file
67
repository/flickr_public/tests/generator/lib.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Flickr Public repository data generator
|
||||
*
|
||||
* @package repository_flickr_public
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Flickr Public repository data generator class
|
||||
*
|
||||
* @package repository_flickr_public
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_flickr_public_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
$record = parent::prepare_record($record);
|
||||
if (!isset($record['email_address'])) {
|
||||
$record['email_address'] = '';
|
||||
}
|
||||
if (!isset($record['usewatermarks'])) {
|
||||
$record['usewatermarks'] = 0;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['api_key'])) {
|
||||
$record['api_key'] = 'api_key';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
53
repository/googledocs/tests/generator/lib.php
Normal file
53
repository/googledocs/tests/generator/lib.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Google Docs repository data generator
|
||||
*
|
||||
* @package repository_googledocs
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Google Docs repository data generator class
|
||||
*
|
||||
* @package repository_googledocs
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_googledocs_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['clientid'])) {
|
||||
$record['clientid'] = 'clientid';
|
||||
}
|
||||
if (!isset($record['secret'])) {
|
||||
$record['secret'] = 'secret';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
35
repository/local/tests/generator/lib.php
Normal file
35
repository/local/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Local repository data generator
|
||||
*
|
||||
* @package repository_local
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Local repository data generator class
|
||||
*
|
||||
* @package repository_local
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_local_generator extends testing_repository_generator {
|
||||
}
|
50
repository/merlot/tests/generator/lib.php
Normal file
50
repository/merlot/tests/generator/lib.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Merlot repository data generator
|
||||
*
|
||||
* @package repository_merlot
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Merlot repository data generator class
|
||||
*
|
||||
* @package repository_merlot
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_merlot_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['licensekey'])) {
|
||||
$record['licensekey'] = 'licensekey';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
53
repository/picasa/tests/generator/lib.php
Normal file
53
repository/picasa/tests/generator/lib.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Picasa repository data generator
|
||||
*
|
||||
* @package repository_picasa
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Picasa repository data generator class
|
||||
*
|
||||
* @package repository_picasa
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_picasa_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['clientid'])) {
|
||||
$record['clientid'] = 'clientid';
|
||||
}
|
||||
if (!isset($record['secret'])) {
|
||||
$record['secret'] = 'secret';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
50
repository/recent/tests/generator/lib.php
Normal file
50
repository/recent/tests/generator/lib.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Recent repository data generator
|
||||
*
|
||||
* @package repository_recent
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Recent repository data generator class
|
||||
*
|
||||
* @package repository_recent
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_recent_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['recentfilesnumber'])) {
|
||||
$record['recentfilesnumber'] = '';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
53
repository/s3/tests/generator/lib.php
Normal file
53
repository/s3/tests/generator/lib.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Amazon S3 repository data generator
|
||||
*
|
||||
* @package repository_s3
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Amazon S3 repository data generator class
|
||||
*
|
||||
* @package repository_s3
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_s3_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in type record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_type_record(array $record) {
|
||||
$record = parent::prepare_type_record($record);
|
||||
if (!isset($record['access_key'])) {
|
||||
$record['access_key'] = 'access_key';
|
||||
}
|
||||
if (!isset($record['secret_key'])) {
|
||||
$record['secret_key'] = 'secret_key';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
}
|
194
repository/tests/generator_test.php
Normal file
194
repository/tests/generator_test.php
Normal file
@ -0,0 +1,194 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Repository generator tests
|
||||
*
|
||||
* @package repository
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
|
||||
/**
|
||||
* Repository generator tests class
|
||||
*
|
||||
* @package repository
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_generator_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Basic test of creation of repository types.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_type() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// All the repository types.
|
||||
$all = array('alfresco', 'boxnet', 'coursefiles', 'dropbox', 'equella', 'filesystem', 'flickr',
|
||||
'flickr_public', 'googledocs', 'local', 'merlot', 'picasa', 'recent', 's3', 'upload', 'url',
|
||||
'user', 'webdav', 'wikimedia', 'youtube');
|
||||
|
||||
// The ones enabled during installation.
|
||||
$alreadyenabled = array('local', 'recent', 'upload', 'url', 'user', 'wikimedia', 'youtube');
|
||||
|
||||
// Enable all the repositories which are not enabled yet.
|
||||
foreach ($all as $type) {
|
||||
if (in_array($type, $alreadyenabled)) {
|
||||
continue;
|
||||
}
|
||||
$repotype = $this->getDataGenerator()->create_repository_type($type);
|
||||
$this->assertEquals($repotype->type, $type, 'Unexpected name after creating repository type ' . $type);
|
||||
$this->assertTrue($DB->record_exists('repository', array('type' => $type, 'visible' => 1)));
|
||||
}
|
||||
|
||||
// Check that all the repositories have been enabled.
|
||||
foreach ($all as $type) {
|
||||
$caughtexception = false;
|
||||
try {
|
||||
$this->getDataGenerator()->create_repository_type($type);
|
||||
} catch (repository_exception $e) {
|
||||
if ($e->getMessage() === 'This repository already exists') {
|
||||
$caughtexception = true;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($caughtexception, "Repository type '$type' should have already been enabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the type options are properly saved.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_type_custom_options() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Single instances.
|
||||
// Note: for single instances repositories enablecourseinstances and enableuserinstances are forced set to 0.
|
||||
$record = new stdClass();
|
||||
$record->pluginname = 'Custom Flickr';
|
||||
$record->api_key = '12345';
|
||||
$record->secret = '67890';
|
||||
$flickr = $this->getDataGenerator()->create_repository_type('flickr', $record);
|
||||
|
||||
$config = get_config('flickr');
|
||||
$record->enableuserinstances = '0';
|
||||
$record->enablecourseinstances = '0';
|
||||
$this->assertEquals($record, $config);
|
||||
$this->assertEquals('Custom Flickr',
|
||||
$DB->get_field('repository_instances', 'name', array('typeid' => $flickr->id), MUST_EXIST));
|
||||
|
||||
$record = new stdClass();
|
||||
$record->pluginname = 'Custom Dropbox';
|
||||
$record->dropbox_key = '12345';
|
||||
$record->dropbox_secret = '67890';
|
||||
$record->dropbox_cachelimit = '123';
|
||||
$dropbox = $this->getDataGenerator()->create_repository_type('dropbox', $record);
|
||||
|
||||
$config = get_config('dropbox');
|
||||
$record->enableuserinstances = '0';
|
||||
$record->enablecourseinstances = '0';
|
||||
$this->assertEquals($record, $config);
|
||||
$this->assertEquals('Custom Dropbox',
|
||||
$DB->get_field('repository_instances', 'name', array('typeid' => $dropbox->id), MUST_EXIST));
|
||||
|
||||
// Multiple instances.
|
||||
$record = new stdClass();
|
||||
$record->pluginname = 'Custom WebDAV';
|
||||
$record->enableuserinstances = '0';
|
||||
$record->enablecourseinstances = '0';
|
||||
$webdav = $this->getDataGenerator()->create_repository_type('webdav', $record);
|
||||
|
||||
$config = get_config('webdav');
|
||||
$this->assertEquals($record, $config);
|
||||
$this->assertFalse( $DB->record_exists('repository_instances', array('typeid' => $webdav->id)));
|
||||
|
||||
$record = new stdClass();
|
||||
$record->pluginname = 'Custom Equella';
|
||||
$record->enableuserinstances = '1';
|
||||
$record->enablecourseinstances = '0';
|
||||
$equella = $this->getDataGenerator()->create_repository_type('equella', $record);
|
||||
|
||||
$config = get_config('equella');
|
||||
$this->assertEquals($record, $config);
|
||||
$this->assertFalse( $DB->record_exists('repository_instances', array('typeid' => $equella->id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Covers basic testing of instance creation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_instance() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$block = $this->getDataGenerator()->create_block('online_users');
|
||||
|
||||
$type = $this->getDataGenerator()->create_repository_type('webdav');
|
||||
$record = new stdClass();
|
||||
$record->name = 'A WebDAV instance';
|
||||
$record->webdav_type = '1';
|
||||
$record->webdav_server = 'localhost';
|
||||
$record->webdav_port = '12345';
|
||||
$record->webdav_path = '/nothing';
|
||||
$record->webdav_user = 'me';
|
||||
$record->webdav_password = '\o/';
|
||||
$record->webdav_auth = 'basic';
|
||||
$instance = $this->getDataGenerator()->create_repository('webdav', $record);
|
||||
|
||||
$this->assertEquals(1, $DB->count_records('repository_instances', array('typeid' => $type->id)));
|
||||
$this->assertEquals($record->name, $DB->get_field('repository_instances', 'name', array('id' => $instance->id)));
|
||||
$entries = $DB->get_records('repository_instance_config', array('instanceid' => $instance->id));
|
||||
$config = new stdClass();
|
||||
foreach ($entries as $entry) {
|
||||
$config->{$entry->name} = $entry->value;
|
||||
}
|
||||
unset($record->name);
|
||||
$this->assertEquals($config, $record);
|
||||
|
||||
// Course context.
|
||||
$record = new stdClass();
|
||||
$record->contextid = context_course::instance($course->id)->id;
|
||||
$instance = $this->getDataGenerator()->create_repository('webdav', $record);
|
||||
$this->assertEquals(2, $DB->count_records('repository_instances', array('typeid' => $type->id)));
|
||||
$this->assertEquals($record->contextid, $instance->contextid);
|
||||
|
||||
// User context.
|
||||
$record->contextid = context_user::instance($user->id)->id;
|
||||
$instance = $this->getDataGenerator()->create_repository('webdav', $record);
|
||||
$this->assertEquals(3, $DB->count_records('repository_instances', array('typeid' => $type->id)));
|
||||
$this->assertEquals($record->contextid, $instance->contextid);
|
||||
|
||||
// Invalid context.
|
||||
$this->setExpectedException('coding_exception');
|
||||
$record->contextid = context_block::instance($block->id)->id;
|
||||
$instance = $this->getDataGenerator()->create_repository('webdav', $record);
|
||||
}
|
||||
|
||||
}
|
35
repository/upload/tests/generator/lib.php
Normal file
35
repository/upload/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Upload repository data generator
|
||||
*
|
||||
* @package repository_upload
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Upload repository data generator class
|
||||
*
|
||||
* @package repository_upload
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_upload_generator extends testing_repository_generator {
|
||||
}
|
35
repository/url/tests/generator/lib.php
Normal file
35
repository/url/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* URL repository data generator
|
||||
*
|
||||
* @package repository_url
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* URL repository data generator class
|
||||
*
|
||||
* @package repository_url
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_url_generator extends testing_repository_generator {
|
||||
}
|
35
repository/user/tests/generator/lib.php
Normal file
35
repository/user/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User private files repository data generator
|
||||
*
|
||||
* @package repository_user
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* User private files repository data generator class
|
||||
*
|
||||
* @package repository_user
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_user_generator extends testing_repository_generator {
|
||||
}
|
69
repository/webdav/tests/generator/lib.php
Normal file
69
repository/webdav/tests/generator/lib.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* WebDAV repository data generator
|
||||
*
|
||||
* @package repository_webdav
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* WebDAV repository data generator class
|
||||
*
|
||||
* @package repository_webdav
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_webdav_generator extends testing_repository_generator {
|
||||
|
||||
/**
|
||||
* Fill in record defaults.
|
||||
*
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_record(array $record) {
|
||||
$record = parent::prepare_record($record);
|
||||
if (!isset($record['webdav_type'])) {
|
||||
$record['webdav_type'] = 0;
|
||||
}
|
||||
if (!isset($record['webdav_server'])) {
|
||||
$record['webdav_server'] = 'webdav.server.local';
|
||||
}
|
||||
if (!isset($record['webdav_port'])) {
|
||||
$record['webdav_port'] = '';
|
||||
}
|
||||
if (!isset($record['webdav_path'])) {
|
||||
$record['webdav_path'] = '/';
|
||||
}
|
||||
if (!isset($record['webdav_user'])) {
|
||||
$record['webdav_user'] = '';
|
||||
}
|
||||
if (!isset($record['webdav_password'])) {
|
||||
$record['webdav_password'] = '';
|
||||
}
|
||||
if (!isset($record['webdav_auth'])) {
|
||||
$record['webdav_auth'] = 'none';
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
|
||||
}
|
35
repository/wikimedia/tests/generator/lib.php
Normal file
35
repository/wikimedia/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Wikimedia repository data generator
|
||||
*
|
||||
* @package repository_wikimedia
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wikimedia repository data generator class
|
||||
*
|
||||
* @package repository_wikimedia
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_wikimedia_generator extends testing_repository_generator {
|
||||
}
|
35
repository/youtube/tests/generator/lib.php
Normal file
35
repository/youtube/tests/generator/lib.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Youtube repository data generator
|
||||
*
|
||||
* @package repository_youtube
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Youtube repository data generator class
|
||||
*
|
||||
* @package repository_youtube
|
||||
* @category test
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class repository_youtube_generator extends testing_repository_generator {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user