1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
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.
|
|
|
8 |
//
|
|
|
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.
|
|
|
13 |
//
|
|
|
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/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Zoom module test data generator class
|
|
|
19 |
*
|
|
|
20 |
* @package mod_zoom
|
|
|
21 |
* @copyright 2020 UC Regents
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
class mod_zoom_generator extends testing_module_generator {
|
|
|
25 |
/**
|
|
|
26 |
* Creates new Zoom module instance.
|
|
|
27 |
* @param array|stdClass $record
|
|
|
28 |
* @param array|null $options
|
|
|
29 |
* @return stdClass Zoom instance
|
|
|
30 |
*/
|
|
|
31 |
public function create_instance($record = null, ?array $options = null) {
|
|
|
32 |
global $CFG;
|
|
|
33 |
require_once($CFG->dirroot . '/mod/zoom/locallib.php');
|
|
|
34 |
|
|
|
35 |
set_config('clientid', 'test', 'zoom');
|
|
|
36 |
set_config('clientsecret', 'test', 'zoom');
|
|
|
37 |
set_config('accountid', 'test', 'zoom');
|
|
|
38 |
|
|
|
39 |
// Mock Zoom data for testing.
|
|
|
40 |
$defaultzoomsettings = [
|
|
|
41 |
'grade' => 0,
|
|
|
42 |
'name' => 'Test Zoom Meeting',
|
|
|
43 |
'meeting_id' => 1,
|
|
|
44 |
'host_id' => 'test',
|
|
|
45 |
'meetingcode' => '',
|
|
|
46 |
'webinar' => 0,
|
|
|
47 |
'option_host_video' => 0,
|
|
|
48 |
'option_audio' => 0,
|
|
|
49 |
'recurring' => 0,
|
|
|
50 |
'option_participants_video' => 0,
|
|
|
51 |
'option_jbh' => 0,
|
|
|
52 |
'option_waiting_room' => 0,
|
|
|
53 |
'option_mute_upon_entry' => 0,
|
|
|
54 |
'start_time' => mktime(0, 0, 0, 2, 22, 2021),
|
|
|
55 |
'duration' => 60,
|
|
|
56 |
'exists_on_zoom' => ZOOM_MEETING_EXPIRED,
|
|
|
57 |
];
|
|
|
58 |
|
|
|
59 |
$record = (object) (array) $record;
|
|
|
60 |
foreach ($defaultzoomsettings as $name => $value) {
|
|
|
61 |
if (!isset($record->{$name})) {
|
|
|
62 |
$record->{$name} = $value;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
return parent::create_instance($record, $options);
|
|
|
67 |
}
|
|
|
68 |
}
|