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 |
namespace mod_bigbluebuttonbn\task;
|
|
|
18 |
|
|
|
19 |
use advanced_testcase;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Send guest email tests
|
|
|
23 |
*
|
|
|
24 |
* @package mod_bigbluebuttonbn
|
|
|
25 |
* @copyright 2019 onwards, Blindside Networks Inc
|
|
|
26 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
27 |
* @covers \mod_bigbluebuttonbn\task\send_guest_emails
|
|
|
28 |
* @coversDefaultClass \mod_bigbluebuttonbn\task\send_guest_emails
|
|
|
29 |
*/
|
|
|
30 |
class send_guest_emails_test extends advanced_testcase {
|
|
|
31 |
/**
|
|
|
32 |
* Check if set instance ID works correctly
|
|
|
33 |
*
|
|
|
34 |
*/
|
|
|
35 |
public function test_send_emails(): void {
|
|
|
36 |
$this->resetAfterTest();
|
|
|
37 |
$emailsink = $this->redirectEmails();
|
|
|
38 |
$generator = $this->getDataGenerator();
|
|
|
39 |
$course = $generator->create_course();
|
|
|
40 |
$instancedata = $generator->create_module('bigbluebuttonbn', [
|
|
|
41 |
'course' => $course->id,
|
|
|
42 |
]);
|
|
|
43 |
$moderatoruser = $generator->create_user();
|
|
|
44 |
|
|
|
45 |
$guestemail = new send_guest_emails();
|
|
|
46 |
$guestemail->set_custom_data(
|
|
|
47 |
[
|
|
|
48 |
'emails' => ['test1@email.com', 'test2@email.com'],
|
|
|
49 |
'useridfrom' => $moderatoruser->id
|
|
|
50 |
]
|
|
|
51 |
);
|
|
|
52 |
$guestemail->set_instance_id($instancedata->id);
|
|
|
53 |
\core\task\manager::queue_adhoc_task($guestemail);
|
|
|
54 |
$this->runAdhocTasks();
|
|
|
55 |
|
|
|
56 |
// Check the events.
|
|
|
57 |
$messages = $emailsink->get_messages();
|
|
|
58 |
$this->assertCount(2, $messages);
|
|
|
59 |
|
|
|
60 |
$this->assertEquals('Invitation: BigBlueButton 1 session in Test course 1', $messages[0]->subject);
|
|
|
61 |
$this->assertEquals('noreply@www.example.com', $messages[0]->from);
|
|
|
62 |
$this->assertEquals('test1@email.com', $messages[0]->to);
|
|
|
63 |
$this->assertEquals('test2@email.com', $messages[1]->to);
|
|
|
64 |
|
|
|
65 |
}
|
|
|
66 |
}
|