Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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;
  17  
  18  use advanced_testcase;
  19  use moodle_exception;
  20  
  21  /**
  22   * Tests for the Big Blue Button Plugin class.
  23   *
  24   * @package   mod_bigbluebuttonbn
  25   * @copyright 2021 Andrew Lyons <andrew@nicols.co.uk>
  26   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   * @coversDefaultClass \mod_bigbluebuttonbn\plugin
  28   */
  29  class plugin_test extends advanced_testcase {
  30  
  31      /**
  32       * Test html2text
  33       *
  34       * @covers ::html2text
  35       */
  36      public function test_html2text(): void {
  37          $this->assertEquals('My text is in HTML', plugin::html2text('<p>My text is&nbsp;in HTML</p>', 100));
  38          $this->assertEquals('My...', plugin::html2text('<p>My text is&nbsp;in HTML</p>', 2));
  39      }
  40  
  41      /**
  42       * Test random_password
  43       *
  44       * @covers ::random_password
  45       */
  46      public function test_random_password(): void {
  47          $password = plugin::random_password(10);
  48          $this->assertEquals(10, strlen($password));
  49          $this->assertMatchesRegularExpression(
  50              '/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]+/', $password);
  51      }
  52  
  53      /**
  54       * Test generate_guest_meeting_credentials
  55       *
  56       * @covers ::generate_guest_meeting_credentials
  57       */
  58      public function test_generate_guest_meeting_credentials(): void {
  59          [$guestlinkuid, $password] = plugin::generate_guest_meeting_credentials();
  60          $this->assertEquals(40, strlen($guestlinkuid));
  61      }
  62  }