Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   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       */
  40      public function test_get_user_info_outline() {
  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              'Has joined the room 1 time(s)',
  57              'Has played a recording 1 time(s)'
  58          ], $logjoins);
  59          $this->assertCount(2, $logtimes);
  60      }
  61      /**
  62       * Test user info outline with several logs
  63       *
  64       * @return void
  65       */
  66      public function test_get_user_info_outline_several_logs() {
  67          $this->resetAfterTest();
  68  
  69          $generator = $this->getDataGenerator();
  70          $user = $generator->create_and_enrol($this->get_course());
  71          list($bbactivitycontext, $bbactivitycm, $bbactivity) = $this->create_instance();
  72          $this->setUser($user);
  73  
  74          // Now create a couple of logs.
  75          $instance = instance::get_from_instanceid($bbactivity->id);
  76          logger::log_meeting_joined_event($instance, 0);
  77          logger::log_meeting_joined_event($instance, 0);
  78  
  79          [$logjoins, $logtimes] = user_info::get_user_info_outline($this->get_course(), $user, $bbactivitycm);
  80          $this->assertEquals([
  81              'Has joined the room 2 time(s)',
  82          ], $logjoins);
  83          $this->assertCount(1, $logtimes);
  84      }
  85  }