2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
22 * @copyright 2012 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 * Data generator class for unit tests and other tools that need to create fake test sites.
32 * @copyright 2012 Petr Skoda {@link http://skodak.org}
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class testing_data_generator {
36 protected $usercounter = 0;
37 protected $categorycount = 0;
38 protected $cohortcount = 0;
39 protected $coursecount = 0;
40 protected $scalecount = 0;
41 protected $groupcount = 0;
42 protected $groupingcount = 0;
45 * @var int keep track of how many forum discussions have been created.
47 protected $forumdiscussioncount = 0;
50 * @var int keep track of how many forum posts have been created.
52 protected $forumpostcount = 0;
54 /** @var array list of plugin generators */
55 protected $generators = array();
57 /** @var array lis of common last names */
58 public $lastnames = array(
59 'Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Miller', 'Davis', 'García', 'Rodríguez', 'Wilson',
60 'Müller', 'Schmidt', 'Schneider', 'Fischer', 'Meyer', 'Weber', 'Schulz', 'Wagner', 'Becker', 'Hoffmann',
61 'Novák', 'Svoboda', 'Novotný', 'Dvořák', 'Černý', 'Procházková', 'Kučerová', 'Veselá', 'Horáková', 'Němcová',
62 'Смирнов', 'Иванов', 'Кузнецов', 'Соколов', 'Попов', 'Лебедева', 'Козлова', 'Новикова', 'Морозова', 'Петрова',
63 '王', '李', '张', '刘', '陈', '楊', '黃', '趙', '吳', '周',
64 '佐藤', '鈴木', '高橋', '田中', '渡辺', '伊藤', '山本', '中村', '小林', '斎藤',
67 /** @var array lis of common first names */
68 public $firstnames = array(
69 'Jacob', 'Ethan', 'Michael', 'Jayden', 'William', 'Isabella', 'Sophia', 'Emma', 'Olivia', 'Ava',
70 'Lukas', 'Leon', 'Luca', 'Timm', 'Paul', 'Leonie', 'Leah', 'Lena', 'Hanna', 'Laura',
71 'Jakub', 'Jan', 'Tomáš', 'Lukáš', 'Matěj', 'Tereza', 'Eliška', 'Anna', 'Adéla', 'Karolína',
72 'Даниил', 'Максим', 'Артем', 'Иван', 'Александр', 'София', 'Анастасия', 'Дарья', 'Мария', 'Полина',
73 '伟', '伟', '芳', '伟', '秀英', '秀英', '娜', '秀英', '伟', '敏',
74 '翔', '大翔', '拓海', '翔太', '颯太', '陽菜', 'さくら', '美咲', '葵', '美羽',
77 public $loremipsum = <<<EOD
78 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla non arcu lacinia neque faucibus fringilla. Vivamus porttitor turpis ac leo. Integer in sapien. Nullam eget nisl. Aliquam erat volutpat. Cras elementum. Mauris suscipit, ligula sit amet pharetra semper, nibh ante cursus purus, vel sagittis velit mauris vel metus. Integer malesuada. Nullam lectus justo, vulputate eget mollis sed, tempor sed magna. Mauris elementum mauris vitae tortor. Aliquam erat volutpat.
79 Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Pellentesque ipsum. Cras pede libero, dapibus nec, pretium sit amet, tempor quis. Aliquam ante. Proin in tellus sit amet nibh dignissim sagittis. Vivamus porttitor turpis ac leo. Duis bibendum, lectus ut viverra rhoncus, dolor nunc faucibus libero, eget facilisis enim ipsum id lacus. In sem justo, commodo ut, suscipit at, pharetra vitae, orci. Aliquam erat volutpat. Nulla est.
80 Vivamus luctus egestas leo. Aenean fermentum risus id tortor. Mauris dictum facilisis augue. Aliquam erat volutpat. Aliquam ornare wisi eu metus. Aliquam id dolor. Duis condimentum augue id magna semper rutrum. Donec iaculis gravida nulla. Pellentesque ipsum. Etiam dictum tincidunt diam. Quisque tincidunt scelerisque libero. Etiam egestas wisi a erat.
81 Integer lacinia. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris tincidunt sem sed arcu. Nullam feugiat, turpis at pulvinar vulputate, erat libero tristique tellus, nec bibendum odio risus sit amet ante. Aliquam id dolor. Maecenas sollicitudin. Et harum quidem rerum facilis est et expedita distinctio. Mauris suscipit, ligula sit amet pharetra semper, nibh ante cursus purus, vel sagittis velit mauris vel metus. Nullam dapibus fermentum ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Pellentesque sapien. Duis risus. Mauris elementum mauris vitae tortor. Suspendisse nisl. Integer rutrum, orci vestibulum ullamcorper ultricies, lacus quam ultricies odio, vitae placerat pede sem sit amet enim.
82 In laoreet, magna id viverra tincidunt, sem odio bibendum justo, vel imperdiet sapien wisi sed libero. Proin pede metus, vulputate nec, fermentum fringilla, vehicula vitae, justo. Nullam justo enim, consectetuer nec, ullamcorper ac, vestibulum in, elit. Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Maecenas lorem. Etiam posuere lacus quis dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel sapien. Nam sed tellus id magna elementum tincidunt. Suspendisse nisl. Vivamus luctus egestas leo. Nulla non arcu lacinia neque faucibus fringilla. Etiam dui sem, fermentum vitae, sagittis id, malesuada in, quam. Etiam dictum tincidunt diam. Etiam commodo dui eget wisi. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Proin pede metus, vulputate nec, fermentum fringilla, vehicula vitae, justo. Duis ante orci, molestie vitae vehicula venenatis, tincidunt ac pede. Pellentesque sapien.
86 * To be called from data reset code only,
87 * do not use in tests.
90 public function reset() {
91 $this->usercounter = 0;
92 $this->categorycount = 0;
93 $this->coursecount = 0;
94 $this->scalecount = 0;
95 $this->forumdiscussioncount = 0;
96 $this->forumpostcount = 0;
98 foreach ($this->generators as $generator) {
104 * Return generator for given plugin
105 * @param string $component
106 * @return mixed plugin data generator
108 public function get_plugin_generator($component) {
109 list($type, $plugin) = normalize_component($component);
111 if ($type !== 'mod' and $type !== 'block') {
112 throw new coding_exception("Plugin type $type does not support generators yet");
115 $dir = get_plugin_directory($type, $plugin);
117 if (!isset($this->generators[$type.'_'.$plugin])) {
118 $lib = "$dir/tests/generator/lib.php";
119 if (!include_once($lib)) {
120 throw new coding_exception("Plugin $component does not support data generator, missing tests/generator/lib");
122 $classname = $type.'_'.$plugin.'_generator';
123 $this->generators[$type.'_'.$plugin] = new $classname($this);
126 return $this->generators[$type.'_'.$plugin];
131 * @param array|stdClass $record
132 * @param array $options
133 * @return stdClass user record
135 public function create_user($record=null, array $options=null) {
138 $this->usercounter++;
139 $i = $this->usercounter;
141 $record = (array)$record;
143 if (!isset($record['auth'])) {
144 $record['auth'] = 'manual';
147 if (!isset($record['firstname']) and !isset($record['lastname'])) {
148 $country = rand(0, 5);
149 $firstname = rand(0, 4);
150 $lastname = rand(0, 4);
151 $female = rand(0, 1);
152 $record['firstname'] = $this->firstnames[($country*10) + $firstname + ($female*5)];
153 $record['lastname'] = $this->lastnames[($country*10) + $lastname + ($female*5)];
155 } else if (!isset($record['firstname'])) {
156 $record['firstname'] = 'Firstname'.$i;
158 } else if (!isset($record['lastname'])) {
159 $record['lastname'] = 'Lastname'.$i;
162 if (!isset($record['idnumber'])) {
163 $record['idnumber'] = '';
166 if (!isset($record['mnethostid'])) {
167 $record['mnethostid'] = $CFG->mnet_localhost_id;
170 if (!isset($record['username'])) {
171 $record['username'] = 'username'.$i;
173 while ($DB->record_exists('user', array('username'=>$record['username'], 'mnethostid'=>$record['mnethostid']))) {
174 $record['username'] = 'username'.$i.'_'.$j;
179 if (!isset($record['password'])) {
180 $record['password'] = 'lala';
183 if (!isset($record['email'])) {
184 $record['email'] = $record['username'].'@example.com';
187 if (!isset($record['confirmed'])) {
188 $record['confirmed'] = 1;
191 if (!isset($record['lang'])) {
192 $record['lang'] = 'en';
195 if (!isset($record['maildisplay'])) {
196 $record['maildisplay'] = 1;
199 if (!isset($record['deleted'])) {
200 $record['deleted'] = 0;
203 $record['timecreated'] = time();
204 $record['timemodified'] = $record['timecreated'];
205 $record['lastip'] = '0.0.0.0';
207 $record['password'] = hash_internal_user_password($record['password']);
209 if ($record['deleted']) {
210 $delname = $record['email'].'.'.time();
211 while ($DB->record_exists('user', array('username'=>$delname))) {
214 $record['idnumber'] = '';
215 $record['email'] = md5($record['username']);
216 $record['username'] = $delname;
217 $record['picture'] = 0;
220 $userid = $DB->insert_record('user', $record);
222 if (!$record['deleted']) {
223 context_user::instance($userid);
226 return $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
230 * Create a test course category
231 * @param array|stdClass $record
232 * @param array $options
233 * @return stdClass course category record
235 public function create_category($record=null, array $options=null) {
237 require_once("$CFG->dirroot/course/lib.php");
239 $this->categorycount++;
240 $i = $this->categorycount;
242 $record = (array)$record;
244 if (!isset($record['name'])) {
245 $record['name'] = 'Course category '.$i;
248 if (!isset($record['idnumber'])) {
249 $record['idnumber'] = '';
252 if (!isset($record['description'])) {
253 $record['description'] = "Test course category $i\n$this->loremipsum";
256 if (!isset($record['descriptionformat'])) {
257 $record['descriptionformat'] = FORMAT_MOODLE;
260 if (!isset($record['parent'])) {
261 $record['parent'] = 0;
264 if (empty($record['parent'])) {
265 $parent = new stdClass();
269 $parent = $DB->get_record('course_categories', array('id'=>$record['parent']), '*', MUST_EXIST);
271 $record['depth'] = $parent->depth+1;
273 $record['sortorder'] = 0;
274 $record['timemodified'] = time();
275 $record['timecreated'] = $record['timemodified'];
277 $catid = $DB->insert_record('course_categories', $record);
278 $path = $parent->path . '/' . $catid;
279 $DB->set_field('course_categories', 'path', $path, array('id'=>$catid));
280 context_coursecat::instance($catid);
282 fix_course_sortorder();
284 return $DB->get_record('course_categories', array('id'=>$catid), '*', MUST_EXIST);
288 * Create test cohort.
289 * @param array|stdClass $record
290 * @param array $options
291 * @return stdClass cohort record
293 public function create_cohort($record=null, array $options=null) {
295 require_once("$CFG->dirroot/cohort/lib.php");
297 $this->cohortcount++;
298 $i = $this->cohortcount;
300 $record = (array)$record;
302 if (!isset($record['contextid'])) {
303 $record['contextid'] = context_system::instance()->id;
306 if (!isset($record['name'])) {
307 $record['name'] = 'Cohort '.$i;
310 if (!isset($record['idnumber'])) {
311 $record['idnumber'] = '';
314 if (!isset($record['description'])) {
315 $record['description'] = "Test cohort $i\n$this->loremipsum";
318 if (!isset($record['descriptionformat'])) {
319 $record['descriptionformat'] = FORMAT_MOODLE;
322 if (!isset($record['component'])) {
323 $record['component'] = '';
326 $id = cohort_add_cohort((object)$record);
328 return $DB->get_record('cohort', array('id'=>$id), '*', MUST_EXIST);
332 * Create a test course
333 * @param array|stdClass $record
334 * @param array $options with keys:
335 * 'createsections'=>bool precreate all sections
336 * @return stdClass course record
338 public function create_course($record=null, array $options=null) {
340 require_once("$CFG->dirroot/course/lib.php");
342 $this->coursecount++;
343 $i = $this->coursecount;
345 $record = (array)$record;
347 if (!isset($record['fullname'])) {
348 $record['fullname'] = 'Test course '.$i;
351 if (!isset($record['shortname'])) {
352 $record['shortname'] = 'tc_'.$i;
355 if (!isset($record['idnumber'])) {
356 $record['idnumber'] = '';
359 if (!isset($record['format'])) {
360 $record['format'] = 'topics';
363 if (!isset($record['newsitems'])) {
364 $record['newsitems'] = 0;
367 if (!isset($record['numsections'])) {
368 $record['numsections'] = 5;
371 if (!isset($record['summary'])) {
372 $record['summary'] = "Test course $i\n$this->loremipsum";
375 if (!isset($record['summaryformat'])) {
376 $record['summaryformat'] = FORMAT_MOODLE;
379 if (!isset($record['category'])) {
380 $record['category'] = $DB->get_field_select('course_categories', "MIN(id)", "parent=0");
383 $course = create_course((object)$record);
384 context_course::instance($course->id);
385 if (!empty($options['createsections'])) {
386 if (isset($course->numsections)) {
387 course_create_sections_if_missing($course, range(0, $course->numsections));
389 course_create_sections_if_missing($course, 0);
397 * Create course section if does not exist yet
398 * @param array|stdClass $record must contain 'course' and 'section' attributes
399 * @param array|null $options
401 * @throws coding_exception
403 public function create_course_section($record = null, array $options = null) {
406 $record = (array)$record;
408 if (empty($record['course'])) {
409 throw new coding_exception('course must be present in testing_data_generator::create_course_section() $record');
412 if (!isset($record['section'])) {
413 throw new coding_exception('section must be present in testing_data_generator::create_course_section() $record');
416 course_create_sections_if_missing($record['course'], $record['section']);
417 return get_fast_modinfo($record['course'])->get_section_info($record['section']);
421 * Create a test block
422 * @param string $blockname
423 * @param array|stdClass $record
424 * @param array $options
425 * @return stdClass block instance record
427 public function create_block($blockname, $record=null, array $options=null) {
428 $generator = $this->get_plugin_generator('block_'.$blockname);
429 return $generator->create_instance($record, $options);
433 * Create a test module
434 * @param string $modulename
435 * @param array|stdClass $record
436 * @param array $options
437 * @return stdClass activity record
439 public function create_module($modulename, $record=null, array $options=null) {
440 $generator = $this->get_plugin_generator('mod_'.$modulename);
441 return $generator->create_instance($record, $options);
445 * Create a test group for the specified course
447 * $record should be either an array or a stdClass containing infomation about the group to create.
448 * At the very least it needs to contain courseid.
449 * Default values are added for name, description, and descriptionformat if they are not present.
451 * This function calls groups_create_group() to create the group within the database.
452 * @see groups_create_group
453 * @param array|stdClass $record
454 * @return stdClass group record
456 public function create_group($record) {
459 require_once($CFG->dirroot . '/group/lib.php');
462 $i = $this->groupcount;
464 $record = (array)$record;
466 if (empty($record['courseid'])) {
467 throw new coding_exception('courseid must be present in testing_data_generator::create_group() $record');
470 if (!isset($record['name'])) {
471 $record['name'] = 'group-' . $i;
474 if (!isset($record['description'])) {
475 $record['description'] = "Test Group $i\n{$this->loremipsum}";
478 if (!isset($record['descriptionformat'])) {
479 $record['descriptionformat'] = FORMAT_MOODLE;
482 $id = groups_create_group((object)$record);
484 return $DB->get_record('groups', array('id'=>$id));
488 * Create a test group member
489 * @param array|stdClass $record
490 * @throws coding_exception
493 public function create_group_member($record) {
496 require_once($CFG->dirroot . '/group/lib.php');
498 $record = (array)$record;
500 if (empty($record['userid'])) {
501 throw new coding_exception('user must be present in testing_util::create_group_member() $record');
504 if (!isset($record['groupid'])) {
505 throw new coding_exception('group must be present in testing_util::create_group_member() $record');
508 if (!isset($record['component'])) {
509 $record['component'] = null;
511 if (!isset($record['itemid'])) {
512 $record['itemid'] = 0;
515 return groups_add_member($record['groupid'], $record['userid'], $record['component'], $record['itemid']);
519 * Create a test grouping for the specified course
521 * $record should be either an array or a stdClass containing infomation about the grouping to create.
522 * At the very least it needs to contain courseid.
523 * Default values are added for name, description, and descriptionformat if they are not present.
525 * This function calls groups_create_grouping() to create the grouping within the database.
526 * @see groups_create_grouping
527 * @param array|stdClass $record
528 * @return stdClass grouping record
530 public function create_grouping($record) {
533 require_once($CFG->dirroot . '/group/lib.php');
535 $this->groupingcount++;
536 $i = $this->groupingcount;
538 $record = (array)$record;
540 if (empty($record['courseid'])) {
541 throw new coding_exception('courseid must be present in testing_data_generator::create_grouping() $record');
544 if (!isset($record['name'])) {
545 $record['name'] = 'grouping-' . $i;
548 if (!isset($record['description'])) {
549 $record['description'] = "Test Grouping $i\n{$this->loremipsum}";
552 if (!isset($record['descriptionformat'])) {
553 $record['descriptionformat'] = FORMAT_MOODLE;
556 $id = groups_create_grouping((object)$record);
558 return $DB->get_record('groupings', array('id'=>$id));
562 * Create a test grouping group
563 * @param array|stdClass $record
564 * @throws coding_exception
567 public function create_grouping_group($record) {
570 require_once($CFG->dirroot . '/group/lib.php');
572 $record = (array)$record;
574 if (empty($record['groupingid'])) {
575 throw new coding_exception('grouping must be present in testing::create_grouping_group() $record');
578 if (!isset($record['groupid'])) {
579 throw new coding_exception('group must be present in testing_util::create_grouping_group() $record');
582 return groups_assign_grouping($record['groupingid'], $record['groupid']);
586 * Create a test scale
587 * @param array|stdClass $record
588 * @param array $options
589 * @return stdClass block instance record
591 public function create_scale($record=null, array $options=null) {
595 $i = $this->scalecount;
597 $record = (array)$record;
599 if (!isset($record['name'])) {
600 $record['name'] = 'Test scale '.$i;
603 if (!isset($record['scale'])) {
604 $record['scale'] = 'A,B,C,D,F';
607 if (!isset($record['courseid'])) {
608 $record['courseid'] = 0;
611 if (!isset($record['userid'])) {
612 $record['userid'] = 0;
615 if (!isset($record['description'])) {
616 $record['description'] = 'Test scale description '.$i;
619 if (!isset($record['descriptionformat'])) {
620 $record['descriptionformat'] = FORMAT_MOODLE;
623 $record['timemodified'] = time();
625 if (isset($record['id'])) {
626 $DB->import_record('scale', $record);
627 $DB->get_manager()->reset_sequence('scale');
630 $id = $DB->insert_record('scale', $record);
633 return $DB->get_record('scale', array('id'=>$id), '*', MUST_EXIST);
637 * Simplified enrolment of user to course using default options.
639 * It is strongly recommended to use only this method for 'manual' and 'self' plugins only!!!
642 * @param int $courseid
643 * @param int $roleid optional role id, use only with manual plugin
644 * @param string $enrol name of enrol plugin,
645 * there must be exactly one instance in course,
646 * it must support enrol_user() method.
647 * @return bool success
649 public function enrol_user($userid, $courseid, $roleid = null, $enrol = 'manual') {
652 if (!$plugin = enrol_get_plugin($enrol)) {
656 $instances = $DB->get_records('enrol', array('courseid'=>$courseid, 'enrol'=>$enrol));
657 if (count($instances) != 1) {
660 $instance = reset($instances);
662 if (is_null($roleid) and $instance->roleid) {
663 $roleid = $instance->roleid;
666 $plugin->enrol_user($instance, $userid, $roleid);
672 * Function to create a dummy discussion.
674 * @param array|stdClass $record
675 * @return stdClass the discussion object
677 public function create_forum_discussion($record = null) {
680 // Increment the forum discussion count.
681 $this->forumdiscussioncount++;
683 $record = (array) $record;
685 if (!isset($record['course'])) {
686 throw new coding_exception('course must be present in phpunit_util::create_forum_discussion() $record');
689 if (!isset($record['forum'])) {
690 throw new coding_exception('forum must be present in phpunit_util::create_forum_discussion() $record');
693 if (!isset($record['userid'])) {
694 throw new coding_exception('userid must be present in phpunit_util::create_forum_discussion() $record');
697 if (!isset($record['name'])) {
698 $record['name'] = "Discussion " . $this->forumdiscussioncount;
701 if (!isset($record['subject'])) {
702 $record['subject'] = "Subject for discussion " . $this->forumdiscussioncount;
705 if (!isset($record['message'])) {
706 $record['message'] = html_writer::tag('p', 'Message for discussion ' . $this->forumdiscussioncount);
709 if (!isset($record['messageformat'])) {
710 $record['messageformat'] = editors_get_preferred_format();
713 if (!isset($record['messagetrust'])) {
714 $record['messagetrust'] = "";
717 if (!isset($record['assessed'])) {
718 $record['assessed'] = '1';
721 if (!isset($record['groupid'])) {
722 $record['groupid'] = "-1";
725 if (!isset($record['timestart'])) {
726 $record['timestart'] = "0";
729 if (!isset($record['timeend'])) {
730 $record['timeend'] = "0";
733 if (!isset($record['mailnow'])) {
734 $record['mailnow'] = "0";
737 $record = (object) $record;
739 // Add the discussion.
740 $record->id = forum_add_discussion($record, null, null, $record->userid);
746 * Function to create a dummy post.
748 * @param array|stdClass $record
749 * @return stdClass the post object
751 public function create_forum_post($record = null) {
754 // Increment the forum post count.
755 $this->forumpostcount++;
757 // Variable to store time.
758 $time = time() + $this->forumpostcount;
760 $record = (array) $record;
762 if (!isset($record['discussion'])) {
763 throw new coding_exception('discussion must be present in phpunit_util::create_forum_post() $record');
766 if (!isset($record['userid'])) {
767 throw new coding_exception('userid must be present in phpunit_util::create_forum_post() $record');
770 if (!isset($record['parent'])) {
771 $record['parent'] = 0;
774 if (!isset($record['subject'])) {
775 $record['subject'] = 'Forum post subject ' . $this->forumpostcount;
778 if (!isset($record['message'])) {
779 $record['message'] = html_writer::tag('p', 'Forum message post ' . $this->forumpostcount);
782 if (!isset($record['created'])) {
783 $record['created'] = $time;
786 if (!isset($record['modified'])) {
787 $record['modified'] = $time;
790 $record = (object) $record;
793 $record->id = $DB->insert_record('forum_posts', $record);
795 // Update the last post.
796 forum_discussion_update_last_post($record->discussion);
803 * Deprecated in favour of testing_data_generator
805 * @deprecated since Moodle 2.5 MDL-37457 - please do not use this function any more.
806 * @todo MDL-37517 This will be deleted in Moodle 2.7
807 * @see testing_data_generator
810 * @copyright 2012 David Monllaó
811 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
813 class phpunit_data_generator extends testing_data_generator {
816 * Dumb constructor to throw the deprecated notification
818 public function __construct() {
819 debugging('Class phpunit_data_generator is deprecated, please use class testing_module_generator instead', DEBUG_DEVELOPER);