'wiki' => 'wiki',
'workshop' => 'workshop');
- public $tables = array('assignment' => array('required' => false, 'toclean' => true),
- 'block' => array('required' => true, 'toclean' => false),
- 'block_instance' => array('required' => true, 'toclean' => true),
- 'block_pinned' => array('required' => true, 'toclean' => true),
- 'capabilities' => array('required' => true, 'toclean' => false),
- 'chat' => array('required' => false, 'toclean' => true),
- 'chat_messages' => array('required' => false, 'toclean' => true),
- 'chat_users' => array('required' => false, 'toclean' => true),
- 'choice' => array('required' => false, 'toclean' => true),
- 'config' => array('required' => true, 'toclean' => false),
- 'config_plugins' => array('required' => true, 'toclean' => false),
- 'context' => array('required' => true, 'toclean' => true),
- 'course' => array('required' => true, 'toclean' => true, 'wheresql' => 'sortorder > 1'),
- 'course_categories' => array('required' => true, 'toclean' => true, 'wheresql' => 'id > 1'),
- 'course_modules' => array('required' => true, 'toclean' => true),
- 'course_sections' => array('required' => true, 'toclean' => true),
- 'data' => array('required' => false, 'toclean' => true),
- 'data_content' => array('required' => false, 'toclean' => true),
- 'data_fields' => array('required' => false, 'toclean' => true),
- 'data_records' => array('required' => false, 'toclean' => true),
- 'event' => array('required' => true, 'toclean' => true),
- 'forum' => array('required' => false, 'toclean' => true),
- 'forum_discussions' => array('required' => false, 'toclean' => true),
- 'forum_posts' => array('required' => false, 'toclean' => true),
- 'glossary' => array('required' => false, 'toclean' => true),
- 'glossary_formats' => array('required' => false, 'toclean' => false),
- 'grade_categories' => array('required' => true, 'toclean' => true),
- 'grade_items' => array('required' => true, 'toclean' => true),
- 'groups' => array('required' => true, 'toclean' => true),
- 'label' => array('required' => false, 'toclean' => true),
- 'lesson' => array('required' => false, 'toclean' => true),
- 'lesson_default' => array('required' => false, 'toclean' => true),
- 'log' => array('required' => true, 'toclean' => true),
- 'log_display' => array('required' => true, 'toclean' => true),
- 'message' => array('required' => false, 'toclean' => true),
- 'modules' => array('required' => true, 'toclean' => true),
- 'question' => array('required' => false, 'toclean' => true),
- 'quiz' => array('required' => false, 'toclean' => true),
- 'resource' => array('required' => true, 'toclean' => true),
- 'role' => array('required' => true, 'toclean' => false),
- 'role_allow_assign' => array('required' => true, 'toclean' => false),
- 'role_allow_override' => array('required' => true, 'toclean' => false),
- 'role_assignments' => array('required' => true, 'toclean' => true),
- 'role_capabilities' => array('required' => true, 'toclean' => true),
- 'survey' => array('required' => false, 'toclean' => true),
- 'user' => array('required' => true, 'toclean' => true, 'wheresql' => 'id > 2'),
- 'wiki' => array('required' => false, 'toclean' => true)
- );
- public $missing_tables = array();
-
public $settings = array();
public $eolchar = '<br />';
public $do_generation = false;
'help' => 'Your moodle username', 'type'=>'STRING', 'default' => ''),
array('short'=>'pw', 'long'=>'password',
'help' => 'Your moodle password', 'type'=>'STRING', 'default' => ''),
- array('short'=>'p', 'long'=>'data_prefix',
- 'help' => 'An optional prefix prepended to the unique identifiers of the generated data. Default=test_',
- 'type'=>'STRING', 'default' => 'test_'),
array('short'=>'P', 'long' => 'database_prefix',
'help' => 'Database prefix to use: tables must already exist or the script will abort!',
'type'=>'STRING', 'default' => 'tst_'),
$user = new stdClass();
$user->firstname = trim(ucfirst(strtolower($firstname)));
- $user->username = $this->get('data_prefix') . strtolower(substr($firstname, 0, 7)
- . substr($lastname, 0, 7)) . $next_user_id++;
+ $user->username = strtolower(substr($firstname, 0, 7) . substr($lastname, 0, 7)) . $next_user_id++;
$user->lastname = $lastname;
$user->email = $user->username . '@example.com';
$user->mnethostid = 1;
$newcourse = fullclone($base_course);
$newcourse->fullname = "Test course $next_course_id";
$newcourse->shortname = "Test $next_course_id";
- $newcourse->idnumber = $this->get('data_prefix') . $next_course_id;
+ $newcourse->idnumber = $next_course_id;
if (!$course = create_course($newcourse)) {
$this->verbose("Error inserting a new course in the database!");
if (!$this->get('ignore_errors')) {
break;
}
- $module->name = $this->get('data_prefix') . ucfirst($moduledata->name) . ' ' . $moduledata->count++;
+ $module->name = ucfirst($moduledata->name) . ' ' . $moduledata->count++;
$module->course = $courseid;
$module->section = $i;
$type = $database_field_types[array_rand($database_field_types)];
require_once($CFG->dirroot.'/mod/data/field/'.$type.'/field.class.php');
$newfield = 'data_field_'.$type;
- $newfield = new $newfield(0, $data, true);
+ $cm = get_coursemodule_from_instance('data', $data->id);
+ $newfield = new $newfield(0, $data, $cm);
$fields[$data->id][] = $newfield;
$newfield->insert_field();
}
return $result;
}
- /**
- * If an alternate DB prefix was given, we need to check that the appropriate tables
- * exist.
- */
- public function check_test_tables() {
- global $CFG, $DB;
-
- ksort($this->tables);
- // Check that all required tables exist
-
- $table_errors = array();
-
- foreach ($this->tables as $table => $tabledata) {
- require_once($CFG->libdir . '/ddllib.php');
- $dbman = $DB->get_manager();
- $xmltable = new XMLDBTable($table);
- if (!$dbman->table_exists($xmltable)) {
- if ($tabledata['required']) {
- $table_errors[] = $this->get('database_prefix') . $table;
- }
- $this->missing_tables[] = $table;
- }
- }
-
- if (!empty($table_errors) && !$this->get('quiet')) {
- if (!$this->get('quiet')) {
- echo "The following required tables do not exist in the database:" . $this->eolchar;
- foreach ($table_errors as $table) {
- echo " $table" . $this->eolchar;
- }
- echo "Please create these tables or choose a different database prefix before running "
- ."this script with these parameters again." . $this->eolchar;
- }
- if (!$this->get('ignore_errors')) {
- die();
- }
- }
-
- }
/**
* If verbose is switched on, prints a string terminated by the global eolchar string.
}
}
+
/**
- * Attempts to delete all generated test data. A few conditions are required for this to be successful:
- * 1. If a database-prefix has been given, tables with this prefix must exist
- * 2. If a data prefix has been given (e.g. test_), test data must contain this prefix in their unique identifiers (not PKs)
- * The first method is safest, because it will not interfere with existing tables, but you have to create all the tables yourself.
+ * Attempts to delete all generated test data.
+ * WARNING: THIS WILL COMPLETELY MESS UP A "REAL" SITE, AND IS INTENDED ONLY FOR DEVELOPMENT PURPOSES
*/
function data_cleanup() {
global $DB;
ob_start();
}
- // Truncate test tables if a specific db prefix was given
- if (!is_null($this->get('database_prefix')) && isset($this->tables)) {
- foreach ($this->tables as $table_name => $tabledata) {
- // Don't empty a few tables
- if (!in_array($table_name, array('modules', 'block')) &&
- $tabledata['toclean'] &&
- !in_array($table_name, $this->missing_tables)) {
- // Leave the frontpage course
- $conditions = 'id > 0';
- if (!empty($tabledata['wheresql'])) {
- $conditions .= " AND {$tabledata['wheresql']} ";
- }
-
- if ($DB->delete_records_select($table_name, $conditions)) {
- $this->verbose("Truncated table $table_name");
- } else {
- $this->verbose("Could not truncate table $table_name");
- if (!$this->get('ignore_errors')) {
- die();
- }
- }
- }
- }
-
- } else {
- echo "BOOH";
- }
- /** Following code has been commented for security reasons
-
- else { // Delete records in normal tables if no specific db prefix was given
- $courses = $DB->get_records_select('course', "idnumber LIKE ?",
- array($this->get('data_prefix').'%'), null, 'id');
-
- if (is_array($courses) && count($courses) > 0) {
- foreach ($courses as $course) {
- if (!delete_course($course->id, false)) {
- $this->verbose("Could not delete course $course->id or some of "
- ."its associated records from the database.");
- if (!$this->get('ignore_errors')) {
- die();
- }
- } else {
- $this->verbose("Deleted course $course->id and all associated records from the database.");
- }
- }
- }
-
- $this->verbose("Deleting test users (permanently)...");
- if (!$DB->delete_records_select('user', "username LIKE ?", array($this->get('data_prefix').'%'))) {
- $this->verbose("Error deleting users from the database");
- if (!$this->get('ignore_errors')) {
- die();
- }
- }
- }
-
- */
+ // TODO Cleanup code
if ($this->get('quiet')) {
ob_end_clean();
// Building the USAGE output of the command line version
$help = "Moodle Data Generator. Generates Data for Moodle sites. Good for benchmarking and other tests.\n\n"
+ . "FOR DEVELOPMENT PURPOSES ONLY! DO NOT USE ON A PRODUCTION SITE!\n\n"
. "Usage: {$settings[0]}; [OPTION] ...\n"
. "Options:\n"
. " -h, -?, -help, --help This output\n";
public function display() {
print_header("Data generator");
print_heading("Data generator: web interface");
+ print_heading("FOR DEVELOPMENT PURPOSES ONLY. DO NOT USE ON A PRODUCTION SITE!", '', 3);
+ print_heading("Your database contents will probably be massacred. You have been warned", '', 5);
+
$mform = new generator_form();
$this->do_generation = optional_param('do_generation', false, PARAM_BOOL);
$zipper = new zip_packer();
list ($contextid, $filearea, $itemid) = array_values($this->get_base_filearea());
- if ($newfile = $zipper->archive_to_storage($files, $contextid, $filearea, $itemid, $filepath, $filename, $this->user->id)) {
+ if ($newfile = $zipper->archive_to_storage($this->get_tempfiles(), $contextid, $filearea, $itemid, $filepath, $filename, $this->user->id)) {
return $newfile;
}
return false;
--- /dev/null
+<?php // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.org //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
+// //
+// This program 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 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program 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: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Unit tests for ../portfoliolib.php.
+ *
+ * @author nicolasconnault@gmail.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package moodlecore
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+ die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
+}
+
+require_once($CFG->libdir . '/portfoliolib.php');
+require_once($CFG->dirroot . '/admin/generator.php');
+
+class portfolio_plugin_test extends portfolio_plugin_push_base {
+ public function expected_time($callertime){
+ return $callertime;
+ }
+
+ public function prepare_package() {
+ return true;
+ }
+
+ public function send_package() {
+ return true;
+ }
+
+ public function get_continue_url() {
+ return '';
+ }
+
+ public static function get_name() {
+ return '';
+ }
+}
+
+class portfolio_caller_test extends portfolio_caller_base {
+ private $content;
+
+ public function __construct($content) {
+ $this->content = $content;
+ }
+
+ public function expected_time() {
+ return PORTFOLIO_TIME_LOW;
+ }
+
+ public function get_navigation() {
+ $extranav = array('name' => 'Test caller class', 'link' => $this->get_return_url());
+ return array($extranav, 'test');
+ }
+
+ public function get_sha1(){
+ return sha1($this->content);
+ }
+
+ public function prepare_package() {
+
+ }
+
+ public function get_return_url() {
+ return '';
+ }
+
+ public function check_permissions() {
+ return true;
+ }
+
+ public static function display_name() {
+ return "Test caller subclass";
+ }
+
+ public function load_data() {
+
+ }
+
+ public static function expected_callbackargs() {
+ return array();
+ }
+}
+
+/**
+ * The following two classes are full mocks: none of their methods do anything, including their constructor.
+ * They can be instantiated directly with no params (new portfolio_caller_test())
+ */
+Mock::generate('portfolio_caller_test', 'mock_caller');
+Mock::generate('portfolio_plugin_test', 'mock_plugin');
+
+/**
+ * Partial mocks work as normal except the methods listed in the 3rd param, which are mocked.
+ * They are instantiated by passing $this to the constructor within the test case class.
+ */
+Mock::generatePartial('portfolio_plugin_test', 'partialmock_plugin', array('send_package'));
+Mock::generatePartial('portfolio_exporter', 'partialmock_exporter', array('process_stage_confirm',
+ 'process_stage_cleanup',
+ 'log_transfer',
+ 'save',
+ 'rewaken_object'));
+
+
+// Generate a mock class for each plugin subclass present
+$portfolio_plugins = get_list_of_plugins('portfolio/type');
+foreach ($portfolio_plugins as $plugin) {
+ require_once($CFG->dirroot . "/portfolio/type/$plugin/lib.php");
+ Mock::generatePartial("portfolio_plugin_$plugin", "partialmock_plugin_$plugin", array('send_package'));
+}
+
+require_once($CFG->libdir . '/portfoliolib.php');
+require_once($CFG->dirroot . '/admin/generator.php');
+
+class portfoliolib_test extends UnitTestCase {
+ public $tables = array();
+
+ function setUp() {
+ global $DB, $CFG;
+
+ $this->tables = $DB->get_tables();
+
+ foreach ($this->tables as $key => $table) {
+ if ($table == 'sessions2') {
+ unset($this->tables[$key]);
+ continue;
+ }
+
+ if ($max_id = $DB->get_field_sql("SELECT MAX(id) FROM {$CFG->prefix}{$table}")) {
+ $this->tables[$table] = $max_id;
+ } else {
+ $this->tables[$table] = 0;
+ }
+ }
+ }
+
+ function tearDown() {
+ global $DB;
+
+ // Truncate all data created during unit tests
+ foreach ($this->tables as $table => $max_pk) {
+ $DB->delete_records_select($table, "id > $max_pk");
+ }
+ }
+
+ function test_construct_dupe_instance() {
+ $gotexception = false;
+ try {
+ $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;
+ }
+ $this->assertTrue($gotexception);
+ }
+
+ /**
+ * does everything we need to set up a new caller
+ * so each subclass doesn't have to implement this
+ *
+ * @param string $class name of caller class to generate (this class def must be already loaded)
+ * @param array $callbackargs the arguments to pass the constructor of the caller
+ * @param int $userid a userid the subclass has generated
+ *
+ * @return portfolio_caller_base subclass
+ */
+ protected function setup_caller($class, $callbackargs, $user=null) {
+ global $DB;
+ $caller = new $class($callbackargs);
+ $caller->set('exporter', new mock_exporter());
+ if (is_numeric($user)) {
+ $user = $DB->get_record('user', array('id' => $user));
+ }
+ if (is_object($user)) {
+ $caller->set('user', $user);
+ }
+ $caller->load_data();
+ return $caller;
+ }
+
+ public function test_caller_with_plugins() {
+ if (!empty($this->caller)) {
+ $plugins = get_list_of_plugins('portfolio/type');
+
+ foreach ($plugins as $plugin) {
+ // Instantiate a fake plugin instance
+ $plugin_class = "partialmock_plugin_$plugin";
+ $plugin = new $plugin_class(&$this);
+
+ // Create a new fake exporter
+ $exporter = new partialmock_exporter(&$this);
+ $exporter->set('caller', $this->caller);
+ $exporter->set('instance', $plugin);
+
+ $exception = false;
+ try {
+ $exporter->process_stage_package();
+ } catch (Exception $e) {
+ $exception = $e->getMessage();
+ }
+
+ $this->assertFalse($exception, "Unwanted exception: $exception");
+ }
+ }
+ }
+}
+?>
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
-require_once($CFG->libdir . '/portfoliolib.php');
-require_once($CFG->dirroot . '/admin/generator.php');
-
-class portfolio_plugin_test extends portfolio_plugin_push_base {
- public function expected_time($callertime){
- return $callertime;
- }
-
- public function prepare_package() {
- return true;
- }
-
- public function send_package() {
- return true;
- }
-
- public function get_continue_url() {
- return '';
- }
-
- public static function get_name() {
- return '';
- }
-}
-
-class portfolio_caller_test extends portfolio_caller_base {
- private $content;
-
- public function __construct($content) {
- $this->content = $content;
- }
-
- public function expected_time() {
- return PORTFOLIO_TIME_LOW;
- }
-
- public function get_navigation() {
- $extranav = array('name' => 'Test caller class', 'link' => $this->get_return_url());
- return array($extranav, 'test');
- }
-
- public function get_sha1(){
- return sha1($this->content);
- }
-
- public function prepare_package() {
-
- }
-
- public function get_return_url() {
- return '';
- }
-
- public function check_permissions() {
- return true;
- }
-
- public static function display_name() {
- return "Test caller subclass";
- }
-
- public function load_data() {
-
- }
-
- public static function expected_callbackargs() {
- return array();
- }
-}
-
-/**
- * The following two classes are full mocks: none of their methods do anything, including their constructor.
- * They can be instantiated directly with no params (new portfolio_caller_test())
- */
-Mock::generate('portfolio_caller_test', 'mock_caller');
-Mock::generate('portfolio_plugin_test', 'mock_plugin');
-
-/**
- * Partial mocks work as normal except the methods listed in the 3rd param, which are mocked.
- * They are instantiated by passing $this to the constructor within the test case class.
- */
-Mock::generatePartial('portfolio_plugin_test', 'partialmock_plugin', array('send_package'));
-
-class portfoliolib_test extends UnitTestCase {
- public $caller;
- public $plugin;
- public $exporter;
- public $original_db;
-
- function setUp() {
- global $DB, $CFG;
- $this->original_db = clone($DB);
-
- $class = get_class($DB);
- $DB = new $class();
- $DB->connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, true, 'tst_');
-
- $u = new StdClass;
- $u->id = 100000000000;
- $this->plugin = new mock_plugin();
- $this->caller = new mock_caller();
- $this->exporter = new portfolio_exporter(&$this->plugin, &$this->caller, '', array());
- $this->exporter->set('user', $u);
- $partialplugin = &new partialmock_plugin($this);
-
- // Write a new text file
- $this->exporter->save();
- $this->exporter->write_new_file('Test text', 'test.txt');
- }
-
- function tearDown() {
- global $DB;
- $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);
-
- // Restore original DB
- $DB = $this->original_db;
- }
-
- function test_construct_dupe_instance() {
- $gotexception = false;
- try {
- $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;
- }
- $this->assertTrue($gotexception);
- }
-
- /**
- * does everything we need to set up a new caller
- * so each subclass doesn't have to implement this
- *
- * @param string $class name of caller class to generate (this class def must be already loaded)
- * @param array $callbackargs the arguments to pass the constructor of the caller
- * @param int $userid a userid the subclass has generated
- *
- * @return portfolio_caller_base subclass
- */
- protected function setup_caller($class, $callbackargs, $user=null) {
- global $DB;
- $caller = new $class($callbackargs);
- $caller->set('exporter', new mock_exporter());
- if (is_numeric($user)) {
- $user = $DB->get_record('user', array('id' => $user));
- }
- if (is_object($user)) {
- $caller->set('user', $user);
- }
- $caller->load_data();
- return $caller;
- }
-}
+require_once($CFG->libdir . '/simpletest/portfolio_testclass.php');
// Load tests for various modules
foreach (get_list_of_plugins('mod') as $module) {
<?php // $Id$
-require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
+require_once($CFG->libdir.'/simpletest/portfolio_testclass.php');
require_once($CFG->dirroot.'/mod/assignment/lib.php');
require_once($CFG->dirroot.'/admin/generator.php');
parent::setUp();
- $settings = array('quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1,
+ $settings = array('quiet' => 1, 'pre_cleanup' => 1,
'modules_list' => array($this->module_type), 'assignment_grades' => true,
'assignment_type' => 'online',
'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1,
$submissions = $DB->get_records('assignment_submissions', array('assignment' => $first_module->id));
$first_submission = reset($submissions);
- $callbackargs = array('id' => $cm->id);
$this->caller = parent::setup_caller('assignment_portfolio_caller', array('id' => $cm->id), $first_submission->userid);
}
$this->assertEqual($sha1, $this->caller->get_sha1());
}
+ public function test_caller_with_plugins() {
+ parent::test_caller_with_plugins();
+ }
}
?>
<?php // $Id$
-require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
+require_once($CFG->libdir.'/simpletest/portfolio_testclass.php');
require_once($CFG->dirroot.'/mod/chat/lib.php');
require_once($CFG->dirroot.'/admin/generator.php');
parent::setUp();
- $settings = array('quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1,
+ $settings = array('quiet' => 1, 'pre_cleanup' => 1,
'modules_list' => array($this->module_type),
'number_of_students' => 15, 'students_per_course' => 15, 'number_of_sections' => 1,
'number_of_modules' => 1, 'messages_per_chat' => 15);
$this->assertEqual($sha1, $this->caller->get_sha1());
}
+ public function test_caller_with_plugins() {
+ parent::test_caller_with_plugins();
+ }
}
?>
<?php // $Id$
-require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
+require_once($CFG->libdir.'/simpletest/portfolio_testclass.php');
require_once($CFG->dirroot.'/mod/data/lib.php');
require_once($CFG->dirroot.'/admin/generator.php');
parent::setUp();
$settings = array('quiet' => 1,
- 'database_prefix' => 'tst_',
+
'pre_cleanup' => 0,
'modules_list' => array($this->module_type),
'number_of_students' => 5,
$this->assertEqual($sha1, $this->caller_single->get_sha1());
}
+ public function test_caller_with_plugins() {
+ parent::test_caller_with_plugins();
+ }
}
?>
<?php // $Id$
-require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
+require_once($CFG->libdir.'/simpletest/portfolio_testclass.php');
require_once($CFG->dirroot.'/mod/forum/lib.php');
require_once($CFG->dirroot.'/admin/generator.php');
$settings = array('quiet' => 1,
'verbose' => 0,
- 'database_prefix' => 'tst_',
+
'pre_cleanup' => 0,
'post_cleanup' => 0,
'modules_list' => array($this->module_type),
$this->assertEqual($sha1, $this->discussioncaller->get_sha1());
}
+ public function test_caller_with_plugins() {
+ parent::test_caller_with_plugins();
+ }
}
?>
<?php // $Id$
-require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
+require_once($CFG->libdir.'/simpletest/portfolio_testclass.php');
require_once($CFG->dirroot.'/mod/glossary/lib.php');
require_once($CFG->dirroot.'/admin/generator.php');
parent::setUp();
- $settings = array('tiny' => 1, 'quiet' => 1, 'database_prefix' => 'tst_', 'pre_cleanup' => 1,
+ $settings = array('tiny' => 1, 'quiet' => 1, 'pre_cleanup' => 1,
'modules_list' => array('glossary'), 'entries_per_glossary' => 20,
'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1,
'number_of_modules' => 1, 'questions_per_course' => 0);
$this->csv_caller->prepare_package();
$this->assertEqual($csv_sha1, $this->csv_caller->get_sha1());
}
+
+ public function test_caller_with_plugins() {
+ parent::test_caller_with_plugins();
+ }
}
?>
--- /dev/null
+<?php // $Id$
+require_once($CFG->libdir.'/simpletest/testportfoliolib.php');
+require_once($CFG->dirroot.'/mod/resource/lib.php');
+require_once($CFG->dirroot.'/admin/generator.php');
+
+Mock::generate('resource_portfolio_caller', 'mock_caller');
+Mock::generate('portfolio_exporter', 'mock_exporter');
+
+class testResourcePortfolioCallers extends portfoliolib_test {
+ public $module_type = 'resource';
+ public $modules = array();
+ public $entries = array();
+ public $caller;
+
+ public function setUp() {
+ global $DB, $USER;
+
+ parent::setUp();
+
+ $settings = array('quiet' => 1, 'pre_cleanup' => 1,
+ 'modules_list' => array($this->module_type),
+ 'number_of_students' => 15, 'students_per_course' => 15, 'number_of_sections' => 1,
+ 'number_of_modules' => 1, 'messages_per_resource' => 15);
+
+ generator_generate_data($settings);
+
+ $this->modules = $DB->get_records($this->module_type);
+ $first_module = reset($this->modules);
+ $cm = get_coursemodule_from_instance($this->module_type, $first_module->id);
+
+ $this->caller = parent::setup_caller('resource_portfolio_caller', array('id' => $cm->id));
+ }
+
+ public function tearDown() {
+ parent::tearDown();
+ }
+
+ public function test_caller_sha1() {
+ $sha1 = $this->caller->get_sha1();
+ $this->caller->prepare_package();
+ $this->assertEqual($sha1, $this->caller->get_sha1());
+ }
+
+}
+?>