Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 32... Línea 32...
32
 * @package   mod_bigbluebuttonbn
32
 * @package   mod_bigbluebuttonbn
33
 * @copyright 2021 Andrew Lyons <andrew@nicols.co.uk>
33
 * @copyright 2021 Andrew Lyons <andrew@nicols.co.uk>
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 * @coversDefaultClass \mod_bigbluebuttonbn\instance
35
 * @coversDefaultClass \mod_bigbluebuttonbn\instance
36
 */
36
 */
37
class instance_test extends advanced_testcase {
37
final class instance_test extends advanced_testcase {
Línea 38... Línea 38...
38
 
38
 
39
    /**
39
    /**
40
     * Test get from
40
     * Test get from
41
     *
41
     *
Línea 63... Línea 63...
63
    /**
63
    /**
64
     * Get from location provider
64
     * Get from location provider
65
     *
65
     *
66
     * @return string[][]
66
     * @return string[][]
67
     */
67
     */
68
    public function get_from_location_provider(): array {
68
    public static function get_from_location_provider(): array {
69
        return [
69
        return [
70
            ['get_from_instanceid', 'id'],
70
            ['get_from_instanceid', 'id'],
71
            ['get_from_cmid', 'cmid'],
71
            ['get_from_cmid', 'cmid'],
72
        ];
72
        ];
73
    }
73
    }
Línea 202... Línea 202...
202
    /**
202
    /**
203
     * Provide invalid meeting examples
203
     * Provide invalid meeting examples
204
     *
204
     *
205
     * @return \string[][]
205
     * @return \string[][]
206
     */
206
     */
207
    public function invalid_meetingid_provider(): array {
207
    public static function invalid_meetingid_provider(): array {
208
        // Meeting IDs are in the formats:
208
        // Meeting IDs are in the formats:
209
        // - <meetingid[string]>-<courseid[number]>-<instanceid[number]>
209
        // - <meetingid[string]>-<courseid[number]>-<instanceid[number]>
210
        // - <meetingid[string]>-<courseid[number]>-<instanceid[number]>[<groupid[number]>]
210
        // - <meetingid[string]>-<courseid[number]>-<instanceid[number]>[<groupid[number]>]
211
        // Note: deducing the group from meeting id will soon be deprecated.
211
        // Note: deducing the group from meeting id will soon be deprecated.
212
        return [
212
        return [
Línea 312... Línea 312...
312
    /**
312
    /**
313
     * Data provider to check the various room_available scenarios'
313
     * Data provider to check the various room_available scenarios'
314
     *
314
     *
315
     * @return array
315
     * @return array
316
     */
316
     */
317
    public function is_currently_open_provider(): array {
317
    public static function is_currently_open_provider(): array {
318
        return [
318
        return [
319
            'No opening or closing time set: Is open' => [null, null, true],
319
            'No opening or closing time set: Is open' => [null, null, true],
320
            'Opening time set in the past, no closing: Is open' => [-DAYSECS, null, true],
320
            'Opening time set in the past, no closing: Is open' => [-DAYSECS, null, true],
321
            'Opening time set in the future, no closing: Is closed' => [+DAYSECS, null, false],
321
            'Opening time set in the future, no closing: Is closed' => [+DAYSECS, null, false],
322
            'Closing time set in the past, no opening: Is closed' => [null, -DAYSECS, false],
322
            'Closing time set in the past, no opening: Is closed' => [null, -DAYSECS, false],
Línea 371... Línea 371...
371
     * @param bool $expected
371
     * @param bool $expected
372
     * @covers ::user_must_wait_to_join
372
     * @covers ::user_must_wait_to_join
373
     */
373
     */
374
    public function test_user_must_wait_to_join(bool $isadmin, bool $ismoderator, bool $haswaitingroom, bool $expected): void {
374
    public function test_user_must_wait_to_join(bool $isadmin, bool $ismoderator, bool $haswaitingroom, bool $expected): void {
375
        $stub = $this->getMockBuilder(instance::class)
375
        $stub = $this->getMockBuilder(instance::class)
376
            ->setMethods([
376
            ->onlyMethods([
377
                'get_instance_var',
377
                'get_instance_var',
378
                'is_admin',
378
                'is_admin',
379
                'is_moderator',
379
                'is_moderator',
380
            ])
380
            ])
381
            ->disableOriginalConstructor()
381
            ->disableOriginalConstructor()
Línea 391... Línea 391...
391
    /**
391
    /**
392
     * Data provider for the user_must_wait_to_join function.
392
     * Data provider for the user_must_wait_to_join function.
393
     *
393
     *
394
     * @return array
394
     * @return array
395
     */
395
     */
396
    public function user_must_wait_to_join_provider(): array {
396
    public static function user_must_wait_to_join_provider(): array {
397
        return [
397
        return [
398
            'Admins must never wait to join (waiting disabled)' => [true, false, false, false],
398
            'Admins must never wait to join (waiting disabled)' => [true, false, false, false],
399
            'Admins must never wait to join (waiting enabled)' => [true, false, true, false],
399
            'Admins must never wait to join (waiting enabled)' => [true, false, true, false],
400
            'Moderators must never wait to join (waiting disabled)' => [false, true, false, false],
400
            'Moderators must never wait to join (waiting disabled)' => [false, true, false, false],
401
            'Moderators must never wait to join (waiting enabled)' => [false, true, true, false],
401
            'Moderators must never wait to join (waiting enabled)' => [false, true, true, false],
Línea 417... Línea 417...
417
        bool $isadmin,
417
        bool $isadmin,
418
        bool $ismoderator,
418
        bool $ismoderator,
419
        bool $expected
419
        bool $expected
420
    ): void {
420
    ): void {
421
        $stub = $this->getMockBuilder(instance::class)
421
        $stub = $this->getMockBuilder(instance::class)
422
            ->setMethods([
422
            ->onlyMethods([
423
                'is_admin',
423
                'is_admin',
424
                'is_moderator',
424
                'is_moderator',
425
            ])
425
            ])
426
            ->disableOriginalConstructor()
426
            ->disableOriginalConstructor()
427
            ->getMock();
427
            ->getMock();
Línea 435... Línea 435...
435
    /**
435
    /**
436
     * Data provider for the does_current_user_count_towards_user_limit function.
436
     * Data provider for the does_current_user_count_towards_user_limit function.
437
     *
437
     *
438
     * @return array
438
     * @return array
439
     */
439
     */
440
    public function does_current_user_count_towards_user_limit_provider(): array {
440
    public static function does_current_user_count_towards_user_limit_provider(): array {
441
        return [
441
        return [
442
            'Admin does not count' => [true, false, false],
442
            'Admin does not count' => [true, false, false],
443
            'Moderator does not count' => [false, true, false],
443
            'Moderator does not count' => [false, true, false],
444
            'Other users do count' => [false, false, true],
444
            'Other users do count' => [false, false, true],
445
        ];
445
        ];
Línea 454... Línea 454...
454
     * @param bool $expectedmodpassword
454
     * @param bool $expectedmodpassword
455
     * @covers ::get_current_user_password
455
     * @covers ::get_current_user_password
456
     */
456
     */
457
    public function test_get_current_user_password(bool $isadmin, bool $ismoderator, bool $expectedmodpassword): void {
457
    public function test_get_current_user_password(bool $isadmin, bool $ismoderator, bool $expectedmodpassword): void {
458
        $stub = $this->getMockBuilder(instance::class)
458
        $stub = $this->getMockBuilder(instance::class)
459
            ->setMethods([
459
            ->onlyMethods([
460
                'is_admin',
460
                'is_admin',
461
                'is_moderator',
461
                'is_moderator',
462
                'get_moderator_password',
462
                'get_moderator_password',
463
                'get_viewer_password',
463
                'get_viewer_password',
464
            ])
464
            ])
Línea 480... Línea 480...
480
    /**
480
    /**
481
     * Data provider for the get_current_user_password function.
481
     * Data provider for the get_current_user_password function.
482
     *
482
     *
483
     * @return array
483
     * @return array
484
     */
484
     */
485
    public function get_current_user_password_provider(): array {
485
    public static function get_current_user_password_provider(): array {
486
        return [
486
        return [
487
            'Admin is a moderator' => [true, false, true],
487
            'Admin is a moderator' => [true, false, true],
488
            'Moderator is a moderator' => [false, true, true],
488
            'Moderator is a moderator' => [false, true, true],
489
            'Others are a viewer' => [false, false, false],
489
            'Others are a viewer' => [false, false, false],
490
        ];
490
        ];
Línea 499... Línea 499...
499
     * @param bool $expectedmodrole
499
     * @param bool $expectedmodrole
500
     * @covers ::get_current_user_role
500
     * @covers ::get_current_user_role
501
     */
501
     */
502
    public function test_get_current_user_role(bool $isadmin, bool $ismoderator, bool $expectedmodrole): void {
502
    public function test_get_current_user_role(bool $isadmin, bool $ismoderator, bool $expectedmodrole): void {
503
        $stub = $this->getMockBuilder(instance::class)
503
        $stub = $this->getMockBuilder(instance::class)
504
            ->setMethods([
504
            ->onlyMethods([
505
                'is_admin',
505
                'is_admin',
506
                'is_moderator',
506
                'is_moderator',
507
            ])
507
            ])
508
            ->disableOriginalConstructor()
508
            ->disableOriginalConstructor()
509
            ->getMock();
509
            ->getMock();
Línea 521... Línea 521...
521
    /**
521
    /**
522
     * Data provider for the get_current_user_role function.
522
     * Data provider for the get_current_user_role function.
523
     *
523
     *
524
     * @return array
524
     * @return array
525
     */
525
     */
526
    public function get_current_user_role_provider(): array {
526
    public static function get_current_user_role_provider(): array {
527
        return [
527
        return [
528
            'Admin is a moderator' => [true, false, true],
528
            'Admin is a moderator' => [true, false, true],
529
            'Moderator is a moderator' => [false, true, true],
529
            'Moderator is a moderator' => [false, true, true],
530
            'Others are a viewer' => [false, false, false],
530
            'Others are a viewer' => [false, false, false],
531
        ];
531
        ];
Línea 544... Línea 544...
544
        bool $isrecorded,
544
        bool $isrecorded,
545
        bool $showbuttons,
545
        bool $showbuttons,
546
        bool $expected
546
        bool $expected
547
    ): void {
547
    ): void {
548
        $stub = $this->getMockBuilder(instance::class)
548
        $stub = $this->getMockBuilder(instance::class)
549
            ->setMethods([
549
            ->onlyMethods([
550
                'is_recorded',
550
                'is_recorded',
551
                'should_show_recording_button',
551
                'should_show_recording_button',
552
            ])
552
            ])
553
            ->disableOriginalConstructor()
553
            ->disableOriginalConstructor()
554
            ->getMock();
554
            ->getMock();
Línea 562... Línea 562...
562
    /**
562
    /**
563
     * Data provider for the allow_recording_start_stop function.
563
     * Data provider for the allow_recording_start_stop function.
564
     *
564
     *
565
     * @return array
565
     * @return array
566
     */
566
     */
567
    public function allow_recording_start_stop_provider(): array {
567
    public static function allow_recording_start_stop_provider(): array {
568
        return [
568
        return [
569
            'Meeting is not recorded: No start/stop' => [false, false, false],
569
            'Meeting is not recorded: No start/stop' => [false, false, false],
570
            'Meeting recorded, Buttons shown: Allow' => [true, true, true],
570
            'Meeting recorded, Buttons shown: Allow' => [true, true, true],
571
            'Meeting recorded, Buttons not shown: Deny' => [true, false, false],
571
            'Meeting recorded, Buttons not shown: Deny' => [true, false, false],
572
        ];
572
        ];