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 |
namespace mod_bigbluebuttonbn\local\helpers;
|
|
|
17 |
|
|
|
18 |
use mod_bigbluebuttonbn\instance;
|
|
|
19 |
use mod_bigbluebuttonbn\logger;
|
|
|
20 |
use mod_bigbluebuttonbn\test\testcase_helper_trait;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* User information printing test
|
|
|
24 |
*
|
|
|
25 |
* @package mod_bigbluebuttonbn
|
|
|
26 |
* @copyright 2022 - present, Blindside Networks Inc
|
|
|
27 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
28 |
* @author Laurent David (laurent@call-learning.fr)
|
|
|
29 |
* @covers \mod_bigbluebuttonbn\local\helpers\user_info
|
|
|
30 |
* @coversDefaultClass \mod_bigbluebuttonbn\local\helpers\user_info
|
|
|
31 |
*/
|
|
|
32 |
class user_info_test extends \advanced_testcase {
|
|
|
33 |
use testcase_helper_trait;
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* Test user info outline
|
|
|
37 |
*
|
|
|
38 |
* @return void
|
|
|
39 |
*/
|
11 |
efrain |
40 |
public function test_get_user_info_outline(): void {
|
1 |
efrain |
41 |
$this->initialise_mock_server();
|
|
|
42 |
$this->resetAfterTest();
|
|
|
43 |
|
|
|
44 |
$generator = $this->getDataGenerator();
|
|
|
45 |
$user = $generator->create_and_enrol($this->get_course());
|
|
|
46 |
list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
|
|
|
47 |
$this->setUser($user);
|
|
|
48 |
|
|
|
49 |
// Now create a couple of logs.
|
|
|
50 |
$instance = instance::get_from_instanceid($bbactivity->id);
|
|
|
51 |
$recordings = $this->create_recordings_for_instance($instance, [['name' => "Pre-Recording 1"]]);
|
|
|
52 |
logger::log_meeting_joined_event($instance, 0);
|
|
|
53 |
logger::log_recording_played_event($instance, $recordings[0]->id);
|
|
|
54 |
[$logjoins, $logtimes] = user_info::get_user_info_outline($this->get_course(), $user, $bbactivitycm);
|
|
|
55 |
$this->assertEquals([
|
|
|
56 |
'1 meeting(s)',
|
|
|
57 |
'1 recording(s) played'
|
|
|
58 |
], $logjoins);
|
|
|
59 |
$this->assertCount(2, $logtimes);
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
/**
|
|
|
63 |
* Test user info outline with several logs
|
|
|
64 |
*
|
|
|
65 |
* @return void
|
|
|
66 |
*/
|
11 |
efrain |
67 |
public function test_get_user_info_outline_several_logs(): void {
|
1 |
efrain |
68 |
$this->resetAfterTest();
|
|
|
69 |
|
|
|
70 |
$generator = $this->getDataGenerator();
|
|
|
71 |
$user = $generator->create_and_enrol($this->get_course());
|
|
|
72 |
list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
|
|
|
73 |
$this->setUser($user);
|
|
|
74 |
|
|
|
75 |
// Now create a couple of logs.
|
|
|
76 |
$instance = instance::get_from_instanceid($bbactivity->id);
|
|
|
77 |
logger::log_meeting_joined_event($instance, 0);
|
|
|
78 |
logger::log_meeting_joined_event($instance, 0);
|
|
|
79 |
|
|
|
80 |
[$logjoins, $logtimes] = user_info::get_user_info_outline($this->get_course(), $user, $bbactivitycm);
|
|
|
81 |
$this->assertEquals([
|
|
|
82 |
'2 meeting(s)',
|
|
|
83 |
], $logjoins);
|
|
|
84 |
$this->assertCount(1, $logtimes);
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
/**
|
|
|
88 |
* Test user info outline for view events
|
|
|
89 |
*
|
|
|
90 |
* @return void
|
|
|
91 |
*/
|
11 |
efrain |
92 |
public function test_get_user_info_outline_view(): void {
|
1 |
efrain |
93 |
$this->initialise_mock_server();
|
|
|
94 |
$this->resetAfterTest();
|
|
|
95 |
|
|
|
96 |
$generator = $this->getDataGenerator();
|
|
|
97 |
$user = $generator->create_and_enrol($this->get_course());
|
|
|
98 |
list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance(
|
|
|
99 |
null,
|
|
|
100 |
['completion' => 2, 'completionview' => 1]);
|
|
|
101 |
$this->setUser($user);
|
|
|
102 |
|
|
|
103 |
// Now create a couple of logs.
|
|
|
104 |
$instance = instance::get_from_instanceid($bbactivity->id);
|
|
|
105 |
// View it twice.
|
|
|
106 |
bigbluebuttonbn_view($instance->get_instance_data(), $instance->get_course(), $instance->get_cm(),
|
|
|
107 |
$instance->get_context());
|
|
|
108 |
bigbluebuttonbn_view($instance->get_instance_data(), $instance->get_course(), $instance->get_cm(),
|
|
|
109 |
$instance->get_context());
|
|
|
110 |
[$logjoins, $logtimes] = user_info::get_user_info_outline($this->get_course(), $user, $bbactivitycm);
|
|
|
111 |
$this->assertEquals([
|
|
|
112 |
'viewed',
|
|
|
113 |
], $logjoins);
|
|
|
114 |
$this->assertCount(1, $logtimes);
|
|
|
115 |
}
|
|
|
116 |
}
|