Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 103... Línea 103...
103
    }
103
    }
Línea 104... Línea 104...
104
 
104
 
105
    /**
105
    /**
106
     * Test send_instant_messages.
106
     * Test send_instant_messages.
107
     */
107
     */
108
    public function test_send_instant_messages() {
108
    public function test_send_instant_messages(): void {
Línea 109... Línea 109...
109
        global $DB, $USER;
109
        global $DB, $USER;
Línea 110... Línea 110...
110
 
110
 
Línea 160... Línea 160...
160
    }
160
    }
Línea 161... Línea 161...
161
 
161
 
162
    /**
162
    /**
163
     * Test send_instant_messages with a message text longer than permitted.
163
     * Test send_instant_messages with a message text longer than permitted.
164
     */
164
     */
165
    public function test_send_instant_messages_long_text() {
165
    public function test_send_instant_messages_long_text(): void {
Línea 166... Línea 166...
166
        global $CFG;
166
        global $CFG;
Línea 167... Línea 167...
167
 
167
 
Línea 195... Línea 195...
195
    }
195
    }
Línea 196... Línea 196...
196
 
196
 
197
    /**
197
    /**
198
     * Test send_instant_messages to a user who has blocked you.
198
     * Test send_instant_messages to a user who has blocked you.
199
     */
199
     */
200
    public function test_send_instant_messages_blocked_user() {
200
    public function test_send_instant_messages_blocked_user(): void {
Línea 201... Línea 201...
201
        global $DB;
201
        global $DB;
Línea 202... Línea 202...
202
 
202
 
Línea 230... Línea 230...
230
    }
230
    }
Línea 231... Línea 231...
231
 
231
 
232
    /**
232
    /**
233
     * Test send_instant_messages when sending a message to a non-contact who has blocked non-contacts.
233
     * Test send_instant_messages when sending a message to a non-contact who has blocked non-contacts.
234
     */
234
     */
235
    public function test_send_instant_messages_block_non_contacts() {
235
    public function test_send_instant_messages_block_non_contacts(): void {
Línea 236... Línea 236...
236
        global $DB;
236
        global $DB;
Línea 237... Línea 237...
237
 
237
 
Línea 266... Línea 266...
266
    }
266
    }
Línea 267... Línea 267...
267
 
267
 
268
    /**
268
    /**
269
     * Test send_instant_messages when sending a message to a contact who has blocked non-contacts.
269
     * Test send_instant_messages when sending a message to a contact who has blocked non-contacts.
270
     */
270
     */
271
    public function test_send_instant_messages_block_non_contacts_but_am_contact() {
271
    public function test_send_instant_messages_block_non_contacts_but_am_contact(): void {
Línea 272... Línea 272...
272
        global $DB, $USER;
272
        global $DB, $USER;
Línea 273... Línea 273...
273
 
273
 
Línea 316... Línea 316...
316
    }
316
    }
Línea 317... Línea 317...
317
 
317
 
318
    /**
318
    /**
319
     * Test send_instant_messages with no capabilities
319
     * Test send_instant_messages with no capabilities
320
     */
320
     */
321
    public function test_send_instant_messages_no_capability() {
321
    public function test_send_instant_messages_no_capability(): void {
Línea 322... Línea 322...
322
        global $DB;
322
        global $DB;
Línea 323... Línea 323...
323
 
323
 
Línea 348... Línea 348...
348
    }
348
    }
Línea 349... Línea 349...
349
 
349
 
350
    /**
350
    /**
351
     * Test send_instant_messages when messaging is disabled.
351
     * Test send_instant_messages when messaging is disabled.
352
     */
352
     */
353
    public function test_send_instant_messages_messaging_disabled() {
353
    public function test_send_instant_messages_messaging_disabled(): void {
Línea 354... Línea 354...
354
        global $CFG;
354
        global $CFG;
Línea 355... Línea 355...
355
 
355
 
Línea 378... Línea 378...
378
    }
378
    }
Línea 379... Línea 379...
379
 
379
 
380
    /**
380
    /**
381
     * Test delete_contacts.
381
     * Test delete_contacts.
382
     */
382
     */
383
    public function test_delete_contacts() {
383
    public function test_delete_contacts(): void {
Línea 384... Línea 384...
384
        $this->resetAfterTest(true);
384
        $this->resetAfterTest(true);
385
 
385
 
386
        $user1 = self::getDataGenerator()->create_user();
386
        $user1 = self::getDataGenerator()->create_user();
Línea 423... Línea 423...
423
    }
423
    }
Línea 424... Línea 424...
424
 
424
 
425
    /**
425
    /**
426
     * Test getting contact requests.
426
     * Test getting contact requests.
427
     */
427
     */
428
    public function test_get_contact_requests() {
428
    public function test_get_contact_requests(): void {
Línea 429... Línea 429...
429
        global $PAGE;
429
        global $PAGE;
Línea 430... Línea 430...
430
 
430
 
Línea 462... Línea 462...
462
    }
462
    }
Línea 463... Línea 463...
463
 
463
 
464
    /**
464
    /**
465
     * Test the get_contact_requests() function when the user has blocked the sender of the request.
465
     * Test the get_contact_requests() function when the user has blocked the sender of the request.
466
     */
466
     */
467
    public function test_get_contact_requests_blocked_sender() {
467
    public function test_get_contact_requests_blocked_sender(): void {
468
        $this->resetAfterTest();
468
        $this->resetAfterTest();
469
        $user1 = self::getDataGenerator()->create_user();
469
        $user1 = self::getDataGenerator()->create_user();
Línea 470... Línea 470...
470
        $user2 = self::getDataGenerator()->create_user();
470
        $user2 = self::getDataGenerator()->create_user();
Línea 484... Línea 484...
484
    }
484
    }
Línea 485... Línea 485...
485
 
485
 
486
    /**
486
    /**
487
     * Test getting contact requests when there are none.
487
     * Test getting contact requests when there are none.
488
     */
488
     */
489
    public function test_get_contact_requests_no_requests() {
489
    public function test_get_contact_requests_no_requests(): void {
Línea 490... Línea 490...
490
        $this->resetAfterTest();
490
        $this->resetAfterTest();
Línea 491... Línea 491...
491
 
491
 
Línea 500... Línea 500...
500
    }
500
    }
Línea 501... Línea 501...
501
 
501
 
502
    /**
502
    /**
503
     * Test getting contact requests with limits.
503
     * Test getting contact requests with limits.
504
     */
504
     */
505
    public function test_get_contact_requests_with_limits() {
505
    public function test_get_contact_requests_with_limits(): void {
Línea 506... Línea 506...
506
        $this->resetAfterTest();
506
        $this->resetAfterTest();
507
 
507
 
508
        $user1 = self::getDataGenerator()->create_user();
508
        $user1 = self::getDataGenerator()->create_user();
Línea 521... Línea 521...
521
    }
521
    }
Línea 522... Línea 522...
522
 
522
 
523
    /**
523
    /**
524
     * Test getting contact requests with messaging disabled.
524
     * Test getting contact requests with messaging disabled.
525
     */
525
     */
526
    public function test_get_contact_requests_messaging_disabled() {
526
    public function test_get_contact_requests_messaging_disabled(): void {
Línea 527... Línea 527...
527
        global $CFG;
527
        global $CFG;
Línea 528... Línea 528...
528
 
528
 
Línea 542... Línea 542...
542
    }
542
    }
Línea 543... Línea 543...
543
 
543
 
544
    /**
544
    /**
545
     * Test getting contact requests with no permission.
545
     * Test getting contact requests with no permission.
546
     */
546
     */
547
    public function test_get_contact_requests_no_permission() {
547
    public function test_get_contact_requests_no_permission(): void {
Línea 548... Línea 548...
548
        $this->resetAfterTest();
548
        $this->resetAfterTest();
549
 
549
 
550
        // Create some skeleton data just so we can call the WS.
550
        // Create some skeleton data just so we can call the WS.
Línea 560... Línea 560...
560
    }
560
    }
Línea 561... Línea 561...
561
 
561
 
562
    /**
562
    /**
563
     * Test getting the number of received contact requests.
563
     * Test getting the number of received contact requests.
564
     */
564
     */
565
    public function test_get_received_contact_requests_count() {
565
    public function test_get_received_contact_requests_count(): void {
Línea 566... Línea 566...
566
        $this->resetAfterTest();
566
        $this->resetAfterTest();
567
 
567
 
568
        $user1 = self::getDataGenerator()->create_user();
568
        $user1 = self::getDataGenerator()->create_user();
Línea 601... Línea 601...
601
    }
601
    }
Línea 602... Línea 602...
602
 
602
 
603
    /**
603
    /**
604
     * Test the get_received_contact_requests_count() function when the user has blocked the sender of the request.
604
     * Test the get_received_contact_requests_count() function when the user has blocked the sender of the request.
605
     */
605
     */
606
    public function test_get_received_contact_requests_count_blocked_sender() {
606
    public function test_get_received_contact_requests_count_blocked_sender(): void {
607
        $this->resetAfterTest();
607
        $this->resetAfterTest();
608
        $user1 = self::getDataGenerator()->create_user();
608
        $user1 = self::getDataGenerator()->create_user();
Línea 609... Línea 609...
609
        $user2 = self::getDataGenerator()->create_user();
609
        $user2 = self::getDataGenerator()->create_user();
Línea 623... Línea 623...
623
    }
623
    }
Línea 624... Línea 624...
624
 
624
 
625
    /**
625
    /**
626
     * Test getting the number of received contact requests with no permissions.
626
     * Test getting the number of received contact requests with no permissions.
627
     */
627
     */
628
    public function test_get_received_contact_requests_count_no_permission() {
628
    public function test_get_received_contact_requests_count_no_permission(): void {
Línea 629... Línea 629...
629
        $this->resetAfterTest();
629
        $this->resetAfterTest();
630
 
630
 
631
        // Create some skeleton data just so we can call the WS.
631
        // Create some skeleton data just so we can call the WS.
Línea 640... Línea 640...
640
    }
640
    }
Línea 641... Línea 641...
641
 
641
 
642
    /**
642
    /**
643
     * Test getting the number of received contact requests with messaging disabled.
643
     * Test getting the number of received contact requests with messaging disabled.
644
     */
644
     */
645
    public function test_get_received_contact_requests_count_messaging_disabled() {
645
    public function test_get_received_contact_requests_count_messaging_disabled(): void {
Línea 646... Línea 646...
646
        global $CFG;
646
        global $CFG;
Línea 647... Línea 647...
647
 
647
 
Línea 661... Línea 661...
661
    }
661
    }
Línea 662... Línea 662...
662
 
662
 
663
    /**
663
    /**
664
     * Test creating a contact request.
664
     * Test creating a contact request.
665
     */
665
     */
666
    public function test_create_contact_request() {
666
    public function test_create_contact_request(): void {
Línea 667... Línea 667...
667
        global $CFG, $DB;
667
        global $CFG, $DB;
Línea 668... Línea 668...
668
 
668
 
Línea 693... Línea 693...
693
    }
693
    }
Línea 694... Línea 694...
694
 
694
 
695
    /**
695
    /**
696
     * Test creating a contact request when not allowed.
696
     * Test creating a contact request when not allowed.
697
     */
697
     */
698
    public function test_create_contact_request_not_allowed() {
698
    public function test_create_contact_request_not_allowed(): void {
Línea 699... Línea 699...
699
        global $CFG;
699
        global $CFG;
Línea 700... Línea 700...
700
 
700
 
Línea 719... Línea 719...
719
    }
719
    }
Línea 720... Línea 720...
720
 
720
 
721
    /**
721
    /**
722
     * Test creating a contact request with messaging disabled.
722
     * Test creating a contact request with messaging disabled.
723
     */
723
     */
724
    public function test_create_contact_request_messaging_disabled() {
724
    public function test_create_contact_request_messaging_disabled(): void {
Línea 725... Línea 725...
725
        global $CFG;
725
        global $CFG;
Línea 726... Línea 726...
726
 
726
 
Línea 741... Línea 741...
741
    }
741
    }
Línea 742... Línea 742...
742
 
742
 
743
    /**
743
    /**
744
     * Test creating a contact request with no permission.
744
     * Test creating a contact request with no permission.
745
     */
745
     */
746
    public function test_create_contact_request_no_permission() {
746
    public function test_create_contact_request_no_permission(): void {
Línea 747... Línea 747...
747
        $this->resetAfterTest();
747
        $this->resetAfterTest();
748
 
748
 
749
        // Create some skeleton data just so we can call the WS.
749
        // Create some skeleton data just so we can call the WS.
Línea 759... Línea 759...
759
    }
759
    }
Línea 760... Línea 760...
760
 
760
 
761
    /**
761
    /**
762
     * Test confirming a contact request.
762
     * Test confirming a contact request.
763
     */
763
     */
764
    public function test_confirm_contact_request() {
764
    public function test_confirm_contact_request(): void {
Línea 765... Línea 765...
765
        global $DB;
765
        global $DB;
Línea 766... Línea 766...
766
 
766
 
Línea 792... Línea 792...
792
    }
792
    }
Línea 793... Línea 793...
793
 
793
 
794
    /**
794
    /**
795
     * Test confirming a contact request with messaging disabled.
795
     * Test confirming a contact request with messaging disabled.
796
     */
796
     */
797
    public function test_confirm_contact_request_messaging_disabled() {
797
    public function test_confirm_contact_request_messaging_disabled(): void {
Línea 798... Línea 798...
798
        global $CFG;
798
        global $CFG;
Línea 799... Línea 799...
799
 
799
 
Línea 814... Línea 814...
814
    }
814
    }
Línea 815... Línea 815...
815
 
815
 
816
    /**
816
    /**
817
     * Test confirming a contact request with no permission.
817
     * Test confirming a contact request with no permission.
818
     */
818
     */
819
    public function test_confirm_contact_request_no_permission() {
819
    public function test_confirm_contact_request_no_permission(): void {
Línea 820... Línea 820...
820
        $this->resetAfterTest();
820
        $this->resetAfterTest();
821
 
821
 
822
        // Create some skeleton data just so we can call the WS.
822
        // Create some skeleton data just so we can call the WS.
Línea 832... Línea 832...
832
    }
832
    }
Línea 833... Línea 833...
833
 
833
 
834
    /**
834
    /**
835
     * Test declining a contact request.
835
     * Test declining a contact request.
836
     */
836
     */
837
    public function test_decline_contact_request() {
837
    public function test_decline_contact_request(): void {
Línea 838... Línea 838...
838
        global $DB;
838
        global $DB;
Línea 839... Línea 839...
839
 
839
 
Línea 857... Línea 857...
857
    }
857
    }
Línea 858... Línea 858...
858
 
858
 
859
    /**
859
    /**
860
     * Test declining a contact request with messaging disabled.
860
     * Test declining a contact request with messaging disabled.
861
     */
861
     */
862
    public function test_decline_contact_request_messaging_disabled() {
862
    public function test_decline_contact_request_messaging_disabled(): void {
Línea 863... Línea 863...
863
        global $CFG;
863
        global $CFG;
Línea 864... Línea 864...
864
 
864
 
Línea 879... Línea 879...
879
    }
879
    }
Línea 880... Línea 880...
880
 
880
 
881
    /**
881
    /**
882
     * Test declining a contact request with no permission.
882
     * Test declining a contact request with no permission.
883
     */
883
     */
884
    public function test_decline_contact_request_no_permission() {
884
    public function test_decline_contact_request_no_permission(): void {
Línea 885... Línea 885...
885
        $this->resetAfterTest();
885
        $this->resetAfterTest();
886
 
886
 
887
        // Create some skeleton data just so we can call the WS.
887
        // Create some skeleton data just so we can call the WS.
Línea 897... Línea 897...
897
    }
897
    }
Línea 898... Línea 898...
898
 
898
 
899
    /**
899
    /**
900
     * Test muting conversations.
900
     * Test muting conversations.
901
     */
901
     */
902
    public function test_mute_conversations() {
902
    public function test_mute_conversations(): void {
Línea 903... Línea 903...
903
        global $DB;
903
        global $DB;
Línea 904... Línea 904...
904
 
904
 
Línea 933... Línea 933...
933
    }
933
    }
Línea 934... Línea 934...
934
 
934
 
935
    /**
935
    /**
936
     * Test muting a conversation with messaging disabled.
936
     * Test muting a conversation with messaging disabled.
937
     */
937
     */
938
    public function test_mute_conversations_messaging_disabled() {
938
    public function test_mute_conversations_messaging_disabled(): void {
Línea 939... Línea 939...
939
        global $CFG;
939
        global $CFG;
Línea 940... Línea 940...
940
 
940
 
Línea 958... Línea 958...
958
    }
958
    }
Línea 959... Línea 959...
959
 
959
 
960
    /**
960
    /**
961
     * Test muting a conversation with no permission.
961
     * Test muting a conversation with no permission.
962
     */
962
     */
963
    public function test_mute_conversations_no_permission() {
963
    public function test_mute_conversations_no_permission(): void {
Línea 964... Línea 964...
964
        $this->resetAfterTest();
964
        $this->resetAfterTest();
965
 
965
 
966
        // Create some skeleton data just so we can call the WS.
966
        // Create some skeleton data just so we can call the WS.
Línea 979... Línea 979...
979
    }
979
    }
Línea 980... Línea 980...
980
 
980
 
981
    /**
981
    /**
982
     * Test unmuting conversations.
982
     * Test unmuting conversations.
983
     */
983
     */
984
    public function test_unmute_conversations() {
984
    public function test_unmute_conversations(): void {
Línea 985... Línea 985...
985
        global $DB;
985
        global $DB;
Línea 986... Línea 986...
986
 
986
 
Línea 1013... Línea 1013...
1013
    }
1013
    }
Línea 1014... Línea 1014...
1014
 
1014
 
1015
    /**
1015
    /**
1016
     * Test unmuting a conversation with messaging disabled.
1016
     * Test unmuting a conversation with messaging disabled.
1017
     */
1017
     */
1018
    public function test_unmute_conversation_messaging_disabled() {
1018
    public function test_unmute_conversation_messaging_disabled(): void {
Línea 1019... Línea 1019...
1019
        global $CFG;
1019
        global $CFG;
Línea 1020... Línea 1020...
1020
 
1020
 
Línea 1038... Línea 1038...
1038
    }
1038
    }
Línea 1039... Línea 1039...
1039
 
1039
 
1040
    /**
1040
    /**
1041
     * Test unmuting a conversation with no permission.
1041
     * Test unmuting a conversation with no permission.
1042
     */
1042
     */
1043
    public function test_unmute_conversation_no_permission() {
1043
    public function test_unmute_conversation_no_permission(): void {
Línea 1044... Línea 1044...
1044
        $this->resetAfterTest();
1044
        $this->resetAfterTest();
1045
 
1045
 
1046
        // Create some skeleton data just so we can call the WS.
1046
        // Create some skeleton data just so we can call the WS.
Línea 1059... Línea 1059...
1059
    }
1059
    }
Línea 1060... Línea 1060...
1060
 
1060
 
1061
    /**
1061
    /**
1062
     * Test blocking a user.
1062
     * Test blocking a user.
1063
     */
1063
     */
1064
    public function test_block_user() {
1064
    public function test_block_user(): void {
Línea 1065... Línea 1065...
1065
        global $DB;
1065
        global $DB;
Línea 1066... Línea 1066...
1066
 
1066
 
Línea 1091... Línea 1091...
1091
    }
1091
    }
Línea 1092... Línea 1092...
1092
 
1092
 
1093
    /**
1093
    /**
1094
     * Test blocking a user.
1094
     * Test blocking a user.
1095
     */
1095
     */
1096
    public function test_block_user_when_ineffective() {
1096
    public function test_block_user_when_ineffective(): void {
Línea 1097... Línea 1097...
1097
        global $DB;
1097
        global $DB;
Línea 1098... Línea 1098...
1098
 
1098
 
Línea 1115... Línea 1115...
1115
    }
1115
    }
Línea 1116... Línea 1116...
1116
 
1116
 
1117
    /**
1117
    /**
1118
     * Test blocking a user with messaging disabled.
1118
     * Test blocking a user with messaging disabled.
1119
     */
1119
     */
1120
    public function test_block_user_messaging_disabled() {
1120
    public function test_block_user_messaging_disabled(): void {
Línea 1121... Línea 1121...
1121
        global $CFG;
1121
        global $CFG;
Línea 1122... Línea 1122...
1122
 
1122
 
Línea 1137... Línea 1137...
1137
    }
1137
    }
Línea 1138... Línea 1138...
1138
 
1138
 
1139
    /**
1139
    /**
1140
     * Test blocking a user with no permission.
1140
     * Test blocking a user with no permission.
1141
     */
1141
     */
1142
    public function test_block_user_no_permission() {
1142
    public function test_block_user_no_permission(): void {
Línea 1143... Línea 1143...
1143
        $this->resetAfterTest();
1143
        $this->resetAfterTest();
1144
 
1144
 
1145
        // Create some skeleton data just so we can call the WS.
1145
        // Create some skeleton data just so we can call the WS.
Línea 1155... Línea 1155...
1155
    }
1155
    }
Línea 1156... Línea 1156...
1156
 
1156
 
1157
    /**
1157
    /**
1158
     * Test unblocking a user.
1158
     * Test unblocking a user.
1159
     */
1159
     */
1160
    public function test_unblock_user() {
1160
    public function test_unblock_user(): void {
Línea 1161... Línea 1161...
1161
        global $DB;
1161
        global $DB;
Línea 1162... Línea 1162...
1162
 
1162
 
Línea 1186... Línea 1186...
1186
    }
1186
    }
Línea 1187... Línea 1187...
1187
 
1187
 
1188
    /**
1188
    /**
1189
     * Test unblocking a user with messaging disabled.
1189
     * Test unblocking a user with messaging disabled.
1190
     */
1190
     */
1191
    public function test_unblock_user_messaging_disabled() {
1191
    public function test_unblock_user_messaging_disabled(): void {
Línea 1192... Línea 1192...
1192
        global $CFG;
1192
        global $CFG;
Línea 1193... Línea 1193...
1193
 
1193
 
Línea 1208... Línea 1208...
1208
    }
1208
    }
Línea 1209... Línea 1209...
1209
 
1209
 
1210
    /**
1210
    /**
1211
     * Test unblocking a user with no permission.
1211
     * Test unblocking a user with no permission.
1212
     */
1212
     */
1213
    public function test_unblock_user_no_permission() {
1213
    public function test_unblock_user_no_permission(): void {
Línea 1214... Línea 1214...
1214
        $this->resetAfterTest();
1214
        $this->resetAfterTest();
1215
 
1215
 
1216
        // Create some skeleton data just so we can call the WS.
1216
        // Create some skeleton data just so we can call the WS.
Línea 1226... Línea 1226...
1226
    }
1226
    }
Línea 1227... Línea 1227...
1227
 
1227
 
1228
    /**
1228
    /**
1229
     * Test search_contacts.
1229
     * Test search_contacts.
1230
     */
1230
     */
1231
    public function test_search_contacts() {
1231
    public function test_search_contacts(): void {
1232
        global $DB;
1232
        global $DB;
Línea 1233... Línea 1233...
1233
        $this->resetAfterTest(true);
1233
        $this->resetAfterTest(true);
1234
 
1234
 
Línea 1293... Línea 1293...
1293
    }
1293
    }
Línea 1294... Línea 1294...
1294
 
1294
 
1295
    /**
1295
    /**
1296
     * Test get_messages.
1296
     * Test get_messages.
1297
     */
1297
     */
1298
    public function test_get_messages() {
1298
    public function test_get_messages(): void {
1299
        global $CFG, $DB, $PAGE;
1299
        global $CFG, $DB, $PAGE;
Línea 1300... Línea 1300...
1300
        $this->resetAfterTest(true);
1300
        $this->resetAfterTest(true);
Línea 1537... Línea 1537...
1537
    }
1537
    }
Línea 1538... Línea 1538...
1538
 
1538
 
1539
    /**
1539
    /**
1540
     * Test get_messages where we want all messages from a user, sent to any user.
1540
     * Test get_messages where we want all messages from a user, sent to any user.
1541
     */
1541
     */
1542
    public function test_get_messages_useridto_all() {
1542
    public function test_get_messages_useridto_all(): void {
Línea 1543... Línea 1543...
1543
        $this->resetAfterTest(true);
1543
        $this->resetAfterTest(true);
1544
 
1544
 
1545
        $user1 = self::getDataGenerator()->create_user();
1545
        $user1 = self::getDataGenerator()->create_user();
Línea 1571... Línea 1571...
1571
    }
1571
    }
Línea 1572... Línea 1572...
1572
 
1572
 
1573
    /**
1573
    /**
1574
     * Test get_messages where we want all messages to a user, sent by any user.
1574
     * Test get_messages where we want all messages to a user, sent by any user.
1575
     */
1575
     */
1576
    public function test_get_messages_useridfrom_all() {
1576
    public function test_get_messages_useridfrom_all(): void {
Línea 1577... Línea 1577...
1577
        $this->resetAfterTest();
1577
        $this->resetAfterTest();
1578
 
1578
 
1579
        $user1 = self::getDataGenerator()->create_user();
1579
        $user1 = self::getDataGenerator()->create_user();
Línea 1605... Línea 1605...
1605
    }
1605
    }
Línea 1606... Línea 1606...
1606
 
1606
 
1607
    /**
1607
    /**
1608
     * Test get_blocked_users.
1608
     * Test get_blocked_users.
1609
     */
1609
     */
1610
    public function test_get_blocked_users() {
1610
    public function test_get_blocked_users(): void {
Línea 1611... Línea 1611...
1611
        $this->resetAfterTest(true);
1611
        $this->resetAfterTest(true);
1612
 
1612
 
1613
        $user1 = self::getDataGenerator()->create_user();
1613
        $user1 = self::getDataGenerator()->create_user();
Línea 1650... Línea 1650...
1650
    }
1650
    }
Línea 1651... Línea 1651...
1651
 
1651
 
1652
    /**
1652
    /**
1653
     * Test mark_message_read.
1653
     * Test mark_message_read.
1654
     */
1654
     */
1655
    public function test_mark_message_read() {
1655
    public function test_mark_message_read(): void {
Línea 1656... Línea 1656...
1656
        $this->resetAfterTest(true);
1656
        $this->resetAfterTest(true);
1657
 
1657
 
1658
        $user1 = self::getDataGenerator()->create_user();
1658
        $user1 = self::getDataGenerator()->create_user();
Línea 1709... Línea 1709...
1709
    }
1709
    }
Línea 1710... Línea 1710...
1710
 
1710
 
1711
    /**
1711
    /**
1712
     * Test mark_notification_read.
1712
     * Test mark_notification_read.
1713
     */
1713
     */
1714
    public function test_mark_notification_read() {
1714
    public function test_mark_notification_read(): void {
Línea 1715... Línea 1715...
1715
        $this->resetAfterTest(true);
1715
        $this->resetAfterTest(true);
1716
 
1716
 
1717
        $user1 = self::getDataGenerator()->create_user();
1717
        $user1 = self::getDataGenerator()->create_user();
Línea 1769... Línea 1769...
1769
    }
1769
    }
Línea 1770... Línea 1770...
1770
 
1770
 
1771
    /**
1771
    /**
1772
     * Test delete_message.
1772
     * Test delete_message.
1773
     */
1773
     */
1774
    public function test_delete_message() {
1774
    public function test_delete_message(): void {
1775
        global $DB;
1775
        global $DB;
Línea 1776... Línea 1776...
1776
        $this->resetAfterTest(true);
1776
        $this->resetAfterTest(true);
1777
 
1777
 
Línea 1868... Línea 1868...
1868
        $this->assertTrue($DB->record_exists('message_user_actions', array('messageid' => $m3to4, 'userid' => $user4->id,
1868
        $this->assertTrue($DB->record_exists('message_user_actions', array('messageid' => $m3to4, 'userid' => $user4->id,
1869
            'action' => \core_message\api::MESSAGE_ACTION_DELETED)));
1869
            'action' => \core_message\api::MESSAGE_ACTION_DELETED)));
Línea 1870... Línea 1870...
1870
 
1870
 
Línea 1871... Línea 1871...
1871
    }
1871
    }
1872
 
1872
 
Línea 1873... Línea 1873...
1873
    public function test_mark_all_notifications_as_read_invalid_user_exception() {
1873
    public function test_mark_all_notifications_as_read_invalid_user_exception(): void {
1874
        $this->resetAfterTest(true);
1874
        $this->resetAfterTest(true);
1875
 
1875
 
Línea 1876... Línea 1876...
1876
        $this->expectException('moodle_exception');
1876
        $this->expectException('moodle_exception');
1877
        core_message_external::mark_all_notifications_as_read(-2132131, 0);
1877
        core_message_external::mark_all_notifications_as_read(-2132131, 0);
Línea 1878... Línea 1878...
1878
    }
1878
    }
1879
 
1879
 
Línea 1880... Línea 1880...
1880
    public function test_mark_all_notifications_as_read_access_denied_exception() {
1880
    public function test_mark_all_notifications_as_read_access_denied_exception(): void {
1881
        $this->resetAfterTest(true);
1881
        $this->resetAfterTest(true);
1882
 
1882
 
1883
        $sender = $this->getDataGenerator()->create_user();
1883
        $sender = $this->getDataGenerator()->create_user();
Línea 1884... Línea 1884...
1884
        $user = $this->getDataGenerator()->create_user();
1884
        $user = $this->getDataGenerator()->create_user();
1885
 
1885
 
Línea 1886... Línea 1886...
1886
        $this->setUser($user);
1886
        $this->setUser($user);
Línea 1887... Línea 1887...
1887
        $this->expectException('moodle_exception');
1887
        $this->expectException('moodle_exception');
1888
        core_message_external::mark_all_notifications_as_read($sender->id, 0);
1888
        core_message_external::mark_all_notifications_as_read($sender->id, 0);
1889
    }
1889
    }
1890
 
1890
 
Línea 1891... Línea 1891...
1891
    public function test_mark_all_notifications_as_read_missing_from_user_exception() {
1891
    public function test_mark_all_notifications_as_read_missing_from_user_exception(): void {
1892
        $this->resetAfterTest(true);
1892
        $this->resetAfterTest(true);
Línea 1893... Línea 1893...
1893
 
1893
 
Línea 1894... Línea 1894...
1894
        $sender = $this->getDataGenerator()->create_user();
1894
        $sender = $this->getDataGenerator()->create_user();
Línea 1930... Línea 1930...
1930
 
1930
 
1931
        $this->assertCount(6, $readnotifications);
1931
        $this->assertCount(6, $readnotifications);
1932
        $this->assertCount(0, $unreadnotifications);
1932
        $this->assertCount(0, $unreadnotifications);
Línea 1933... Línea 1933...
1933
    }
1933
    }
1934
 
1934
 
Línea 1935... Línea 1935...
1935
    public function test_mark_all_notifications_as_read_time_created_to() {
1935
    public function test_mark_all_notifications_as_read_time_created_to(): void {
Línea 1936... Línea 1936...
1936
        global $DB;
1936
        global $DB;
Línea 1973... Línea 1973...
1973
    }
1973
    }
Línea 1974... Línea 1974...
1974
 
1974
 
1975
    /**
1975
    /**
1976
     * Test get_user_notification_preferences
1976
     * Test get_user_notification_preferences
1977
     */
1977
     */
1978
    public function test_get_user_notification_preferences() {
1978
    public function test_get_user_notification_preferences(): void {
Línea 1979... Línea 1979...
1979
        $this->resetAfterTest(true);
1979
        $this->resetAfterTest(true);
1980
 
1980
 
Línea 2012... Línea 2012...
2012
    }
2012
    }
Línea 2013... Línea 2013...
2013
 
2013
 
2014
    /**
2014
    /**
2015
     * Test get_user_notification_preferences permissions
2015
     * Test get_user_notification_preferences permissions
2016
     */
2016
     */
2017
    public function test_get_user_notification_preferences_permissions() {
2017
    public function test_get_user_notification_preferences_permissions(): void {
Línea 2018... Línea 2018...
2018
        $this->resetAfterTest(true);
2018
        $this->resetAfterTest(true);
2019
 
2019
 
2020
        $user = self::getDataGenerator()->create_user();
2020
        $user = self::getDataGenerator()->create_user();
Línea 2030... Línea 2030...
2030
     *
2030
     *
2031
     * This test verifies that any contacts are returned, as well as any non-contacts whose profile we can view.
2031
     * This test verifies that any contacts are returned, as well as any non-contacts whose profile we can view.
2032
     * If checks this by placing some users in the same course, where default caps would permit a user to view another user's
2032
     * If checks this by placing some users in the same course, where default caps would permit a user to view another user's
2033
     * profile.
2033
     * profile.
2034
     */
2034
     */
2035
    public function test_message_search_users_messagingallusers_disabled() {
2035
    public function test_message_search_users_messagingallusers_disabled(): void {
2036
        global $DB;
2036
        global $DB;
2037
        $this->resetAfterTest();
2037
        $this->resetAfterTest();
Línea 2038... Línea 2038...
2038
 
2038
 
2039
        // Create some users.
2039
        // Create some users.
Línea 2126... Línea 2126...
2126
     * Tests searching for users when site-wide messaging is enabled.
2126
     * Tests searching for users when site-wide messaging is enabled.
2127
     *
2127
     *
2128
     * This test verifies that any contacts are returned, as well as any non-contacts, regardless of whether the searching user
2128
     * This test verifies that any contacts are returned, as well as any non-contacts, regardless of whether the searching user
2129
     * can view their respective profile.
2129
     * can view their respective profile.
2130
     */
2130
     */
2131
    public function test_message_search_users_messagingallusers_enabled() {
2131
    public function test_message_search_users_messagingallusers_enabled(): void {
2132
        global $DB;
2132
        global $DB;
2133
        $this->resetAfterTest();
2133
        $this->resetAfterTest();
Línea 2134... Línea 2134...
2134
 
2134
 
2135
        // Create some users.
2135
        // Create some users.
Línea 2219... Línea 2219...
2219
    }
2219
    }
Línea 2220... Línea 2220...
2220
 
2220
 
2221
    /**
2221
    /**
2222
     * Verify searching for users find themselves when they have self-conversations.
2222
     * Verify searching for users find themselves when they have self-conversations.
2223
     */
2223
     */
2224
    public function test_message_search_users_self_conversations() {
2224
    public function test_message_search_users_self_conversations(): void {
Línea 2225... Línea 2225...
2225
        $this->resetAfterTest();
2225
        $this->resetAfterTest();
2226
 
2226
 
2227
        // Create some users.
2227
        // Create some users.
Línea 2249... Línea 2249...
2249
    }
2249
    }
Línea 2250... Línea 2250...
2250
 
2250
 
2251
    /**
2251
    /**
2252
     * Verify searching for users works even if no matching users from either contacts, or non-contacts can be found.
2252
     * Verify searching for users works even if no matching users from either contacts, or non-contacts can be found.
2253
     */
2253
     */
2254
    public function test_message_search_users_with_empty_result() {
2254
    public function test_message_search_users_with_empty_result(): void {
Línea 2255... Línea 2255...
2255
        $this->resetAfterTest();
2255
        $this->resetAfterTest();
2256
 
2256
 
2257
        // Create some users, but make sure neither will match the search term.
2257
        // Create some users, but make sure neither will match the search term.
Línea 2275... Línea 2275...
2275
    }
2275
    }
Línea 2276... Línea 2276...
2276
 
2276
 
2277
    /**
2277
    /**
2278
     * Test verifying that limits and offsets work for both the contacts and non-contacts return data.
2278
     * Test verifying that limits and offsets work for both the contacts and non-contacts return data.
2279
     */
2279
     */
2280
    public function test_message_search_users_limit_offset() {
2280
    public function test_message_search_users_limit_offset(): void {
Línea 2281... Línea 2281...
2281
        $this->resetAfterTest();
2281
        $this->resetAfterTest();
2282
 
2282
 
2283
        // Create 20 users.
2283
        // Create 20 users.
Línea 2354... Línea 2354...
2354
    }
2354
    }
Línea 2355... Línea 2355...
2355
 
2355
 
2356
    /**
2356
    /**
2357
     * Tests searching users as another user having the 'moodle/user:viewdetails' capability.
2357
     * Tests searching users as another user having the 'moodle/user:viewdetails' capability.
2358
     */
2358
     */
2359
    public function test_message_search_users_with_cap() {
2359
    public function test_message_search_users_with_cap(): void {
2360
        $this->resetAfterTest();
2360
        $this->resetAfterTest();
Línea 2361... Línea 2361...
2361
        global $DB;
2361
        global $DB;
2362
 
2362
 
Línea 2411... Línea 2411...
2411
    }
2411
    }
Línea 2412... Línea 2412...
2412
 
2412
 
2413
    /**
2413
    /**
2414
     * Tests searching users as another user without the 'moodle/user:viewdetails' capability.
2414
     * Tests searching users as another user without the 'moodle/user:viewdetails' capability.
2415
     */
2415
     */
2416
    public function test_message_search_users_without_cap() {
2416
    public function test_message_search_users_without_cap(): void {
Línea 2417... Línea 2417...
2417
        $this->resetAfterTest();
2417
        $this->resetAfterTest();
2418
 
2418
 
2419
        // Create some users.
2419
        // Create some users.
Línea 2430... Línea 2430...
2430
    }
2430
    }
Línea 2431... Línea 2431...
2431
 
2431
 
2432
    /**
2432
    /**
2433
     * Tests searching users with messaging disabled.
2433
     * Tests searching users with messaging disabled.
2434
     */
2434
     */
2435
    public function test_message_search_users_messaging_disabled() {
2435
    public function test_message_search_users_messaging_disabled(): void {
Línea 2436... Línea 2436...
2436
        $this->resetAfterTest();
2436
        $this->resetAfterTest();
2437
 
2437
 
Línea 2450... Línea 2450...
2450
    }
2450
    }
Línea 2451... Línea 2451...
2451
 
2451
 
2452
    /**
2452
    /**
2453
     * Tests searching messages.
2453
     * Tests searching messages.
2454
     */
2454
     */
2455
    public function test_messagearea_search_messages() {
2455
    public function test_messagearea_search_messages(): void {
Línea 2456... Línea 2456...
2456
        $this->resetAfterTest(true);
2456
        $this->resetAfterTest(true);
2457
 
2457
 
2458
        // Create some users.
2458
        // Create some users.
Línea 2509... Línea 2509...
2509
    }
2509
    }
Línea 2510... Línea 2510...
2510
 
2510
 
2511
    /**
2511
    /**
2512
     * Tests searching messages as another user.
2512
     * Tests searching messages as another user.
2513
     */
2513
     */
2514
    public function test_messagearea_search_messages_as_other_user() {
2514
    public function test_messagearea_search_messages_as_other_user(): void {
Línea 2515... Línea 2515...
2515
        $this->resetAfterTest(true);
2515
        $this->resetAfterTest(true);
2516
 
2516
 
Línea 2566... Línea 2566...
2566
    }
2566
    }
Línea 2567... Línea 2567...
2567
 
2567
 
2568
    /**
2568
    /**
2569
     * Tests searching messages as another user without the proper capabilities.
2569
     * Tests searching messages as another user without the proper capabilities.
2570
     */
2570
     */
2571
    public function test_messagearea_search_messages_as_other_user_without_cap() {
2571
    public function test_messagearea_search_messages_as_other_user_without_cap(): void {
Línea 2572... Línea 2572...
2572
        $this->resetAfterTest(true);
2572
        $this->resetAfterTest(true);
2573
 
2573
 
2574
        // Create some users.
2574
        // Create some users.
Línea 2584... Línea 2584...
2584
    }
2584
    }
Línea 2585... Línea 2585...
2585
 
2585
 
2586
    /**
2586
    /**
2587
     * Tests searching messages with messaging disabled
2587
     * Tests searching messages with messaging disabled
2588
     */
2588
     */
2589
    public function test_messagearea_search_messages_messaging_disabled() {
2589
    public function test_messagearea_search_messages_messaging_disabled(): void {
Línea 2590... Línea 2590...
2590
        global $CFG;
2590
        global $CFG;
Línea 2591... Línea 2591...
2591
 
2591
 
Línea 2606... Línea 2606...
2606
    }
2606
    }
Línea 2607... Línea 2607...
2607
 
2607
 
2608
    /**
2608
    /**
2609
     * Tests retrieving contacts.
2609
     * Tests retrieving contacts.
2610
     */
2610
     */
2611
    public function test_get_user_contacts() {
2611
    public function test_get_user_contacts(): void {
Línea 2612... Línea 2612...
2612
        $this->resetAfterTest(true);
2612
        $this->resetAfterTest(true);
2613
 
2613
 
Línea 2672... Línea 2672...
2672
    }
2672
    }
Línea 2673... Línea 2673...
2673
 
2673
 
2674
    /**
2674
    /**
2675
     * Tests retrieving contacts as another user.
2675
     * Tests retrieving contacts as another user.
2676
     */
2676
     */
2677
    public function test_get_user_contacts_as_other_user() {
2677
    public function test_get_user_contacts_as_other_user(): void {
Línea 2678... Línea 2678...
2678
        $this->resetAfterTest(true);
2678
        $this->resetAfterTest(true);
Línea 2679... Línea 2679...
2679
 
2679
 
Línea 2737... Línea 2737...
2737
    }
2737
    }
Línea 2738... Línea 2738...
2738
 
2738
 
2739
    /**
2739
    /**
2740
     * Tests retrieving contacts as another user without the proper capabilities.
2740
     * Tests retrieving contacts as another user without the proper capabilities.
2741
     */
2741
     */
2742
    public function test_get_user_contacts_as_other_user_without_cap() {
2742
    public function test_get_user_contacts_as_other_user_without_cap(): void {
Línea 2743... Línea 2743...
2743
        $this->resetAfterTest(true);
2743
        $this->resetAfterTest(true);
2744
 
2744
 
2745
        // Create some users.
2745
        // Create some users.
Línea 2755... Línea 2755...
2755
    }
2755
    }
Línea 2756... Línea 2756...
2756
 
2756
 
2757
    /**
2757
    /**
2758
     * Tests retrieving contacts with messaging disabled.
2758
     * Tests retrieving contacts with messaging disabled.
2759
     */
2759
     */
2760
    public function test_get_user_contacts_messaging_disabled() {
2760
    public function test_get_user_contacts_messaging_disabled(): void {
Línea 2761... Línea 2761...
2761
        global $CFG;
2761
        global $CFG;
Línea 2762... Línea 2762...
2762
 
2762
 
Línea 2777... Línea 2777...
2777
    }
2777
    }
Línea 2778... Línea 2778...
2778
 
2778
 
2779
    /**
2779
    /**
2780
     * Test getting contacts when there are no results.
2780
     * Test getting contacts when there are no results.
2781
     */
2781
     */
2782
    public function test_get_user_contacts_no_results() {
2782
    public function test_get_user_contacts_no_results(): void {
Línea 2783... Línea 2783...
2783
        $this->resetAfterTest();
2783
        $this->resetAfterTest();
Línea 2784... Línea 2784...
2784
 
2784
 
Línea 2793... Línea 2793...
2793
    }
2793
    }
Línea 2794... Línea 2794...
2794
 
2794
 
2795
    /**
2795
    /**
2796
     * Tests get_conversation_messages for retrieving messages.
2796
     * Tests get_conversation_messages for retrieving messages.
2797
     */
2797
     */
2798
    public function test_get_conversation_messages() {
2798
    public function test_get_conversation_messages(): void {
Línea 2799... Línea 2799...
2799
        $this->resetAfterTest(true);
2799
        $this->resetAfterTest(true);
2800
 
2800
 
2801
        // Create some users.
2801
        // Create some users.
Línea 2867... Línea 2867...
2867
    }
2867
    }
Línea 2868... Línea 2868...
2868
 
2868
 
2869
    /**
2869
    /**
2870
     * Tests get_conversation_messages for retrieving messages using timefrom parameter.
2870
     * Tests get_conversation_messages for retrieving messages using timefrom parameter.
2871
     */
2871
     */
2872
    public function test_get_conversation_messages_timefrom() {
2872
    public function test_get_conversation_messages_timefrom(): void {
Línea 2873... Línea 2873...
2873
        $this->resetAfterTest(true);
2873
        $this->resetAfterTest(true);
2874
 
2874
 
2875
        // Create some users.
2875
        // Create some users.
Línea 2923... Línea 2923...
2923
    }
2923
    }
Línea 2924... Línea 2924...
2924
 
2924
 
2925
    /**
2925
    /**
2926
     * Tests get_conversation_messages for retrieving messages as another user.
2926
     * Tests get_conversation_messages for retrieving messages as another user.
2927
     */
2927
     */
2928
    public function test_get_conversation_messages_as_other_user() {
2928
    public function test_get_conversation_messages_as_other_user(): void {
Línea 2929... Línea 2929...
2929
        $this->resetAfterTest(true);
2929
        $this->resetAfterTest(true);
2930
 
2930
 
Línea 2991... Línea 2991...
2991
    }
2991
    }
Línea 2992... Línea 2992...
2992
 
2992
 
2993
    /**
2993
    /**
2994
     * Tests get_conversation_messages for retrieving messages as another user without the proper capabilities.
2994
     * Tests get_conversation_messages for retrieving messages as another user without the proper capabilities.
2995
     */
2995
     */
2996
    public function test_get_conversation_messages_as_other_user_without_cap() {
2996
    public function test_get_conversation_messages_as_other_user_without_cap(): void {
Línea 2997... Línea 2997...
2997
        $this->resetAfterTest(true);
2997
        $this->resetAfterTest(true);
2998
 
2998
 
2999
        // Create some users.
2999
        // Create some users.
Línea 3017... Línea 3017...
3017
    }
3017
    }
Línea 3018... Línea 3018...
3018
 
3018
 
3019
    /**
3019
    /**
3020
     * Tests get_conversation_messages for retrieving messages as another user not in the conversation.
3020
     * Tests get_conversation_messages for retrieving messages as another user not in the conversation.
3021
     */
3021
     */
3022
    public function test_get_conversation_messages_as_user_not_in_conversation() {
3022
    public function test_get_conversation_messages_as_user_not_in_conversation(): void {
Línea 3023... Línea 3023...
3023
        $this->resetAfterTest(true);
3023
        $this->resetAfterTest(true);
3024
 
3024
 
3025
        // Create some users.
3025
        // Create some users.
Línea 3042... Línea 3042...
3042
    }
3042
    }
Línea 3043... Línea 3043...
3043
 
3043
 
3044
    /**
3044
    /**
3045
     * Tests get_conversation_messages for retrieving messages with messaging disabled.
3045
     * Tests get_conversation_messages for retrieving messages with messaging disabled.
3046
     */
3046
     */
3047
    public function test_get_conversation_messages_messaging_disabled() {
3047
    public function test_get_conversation_messages_messaging_disabled(): void {
Línea 3048... Línea 3048...
3048
        $this->resetAfterTest(true);
3048
        $this->resetAfterTest(true);
3049
 
3049
 
3050
        // Create some skeleton data just so we can call the WS.
3050
        // Create some skeleton data just so we can call the WS.
Línea 3071... Línea 3071...
3071
    }
3071
    }
Línea 3072... Línea 3072...
3072
 
3072
 
3073
    /**
3073
    /**
3074
     * Test marking all conversation messages as read with an invalid user.
3074
     * Test marking all conversation messages as read with an invalid user.
3075
     */
3075
     */
3076
    public function test_mark_all_conversation_messages_as_read_invalid_user_exception() {
3076
    public function test_mark_all_conversation_messages_as_read_invalid_user_exception(): void {
Línea 3077... Línea 3077...
3077
        $this->resetAfterTest(true);
3077
        $this->resetAfterTest(true);
3078
 
3078
 
Línea 3093... Línea 3093...
3093
    }
3093
    }
Línea 3094... Línea 3094...
3094
 
3094
 
3095
    /**
3095
    /**
3096
     * Test marking all conversation messages as read without proper access.
3096
     * Test marking all conversation messages as read without proper access.
3097
     */
3097
     */
3098
    public function test_mark_all_conversation_messages_as_read_access_denied_exception() {
3098
    public function test_mark_all_conversation_messages_as_read_access_denied_exception(): void {
Línea 3099... Línea 3099...
3099
        $this->resetAfterTest(true);
3099
        $this->resetAfterTest(true);
3100
 
3100
 
3101
        $user1 = self::getDataGenerator()->create_user();
3101
        $user1 = self::getDataGenerator()->create_user();
Línea 3117... Línea 3117...
3117
    }
3117
    }
Línea 3118... Línea 3118...
3118
 
3118
 
3119
    /**
3119
    /**
3120
     * Test marking all conversation messages as read for another user.
3120
     * Test marking all conversation messages as read for another user.
3121
     */
3121
     */
3122
    public function test_mark_all_conversation_messages_as_read_wrong_user() {
3122
    public function test_mark_all_conversation_messages_as_read_wrong_user(): void {
Línea 3123... Línea 3123...
3123
        $this->resetAfterTest(true);
3123
        $this->resetAfterTest(true);
3124
 
3124
 
Línea 3141... Línea 3141...
3141
    }
3141
    }
Línea 3142... Línea 3142...
3142
 
3142
 
3143
    /**
3143
    /**
3144
     * Test marking all conversation messages as admin.
3144
     * Test marking all conversation messages as admin.
3145
     */
3145
     */
3146
    public function test_mark_all_conversation_messages_as_admin() {
3146
    public function test_mark_all_conversation_messages_as_admin(): void {
Línea 3147... Línea 3147...
3147
        global $DB;
3147
        global $DB;
Línea 3148... Línea 3148...
3148
 
3148
 
Línea 3167... Línea 3167...
3167
    }
3167
    }
Línea 3168... Línea 3168...
3168
 
3168
 
3169
    /**
3169
    /**
3170
     * Test marking all conversation messages.
3170
     * Test marking all conversation messages.
3171
     */
3171
     */
3172
    public function test_mark_all_conversation_messages_as_read() {
3172
    public function test_mark_all_conversation_messages_as_read(): void {
Línea 3173... Línea 3173...
3173
        global $DB;
3173
        global $DB;
Línea 3174... Línea 3174...
3174
 
3174
 
Línea 3193... Línea 3193...
3193
    }
3193
    }
Línea 3194... Línea 3194...
3194
 
3194
 
3195
    /**
3195
    /**
3196
     * Test getting unread conversation count.
3196
     * Test getting unread conversation count.
3197
     */
3197
     */
3198
    public function test_get_unread_conversations_count() {
3198
    public function test_get_unread_conversations_count(): void {
Línea 3199... Línea 3199...
3199
        $this->resetAfterTest(true);
3199
        $this->resetAfterTest(true);
3200
 
3200
 
3201
        // Create some users.
3201
        // Create some users.
Línea 3233... Línea 3233...
3233
    }
3233
    }
Línea 3234... Línea 3234...
3234
 
3234
 
3235
    /**
3235
    /**
3236
     * Test getting unread conversation count as other user.
3236
     * Test getting unread conversation count as other user.
3237
     */
3237
     */
3238
    public function test_get_unread_conversations_count_as_other_user() {
3238
    public function test_get_unread_conversations_count_as_other_user(): void {
Línea 3239... Línea 3239...
3239
        $this->resetAfterTest(true);
3239
        $this->resetAfterTest(true);
3240
 
3240
 
Línea 3273... Línea 3273...
3273
    }
3273
    }
Línea 3274... Línea 3274...
3274
 
3274
 
3275
    /**
3275
    /**
3276
     * Test getting unread conversation count as other user without proper capability.
3276
     * Test getting unread conversation count as other user without proper capability.
3277
     */
3277
     */
3278
    public function test_get_unread_conversations_count_as_other_user_without_cap() {
3278
    public function test_get_unread_conversations_count_as_other_user_without_cap(): void {
Línea 3279... Línea 3279...
3279
        $this->resetAfterTest(true);
3279
        $this->resetAfterTest(true);
3280
 
3280
 
3281
        // Create some users.
3281
        // Create some users.
Línea 3291... Línea 3291...
3291
    }
3291
    }
Línea 3292... Línea 3292...
3292
 
3292
 
3293
    /**
3293
    /**
3294
     * Test deleting conversations.
3294
     * Test deleting conversations.
3295
     */
3295
     */
3296
    public function test_delete_conversations_by_id() {
3296
    public function test_delete_conversations_by_id(): void {
Línea 3297... Línea 3297...
3297
        global $DB;
3297
        global $DB;
Línea 3298... Línea 3298...
3298
 
3298
 
Línea 3345... Línea 3345...
3345
    }
3345
    }
Línea 3346... Línea 3346...
3346
 
3346
 
3347
    /**
3347
    /**
3348
     * Test deleting conversations as other user.
3348
     * Test deleting conversations as other user.
3349
     */
3349
     */
3350
    public function test_delete_conversations_by_id_as_other_user() {
3350
    public function test_delete_conversations_by_id_as_other_user(): void {
Línea 3351... Línea 3351...
3351
        global $DB;
3351
        global $DB;
Línea 3352... Línea 3352...
3352
 
3352
 
Línea 3398... Línea 3398...
3398
    }
3398
    }
Línea 3399... Línea 3399...
3399
 
3399
 
3400
    /**
3400
    /**
3401
     * Test deleting conversations as other user without proper capability.
3401
     * Test deleting conversations as other user without proper capability.
3402
     */
3402
     */
3403
    public function test_delete_conversations_by_id_as_other_user_without_cap() {
3403
    public function test_delete_conversations_by_id_as_other_user_without_cap(): void {
Línea 3404... Línea 3404...
3404
        $this->resetAfterTest(true);
3404
        $this->resetAfterTest(true);
3405
 
3405
 
3406
        // Create some users.
3406
        // Create some users.
Línea 3426... Línea 3426...
3426
    }
3426
    }
Línea 3427... Línea 3427...
3427
 
3427
 
3428
    /**
3428
    /**
3429
     * Test deleting conversations with messaging disabled.
3429
     * Test deleting conversations with messaging disabled.
3430
     */
3430
     */
3431
    public function test_delete_conversations_by_id_messaging_disabled() {
3431
    public function test_delete_conversations_by_id_messaging_disabled(): void {
Línea 3432... Línea 3432...
3432
        global $CFG;
3432
        global $CFG;
Línea 3433... Línea 3433...
3433
 
3433
 
Línea 3458... Línea 3458...
3458
    }
3458
    }
Línea 3459... Línea 3459...
3459
 
3459
 
3460
    /**
3460
    /**
3461
     * Test get message processor.
3461
     * Test get message processor.
3462
     */
3462
     */
3463
    public function test_get_message_processor() {
3463
    public function test_get_message_processor(): void {
Línea 3464... Línea 3464...
3464
        $this->resetAfterTest(true);
3464
        $this->resetAfterTest(true);
3465
 
3465
 
Línea 3480... Línea 3480...
3480
    }
3480
    }
Línea 3481... Línea 3481...
3481
 
3481
 
3482
    /**
3482
    /**
3483
     * Test get_user_notification_preferences
3483
     * Test get_user_notification_preferences
3484
     */
3484
     */
3485
    public function test_get_user_message_preferences() {
3485
    public function test_get_user_message_preferences(): void {
Línea 3486... Línea 3486...
3486
        $this->resetAfterTest(true);
3486
        $this->resetAfterTest(true);
3487
 
3487
 
Línea 3522... Línea 3522...
3522
    }
3522
    }
Línea 3523... Línea 3523...
3523
 
3523
 
3524
    /**
3524
    /**
3525
     * Test get_user_message_preferences permissions
3525
     * Test get_user_message_preferences permissions
3526
     */
3526
     */
3527
    public function test_get_user_message_preferences_permissions() {
3527
    public function test_get_user_message_preferences_permissions(): void {
Línea 3528... Línea 3528...
3528
        $this->resetAfterTest(true);
3528
        $this->resetAfterTest(true);
3529
 
3529
 
3530
        $user = self::getDataGenerator()->create_user();
3530
        $user = self::getDataGenerator()->create_user();
Línea 3558... Línea 3558...
3558
    }
3558
    }
Línea 3559... Línea 3559...
3559
 
3559
 
3560
    /**
3560
    /**
3561
     * Test verifying that conversations can be marked as favourite conversations.
3561
     * Test verifying that conversations can be marked as favourite conversations.
3562
     */
3562
     */
3563
    public function test_set_favourite_conversations_basic() {
3563
    public function test_set_favourite_conversations_basic(): void {
Línea 3564... Línea 3564...
3564
        $this->resetAfterTest();
3564
        $this->resetAfterTest();
3565
 
3565
 
3566
        $user1 = self::getDataGenerator()->create_user();
3566
        $user1 = self::getDataGenerator()->create_user();
Línea 3594... Línea 3594...
3594
    }
3594
    }
Línea 3595... Línea 3595...
3595
 
3595
 
3596
    /**
3596
    /**
3597
     * Test confirming that a user can't favourite a conversation on behalf of another user.
3597
     * Test confirming that a user can't favourite a conversation on behalf of another user.
3598
     */
3598
     */
3599
    public function test_set_favourite_conversations_another_users_conversation() {
3599
    public function test_set_favourite_conversations_another_users_conversation(): void {
Línea 3600... Línea 3600...
3600
        $this->resetAfterTest();
3600
        $this->resetAfterTest();
3601
 
3601
 
3602
        $user1 = self::getDataGenerator()->create_user();
3602
        $user1 = self::getDataGenerator()->create_user();
Línea 3622... Línea 3622...
3622
    }
3622
    }
Línea 3623... Línea 3623...
3623
 
3623
 
3624
    /**
3624
    /**
3625
     * Test confirming that a user can't mark a conversation as their own favourite if it's a conversation they're not a member of.
3625
     * Test confirming that a user can't mark a conversation as their own favourite if it's a conversation they're not a member of.
3626
     */
3626
     */
3627
    public function test_set_favourite_conversations_non_member() {
3627
    public function test_set_favourite_conversations_non_member(): void {
Línea 3628... Línea 3628...
3628
        $this->resetAfterTest();
3628
        $this->resetAfterTest();
3629
 
3629
 
3630
        $user1 = self::getDataGenerator()->create_user();
3630
        $user1 = self::getDataGenerator()->create_user();
Línea 3651... Línea 3651...
3651
    }
3651
    }
Línea 3652... Línea 3652...
3652
 
3652
 
3653
    /**
3653
    /**
3654
     * Test confirming that a user can't favourite a non-existent conversation.
3654
     * Test confirming that a user can't favourite a non-existent conversation.
3655
     */
3655
     */
3656
    public function test_set_favourite_conversations_non_existent_conversation() {
3656
    public function test_set_favourite_conversations_non_existent_conversation(): void {
Línea 3657... Línea 3657...
3657
        $this->resetAfterTest();
3657
        $this->resetAfterTest();
3658
 
3658
 
Línea 3665... Línea 3665...
3665
    }
3665
    }
Línea 3666... Línea 3666...
3666
 
3666
 
3667
    /**
3667
    /**
3668
     * Test confirming that a user can unset a favourite conversation, or list of favourite conversations.
3668
     * Test confirming that a user can unset a favourite conversation, or list of favourite conversations.
3669
     */
3669
     */
3670
    public function test_unset_favourite_conversations_basic() {
3670
    public function test_unset_favourite_conversations_basic(): void {
Línea 3671... Línea 3671...
3671
        $this->resetAfterTest();
3671
        $this->resetAfterTest();
3672
 
3672
 
3673
        $user1 = self::getDataGenerator()->create_user();
3673
        $user1 = self::getDataGenerator()->create_user();
Línea 3712... Línea 3712...
3712
    }
3712
    }
Línea 3713... Línea 3713...
3713
 
3713
 
3714
    /**
3714
    /**
3715
     * Test confirming that a user can't unfavourite a conversation for another user.
3715
     * Test confirming that a user can't unfavourite a conversation for another user.
3716
     */
3716
     */
3717
    public function test_unset_favourite_conversations_another_users_conversation() {
3717
    public function test_unset_favourite_conversations_another_users_conversation(): void {
Línea 3718... Línea 3718...
3718
        $this->resetAfterTest();
3718
        $this->resetAfterTest();
3719
 
3719
 
3720
        $user1 = self::getDataGenerator()->create_user();
3720
        $user1 = self::getDataGenerator()->create_user();
Línea 3746... Línea 3746...
3746
    }
3746
    }
Línea 3747... Línea 3747...
3747
 
3747
 
3748
    /**
3748
    /**
3749
     * Test confirming that a user can't unfavourite a non-existent conversation.
3749
     * Test confirming that a user can't unfavourite a non-existent conversation.
3750
     */
3750
     */
3751
    public function test_unset_favourite_conversations_non_existent_conversation() {
3751
    public function test_unset_favourite_conversations_non_existent_conversation(): void {
Línea 3752... Línea 3752...
3752
        $this->resetAfterTest();
3752
        $this->resetAfterTest();
3753
 
3753
 
Línea 3830... Línea 3830...
3830
    }
3830
    }
Línea 3831... Línea 3831...
3831
 
3831
 
3832
    /**
3832
    /**
3833
     * Test confirming the basic use of get_conversations, with no limits, nor type or favourite restrictions.
3833
     * Test confirming the basic use of get_conversations, with no limits, nor type or favourite restrictions.
3834
     */
3834
     */
3835
    public function test_get_conversations_no_restrictions() {
3835
    public function test_get_conversations_no_restrictions(): void {
Línea 3836... Línea 3836...
3836
        $this->resetAfterTest(true);
3836
        $this->resetAfterTest(true);
3837
 
3837
 
3838
        // Get a bunch of conversations, some group, some individual and in different states.
3838
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 3898... Línea 3898...
3898
    }
3898
    }
Línea 3899... Línea 3899...
3899
 
3899
 
3900
    /**
3900
    /**
3901
     * Test verifying that html format messages are supported, and that message_format_message_text() is being called appropriately.
3901
     * Test verifying that html format messages are supported, and that message_format_message_text() is being called appropriately.
3902
     */
3902
     */
3903
    public function test_get_conversations_message_format() {
3903
    public function test_get_conversations_message_format(): void {
Línea 3904... Línea 3904...
3904
        $this->resetAfterTest();
3904
        $this->resetAfterTest();
3905
 
3905
 
3906
        global $DB;
3906
        global $DB;
Línea 3933... Línea 3933...
3933
    }
3933
    }
Línea 3934... Línea 3934...
3934
 
3934
 
3935
    /**
3935
    /**
3936
     * Tests retrieving conversations with a limit and offset to ensure pagination works correctly.
3936
     * Tests retrieving conversations with a limit and offset to ensure pagination works correctly.
3937
     */
3937
     */
3938
    public function test_get_conversations_limit_offset() {
3938
    public function test_get_conversations_limit_offset(): void {
Línea 3939... Línea 3939...
3939
        $this->resetAfterTest(true);
3939
        $this->resetAfterTest(true);
3940
 
3940
 
3941
        // Get a bunch of conversations, some group, some individual and in different states.
3941
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 3985... Línea 3985...
3985
    }
3985
    }
Línea 3986... Línea 3986...
3986
 
3986
 
3987
    /**
3987
    /**
3988
     * Test verifying the type filtering behaviour of the get_conversations external method.
3988
     * Test verifying the type filtering behaviour of the get_conversations external method.
3989
     */
3989
     */
3990
    public function test_get_conversations_type_filter() {
3990
    public function test_get_conversations_type_filter(): void {
Línea 3991... Línea 3991...
3991
        $this->resetAfterTest(true);
3991
        $this->resetAfterTest(true);
3992
 
3992
 
3993
        // Get a bunch of conversations, some group, some individual and in different states.
3993
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4017... Línea 4017...
4017
    }
4017
    }
Línea 4018... Línea 4018...
4018
 
4018
 
4019
    /**
4019
    /**
4020
     * Tests retrieving conversations when a 'self' conversation exists.
4020
     * Tests retrieving conversations when a 'self' conversation exists.
4021
     */
4021
     */
4022
    public function test_get_conversations_self_conversations() {
4022
    public function test_get_conversations_self_conversations(): void {
4023
        global $DB;
4023
        global $DB;
Línea 4024... Línea 4024...
4024
        $this->resetAfterTest();
4024
        $this->resetAfterTest();
4025
 
4025
 
Línea 4044... Línea 4044...
4044
    }
4044
    }
Línea 4045... Línea 4045...
4045
 
4045
 
4046
    /**
4046
    /**
4047
     * Tests retrieving conversations when a conversation contains a deleted user.
4047
     * Tests retrieving conversations when a conversation contains a deleted user.
4048
     */
4048
     */
4049
    public function test_get_conversations_deleted_user() {
4049
    public function test_get_conversations_deleted_user(): void {
Línea 4050... Línea 4050...
4050
        $this->resetAfterTest(true);
4050
        $this->resetAfterTest(true);
4051
 
4051
 
4052
        // Get a bunch of conversations, some group, some individual and in different states.
4052
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4109... Línea 4109...
4109
    }
4109
    }
Línea 4110... Línea 4110...
4110
 
4110
 
4111
    /**
4111
    /**
4112
     * Tests retrieving conversations when a conversation contains a deleted from the database user.
4112
     * Tests retrieving conversations when a conversation contains a deleted from the database user.
4113
     */
4113
     */
4114
    public function test_get_conversations_deleted_user_from_database() {
4114
    public function test_get_conversations_deleted_user_from_database(): void {
Línea 4115... Línea 4115...
4115
        global $DB;
4115
        global $DB;
Línea 4116... Línea 4116...
4116
 
4116
 
Línea 4164... Línea 4164...
4164
    }
4164
    }
Línea 4165... Línea 4165...
4165
 
4165
 
4166
    /**
4166
    /**
4167
     * Test verifying the behaviour of get_conversations() when fetching favourite conversations.
4167
     * Test verifying the behaviour of get_conversations() when fetching favourite conversations.
4168
     */
4168
     */
4169
    public function test_get_conversations_favourite_conversations() {
4169
    public function test_get_conversations_favourite_conversations(): void {
Línea 4170... Línea 4170...
4170
        $this->resetAfterTest(true);
4170
        $this->resetAfterTest(true);
4171
 
4171
 
4172
        // Get a bunch of conversations, some group, some individual and in different states.
4172
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4237... Línea 4237...
4237
    }
4237
    }
Línea 4238... Línea 4238...
4238
 
4238
 
4239
    /**
4239
    /**
4240
     * Test verifying that group linked conversations are returned and contain a subname matching the course name.
4240
     * Test verifying that group linked conversations are returned and contain a subname matching the course name.
4241
     */
4241
     */
4242
    public function test_get_conversations_group_linked() {
4242
    public function test_get_conversations_group_linked(): void {
4243
        $this->resetAfterTest();
4243
        $this->resetAfterTest();
Línea 4244... Línea 4244...
4244
        global $CFG, $DB;
4244
        global $CFG, $DB;
4245
 
4245
 
Línea 4283... Línea 4283...
4283
    }
4283
    }
Línea 4284... Línea 4284...
4284
 
4284
 
4285
    /**
4285
    /**
4286
     * Test that group conversations containing MathJax don't break the WebService.
4286
     * Test that group conversations containing MathJax don't break the WebService.
4287
     */
4287
     */
4288
    public function test_get_conversations_group_with_mathjax() {
4288
    public function test_get_conversations_group_with_mathjax(): void {
4289
        $this->resetAfterTest(true);
4289
        $this->resetAfterTest(true);
Línea 4290... Línea 4290...
4290
        $this->setAdminUser();
4290
        $this->setAdminUser();
4291
 
4291
 
Línea 4333... Línea 4333...
4333
    /**
4333
    /**
4334
     * Test verifying get_conversations when there are users in a group and/or individual conversation. The reason this
4334
     * Test verifying get_conversations when there are users in a group and/or individual conversation. The reason this
4335
     * test is performed is because we do not need as much data for group conversations (saving DB calls), so we want
4335
     * test is performed is because we do not need as much data for group conversations (saving DB calls), so we want
4336
     * to confirm this happens.
4336
     * to confirm this happens.
4337
     */
4337
     */
4338
    public function test_get_conversations_user_in_group_and_individual_chat() {
4338
    public function test_get_conversations_user_in_group_and_individual_chat(): void {
4339
        $this->resetAfterTest();
4339
        $this->resetAfterTest();
Línea 4340... Línea 4340...
4340
 
4340
 
4341
        $user1 = self::getDataGenerator()->create_user();
4341
        $user1 = self::getDataGenerator()->create_user();
4342
        $user2 = self::getDataGenerator()->create_user();
4342
        $user2 = self::getDataGenerator()->create_user();
Línea 4393... Línea 4393...
4393
    }
4393
    }
Línea 4394... Línea 4394...
4394
 
4394
 
4395
    /**
4395
    /**
4396
     * Test verifying get_conversations identifies if a conversation is muted or not.
4396
     * Test verifying get_conversations identifies if a conversation is muted or not.
4397
     */
4397
     */
4398
    public function test_get_conversations_some_muted() {
4398
    public function test_get_conversations_some_muted(): void {
Línea 4399... Línea 4399...
4399
        $this->resetAfterTest();
4399
        $this->resetAfterTest();
4400
 
4400
 
4401
        // Create some users.
4401
        // Create some users.
Línea 4443... Línea 4443...
4443
    }
4443
    }
Línea 4444... Línea 4444...
4444
 
4444
 
4445
    /**
4445
    /**
4446
     * Test returning members in a conversation with no contact requests.
4446
     * Test returning members in a conversation with no contact requests.
4447
     */
4447
     */
4448
    public function test_get_conversation_members_messaging_disabled() {
4448
    public function test_get_conversation_members_messaging_disabled(): void {
Línea 4449... Línea 4449...
4449
        global $CFG;
4449
        global $CFG;
Línea 4450... Línea 4450...
4450
 
4450
 
Línea 4457... Línea 4457...
4457
    }
4457
    }
Línea 4458... Línea 4458...
4458
 
4458
 
4459
    /**
4459
    /**
4460
     * Test returning members in a conversation with no contact requests.
4460
     * Test returning members in a conversation with no contact requests.
4461
     */
4461
     */
4462
    public function test_get_conversation_members_wrong_user() {
4462
    public function test_get_conversation_members_wrong_user(): void {
Línea 4463... Línea 4463...
4463
        $this->resetAfterTest();
4463
        $this->resetAfterTest();
4464
 
4464
 
Línea 4472... Línea 4472...
4472
    }
4472
    }
Línea 4473... Línea 4473...
4473
 
4473
 
4474
    /**
4474
    /**
4475
     * Test returning members in a conversation with no contact requests.
4475
     * Test returning members in a conversation with no contact requests.
4476
     */
4476
     */
4477
    public function test_get_conversation_members() {
4477
    public function test_get_conversation_members(): void {
Línea 4478... Línea 4478...
4478
        $this->resetAfterTest();
4478
        $this->resetAfterTest();
4479
 
4479
 
Línea 4550... Línea 4550...
4550
    }
4550
    }
Línea 4551... Línea 4551...
4551
 
4551
 
4552
    /**
4552
    /**
4553
     * Test returning members in a conversation with contact requests.
4553
     * Test returning members in a conversation with contact requests.
4554
     */
4554
     */
4555
    public function test_get_conversation_members_with_contact_requests() {
4555
    public function test_get_conversation_members_with_contact_requests(): void {
Línea 4556... Línea 4556...
4556
        $this->resetAfterTest();
4556
        $this->resetAfterTest();
4557
 
4557
 
Línea 4645... Línea 4645...
4645
    }
4645
    }
Línea 4646... Línea 4646...
4646
 
4646
 
4647
    /**
4647
    /**
4648
     * Test returning members in a conversation when you are not a member.
4648
     * Test returning members in a conversation when you are not a member.
4649
     */
4649
     */
4650
    public function test_get_conversation_members_not_a_member() {
4650
    public function test_get_conversation_members_not_a_member(): void {
Línea 4651... Línea 4651...
4651
        $this->resetAfterTest();
4651
        $this->resetAfterTest();
4652
 
4652
 
Línea 4672... Línea 4672...
4672
    }
4672
    }
Línea 4673... Línea 4673...
4673
 
4673
 
4674
    /**
4674
    /**
4675
     * Test verifying multiple messages can be sent to an individual conversation.
4675
     * Test verifying multiple messages can be sent to an individual conversation.
4676
     */
4676
     */
4677
    public function test_send_messages_to_conversation_individual() {
4677
    public function test_send_messages_to_conversation_individual(): void {
Línea 4678... Línea 4678...
4678
        $this->resetAfterTest(true);
4678
        $this->resetAfterTest(true);
4679
 
4679
 
4680
        // Get a bunch of conversations, some group, some individual and in different states.
4680
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4724... Línea 4724...
4724
    }
4724
    }
Línea 4725... Línea 4725...
4725
 
4725
 
4726
    /**
4726
    /**
4727
     * Test verifying multiple messages can be sent to an group conversation.
4727
     * Test verifying multiple messages can be sent to an group conversation.
4728
     */
4728
     */
4729
    public function test_send_messages_to_conversation_group() {
4729
    public function test_send_messages_to_conversation_group(): void {
Línea 4730... Línea 4730...
4730
        $this->resetAfterTest(true);
4730
        $this->resetAfterTest(true);
4731
 
4731
 
4732
        // Get a bunch of conversations, some group, some individual and in different states.
4732
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4776... Línea 4776...
4776
    }
4776
    }
Línea 4777... Línea 4777...
4777
 
4777
 
4778
    /**
4778
    /**
4779
     * Test verifying multiple messages can not be sent to a non existent conversation.
4779
     * Test verifying multiple messages can not be sent to a non existent conversation.
4780
     */
4780
     */
4781
    public function test_send_messages_to_conversation_non_existent_conversation() {
4781
    public function test_send_messages_to_conversation_non_existent_conversation(): void {
Línea 4782... Línea 4782...
4782
        $this->resetAfterTest(true);
4782
        $this->resetAfterTest(true);
4783
 
4783
 
4784
        // Get a bunch of conversations, some group, some individual and in different states.
4784
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4804... Línea 4804...
4804
    }
4804
    }
Línea 4805... Línea 4805...
4805
 
4805
 
4806
    /**
4806
    /**
4807
     * Test verifying multiple messages can not be sent to a conversation by a non-member.
4807
     * Test verifying multiple messages can not be sent to a conversation by a non-member.
4808
     */
4808
     */
4809
    public function test_send_messages_to_conversation_non_member() {
4809
    public function test_send_messages_to_conversation_non_member(): void {
Línea 4810... Línea 4810...
4810
        $this->resetAfterTest(true);
4810
        $this->resetAfterTest(true);
4811
 
4811
 
4812
        // Get a bunch of conversations, some group, some individual and in different states.
4812
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4839... Línea 4839...
4839
    }
4839
    }
Línea 4840... Línea 4840...
4840
 
4840
 
4841
    /**
4841
    /**
4842
     * Test verifying a to long message can not be sent to a conversation.
4842
     * Test verifying a to long message can not be sent to a conversation.
4843
     */
4843
     */
4844
    public function test_send_messages_to_conversation_long_text() {
4844
    public function test_send_messages_to_conversation_long_text(): void {
Línea 4845... Línea 4845...
4845
        $this->resetAfterTest(true);
4845
        $this->resetAfterTest(true);
4846
 
4846
 
4847
        // Get a bunch of conversations, some group, some individual and in different states.
4847
        // Get a bunch of conversations, some group, some individual and in different states.
Línea 4871... Línea 4871...
4871
    }
4871
    }
Línea 4872... Línea 4872...
4872
 
4872
 
4873
    /**
4873
    /**
4874
     * Test getting a conversation that doesn't exist.
4874
     * Test getting a conversation that doesn't exist.
4875
     */
4875
     */
4876
    public function test_get_conversation_no_conversation() {
4876
    public function test_get_conversation_no_conversation(): void {
Línea 4877... Línea 4877...
4877
        $this->resetAfterTest();
4877
        $this->resetAfterTest();
4878
 
4878
 
Línea 4898... Línea 4898...
4898
    }
4898
    }
Línea 4899... Línea 4899...
4899
 
4899
 
4900
    /**
4900
    /**
4901
     * Test verifying that the correct favourite information is returned for a non-linked converastion at user context.
4901
     * Test verifying that the correct favourite information is returned for a non-linked converastion at user context.
4902
     */
4902
     */
4903
    public function test_get_conversation_favourited() {
4903
    public function test_get_conversation_favourited(): void {
Línea 4904... Línea 4904...
4904
        $this->resetAfterTest();
4904
        $this->resetAfterTest();
4905
 
4905
 
Línea 4933... Línea 4933...
4933
    }
4933
    }
Línea 4934... Línea 4934...
4934
 
4934
 
4935
    /**
4935
    /**
4936
     * Test verifying that the correct favourite information is returned for a group-linked conversation at course context.
4936
     * Test verifying that the correct favourite information is returned for a group-linked conversation at course context.
4937
     */
4937
     */
4938
    public function test_get_conversation_favourited_group_linked() {
4938
    public function test_get_conversation_favourited_group_linked(): void {
4939
        $this->resetAfterTest();
4939
        $this->resetAfterTest();
Línea 4940... Línea 4940...
4940
        global $DB;
4940
        global $DB;
4941
 
4941
 
Línea 4981... Línea 4981...
4981
    }
4981
    }
Línea 4982... Línea 4982...
4982
 
4982
 
4983
    /**
4983
    /**
4984
     * Test getting a conversation with no messages.
4984
     * Test getting a conversation with no messages.
4985
     */
4985
     */
4986
    public function test_get_conversation_no_messages() {
4986
    public function test_get_conversation_no_messages(): void {
Línea 4987... Línea 4987...
4987
        $this->resetAfterTest();
4987
        $this->resetAfterTest();
4988
 
4988
 
Línea 5030... Línea 5030...
5030
    }
5030
    }
Línea 5031... Línea 5031...
5031
 
5031
 
5032
    /**
5032
    /**
5033
     * Test getting a conversation with messages.
5033
     * Test getting a conversation with messages.
5034
     */
5034
     */
5035
    public function test_get_conversation_with_messages() {
5035
    public function test_get_conversation_with_messages(): void {
Línea 5036... Línea 5036...
5036
        $this->resetAfterTest();
5036
        $this->resetAfterTest();
5037
 
5037
 
5038
        $user1 = self::getDataGenerator()->create_user();
5038
        $user1 = self::getDataGenerator()->create_user();
Línea 5516... Línea 5516...
5516
        $deletemessages,
5516
        $deletemessages,
5517
        $arguments,
5517
        $arguments,
5518
        $expectedcounts,
5518
        $expectedcounts,
5519
        $expectedunreadcounts,
5519
        $expectedunreadcounts,
5520
        $deletedusers
5520
        $deletedusers
5521
    ) {
5521
    ): void {
5522
        $this->resetAfterTest();
5522
        $this->resetAfterTest();
5523
        $generator = $this->getDataGenerator();
5523
        $generator = $this->getDataGenerator();
5524
        $users = [
5524
        $users = [
5525
            $generator->create_user(),
5525
            $generator->create_user(),
5526
            $generator->create_user(),
5526
            $generator->create_user(),
Línea 5613... Línea 5613...
5613
        $deletemessages,
5613
        $deletemessages,
5614
        $arguments,
5614
        $arguments,
5615
        $expectedcounts,
5615
        $expectedcounts,
5616
        $expectedunreadcounts,
5616
        $expectedunreadcounts,
5617
        $deletedusers
5617
        $deletedusers
5618
    ) {
5618
    ): void {
5619
        $this->resetAfterTest();
5619
        $this->resetAfterTest();
5620
        $generator = $this->getDataGenerator();
5620
        $generator = $this->getDataGenerator();
5621
        $users = [
5621
        $users = [
5622
            $generator->create_user(),
5622
            $generator->create_user(),
5623
            $generator->create_user(),
5623
            $generator->create_user(),
Línea 5682... Línea 5682...
5682
    }
5682
    }
Línea 5683... Línea 5683...
5683
 
5683
 
5684
    /**
5684
    /**
5685
     * Test delete_message for all users.
5685
     * Test delete_message for all users.
5686
     */
5686
     */
5687
    public function test_delete_message_for_all_users() {
5687
    public function test_delete_message_for_all_users(): void {
Línea 5688... Línea 5688...
5688
        global $DB;
5688
        global $DB;
Línea 5689... Línea 5689...
5689
 
5689
 
Línea 5728... Línea 5728...
5728
    }
5728
    }
Línea 5729... Línea 5729...
5729
 
5729
 
5730
    /**
5730
    /**
5731
     * Test delete_message for all users with messaging disabled.
5731
     * Test delete_message for all users with messaging disabled.
5732
     */
5732
     */
5733
    public function test_delete_message_for_all_users_messaging_disabled() {
5733
    public function test_delete_message_for_all_users_messaging_disabled(): void {
Línea 5734... Línea 5734...
5734
        global $CFG;
5734
        global $CFG;
Línea 5735... Línea 5735...
5735
 
5735
 
Línea 5752... Línea 5752...
5752
    }
5752
    }
Línea 5753... Línea 5753...
5753
 
5753
 
5754
    /**
5754
    /**
5755
     * Test delete_message for all users with no permission.
5755
     * Test delete_message for all users with no permission.
5756
     */
5756
     */
5757
    public function test_delete_message_for_all_users_no_permission() {
5757
    public function test_delete_message_for_all_users_no_permission(): void {
Línea 5758... Línea 5758...
5758
        $this->resetAfterTest();
5758
        $this->resetAfterTest();
5759
 
5759
 
Línea 5772... Línea 5772...
5772
    }
5772
    }
Línea 5773... Línea 5773...
5773
 
5773
 
5774
    /**
5774
    /**
5775
     * Test delete_message for all users in a private conversation.
5775
     * Test delete_message for all users in a private conversation.
5776
     */
5776
     */
5777
    public function test_delete_message_for_all_users_private_conversation() {
5777
    public function test_delete_message_for_all_users_private_conversation(): void {
Línea 5778... Línea 5778...
5778
        global $DB;
5778
        global $DB;
Línea 5779... Línea 5779...
5779
 
5779
 
Línea 5801... Línea 5801...
5801
 
5801
 
5802
    /**
5802
    /**
5803
     * Test retrieving conversation messages by providing a timefrom higher than last message timecreated. It should return no
5803
     * Test retrieving conversation messages by providing a timefrom higher than last message timecreated. It should return no
5804
     * messages but keep the return structure to not break when called from the ws.
5804
     * messages but keep the return structure to not break when called from the ws.
5805
     */
5805
     */
5806
    public function test_get_conversation_messages_timefrom_higher_than_last_timecreated() {
5806
    public function test_get_conversation_messages_timefrom_higher_than_last_timecreated(): void {
Línea 5807... Línea 5807...
5807
        $this->resetAfterTest(true);
5807
        $this->resetAfterTest(true);
5808
 
5808
 
5809
        // Create some users.
5809
        // Create some users.