Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 104... Línea 104...
104
        $record = $DB->get_record('messageinbound_handlers', array('classname' => '\mod_forum\message\inbound\reply_handler'));
104
        $record = $DB->get_record('messageinbound_handlers', array('classname' => '\mod_forum\message\inbound\reply_handler'));
105
        $record->enabled = true;
105
        $record->enabled = true;
106
        $record->id = $DB->update_record('messageinbound_handlers', $record);
106
        $record->id = $DB->update_record('messageinbound_handlers', $record);
107
    }
107
    }
Línea 108... Línea 108...
108
 
108
 
109
    public function test_cron_message_includes_courseid() {
109
    public function test_cron_message_includes_courseid(): void {
Línea 110... Línea 110...
110
        $this->resetAfterTest(true);
110
        $this->resetAfterTest(true);
111
 
111
 
Línea 142... Línea 142...
142
        $this->assertEquals($course->id, $event->other['courseid']);
142
        $this->assertEquals($course->id, $event->other['courseid']);
Línea 143... Línea 143...
143
 
143
 
144
        $this->send_notifications_and_assert($recipient, [$post]);
144
        $this->send_notifications_and_assert($recipient, [$post]);
Línea 145... Línea 145...
145
    }
145
    }
146
 
146
 
147
    public function test_forced_subscription() {
147
    public function test_forced_subscription(): void {
Línea 148... Línea 148...
148
        global $DB;
148
        global $DB;
149
        $this->resetAfterTest(true);
149
        $this->resetAfterTest(true);
Línea 193... Línea 193...
193
    }
193
    }
Línea 194... Línea 194...
194
 
194
 
195
    /**
195
    /**
196
     * Ensure that for a forum with subscription disabled that standard users will not receive posts.
196
     * Ensure that for a forum with subscription disabled that standard users will not receive posts.
197
     */
197
     */
198
    public function test_subscription_disabled_standard_users() {
198
    public function test_subscription_disabled_standard_users(): void {
Línea 199... Línea 199...
199
        global $DB;
199
        global $DB;
Línea 200... Línea 200...
200
 
200
 
Línea 230... Línea 230...
230
    }
230
    }
Línea 231... Línea 231...
231
 
231
 
232
    /**
232
    /**
233
     * Ensure that for a forum with subscription disabled that a user subscribed to the forum will receive the post.
233
     * Ensure that for a forum with subscription disabled that a user subscribed to the forum will receive the post.
234
     */
234
     */
235
    public function test_subscription_disabled_user_subscribed_forum() {
235
    public function test_subscription_disabled_user_subscribed_forum(): void {
Línea 236... Línea 236...
236
        global $DB;
236
        global $DB;
Línea 237... Línea 237...
237
 
237
 
Línea 279... Línea 279...
279
 
279
 
280
    /**
280
    /**
281
     * Ensure that for a forum with subscription disabled that a user subscribed to the discussion will receive the
281
     * Ensure that for a forum with subscription disabled that a user subscribed to the discussion will receive the
282
     * post.
282
     * post.
283
     */
283
     */
284
    public function test_subscription_disabled_user_subscribed_discussion() {
284
    public function test_subscription_disabled_user_subscribed_discussion(): void {
Línea 285... Línea 285...
285
        global $DB;
285
        global $DB;
Línea 286... Línea 286...
286
 
286
 
Línea 323... Línea 323...
323
    }
323
    }
Línea 324... Línea 324...
324
 
324
 
325
    /**
325
    /**
326
     * Ensure that for a forum with automatic subscription that users receive posts.
326
     * Ensure that for a forum with automatic subscription that users receive posts.
327
     */
327
     */
328
    public function test_automatic() {
328
    public function test_automatic(): void {
Línea 329... Línea 329...
329
        $this->resetAfterTest(true);
329
        $this->resetAfterTest(true);
330
 
330
 
Línea 358... Línea 358...
358
 
358
 
359
    /**
359
    /**
360
     * Ensure that private replies are not sent to users with an automatic subscription unless they are an expected
360
     * Ensure that private replies are not sent to users with an automatic subscription unless they are an expected
361
     * recipient.
361
     * recipient.
362
     */
362
     */
363
    public function test_automatic_with_private_reply() {
363
    public function test_automatic_with_private_reply(): void {
Línea 364... Línea 364...
364
        $this->resetAfterTest(true);
364
        $this->resetAfterTest(true);
365
 
365
 
366
        // Create a course, with a forum.
366
        // Create a course, with a forum.
Línea 404... Línea 404...
404
        $this->send_notifications_and_assert($teacher, [$post, $reply]);
404
        $this->send_notifications_and_assert($teacher, [$post, $reply]);
405
        $this->send_notifications_and_assert($otherteacher, [$post, $reply]);
405
        $this->send_notifications_and_assert($otherteacher, [$post, $reply]);
406
        $this->send_notifications_and_assert($otherstudent, [$post]);
406
        $this->send_notifications_and_assert($otherstudent, [$post]);
407
    }
407
    }
Línea 408... Línea 408...
408
 
408
 
409
    public function test_optional() {
409
    public function test_optional(): void {
Línea 410... Línea 410...
410
        $this->resetAfterTest(true);
410
        $this->resetAfterTest(true);
411
 
411
 
Línea 435... Línea 435...
435
 
435
 
436
        $this->send_notifications_and_assert($author, []);
436
        $this->send_notifications_and_assert($author, []);
437
        $this->send_notifications_and_assert($recipient, []);
437
        $this->send_notifications_and_assert($recipient, []);
Línea 438... Línea 438...
438
    }
438
    }
439
 
439
 
Línea 440... Línea 440...
440
    public function test_automatic_with_unsubscribed_user() {
440
    public function test_automatic_with_unsubscribed_user(): void {
441
        $this->resetAfterTest(true);
441
        $this->resetAfterTest(true);
Línea 469... Línea 469...
469
 
469
 
470
        $this->send_notifications_and_assert($author, []);
470
        $this->send_notifications_and_assert($author, []);
471
        $this->send_notifications_and_assert($recipient, [$post]);
471
        $this->send_notifications_and_assert($recipient, [$post]);
Línea 472... Línea 472...
472
    }
472
    }
473
 
473
 
Línea 474... Línea 474...
474
    public function test_optional_with_subscribed_user() {
474
    public function test_optional_with_subscribed_user(): void {
475
        $this->resetAfterTest(true);
475
        $this->resetAfterTest(true);
Línea 503... Línea 503...
503
 
503
 
504
        $this->send_notifications_and_assert($author, []);
504
        $this->send_notifications_and_assert($author, []);
505
        $this->send_notifications_and_assert($recipient, [$post]);
505
        $this->send_notifications_and_assert($recipient, [$post]);
Línea 506... Línea 506...
506
    }
506
    }
507
 
507
 
Línea 508... Línea 508...
508
    public function test_automatic_with_unsubscribed_discussion() {
508
    public function test_automatic_with_unsubscribed_discussion(): void {
509
        $this->resetAfterTest(true);
509
        $this->resetAfterTest(true);
Línea 540... Línea 540...
540
 
540
 
541
        $this->send_notifications_and_assert($author, []);
541
        $this->send_notifications_and_assert($author, []);
542
        $this->send_notifications_and_assert($recipient, [$post]);
542
        $this->send_notifications_and_assert($recipient, [$post]);
Línea 543... Línea 543...
543
    }
543
    }
544
 
544
 
Línea 545... Línea 545...
545
    public function test_optional_with_subscribed_discussion() {
545
    public function test_optional_with_subscribed_discussion(): void {
546
        $this->resetAfterTest(true);
546
        $this->resetAfterTest(true);
Línea 598... Línea 598...
598
 
598
 
599
        $this->send_notifications_and_assert($author, []);
599
        $this->send_notifications_and_assert($author, []);
600
        $this->send_notifications_and_assert($recipient, [$reply]);
600
        $this->send_notifications_and_assert($recipient, [$reply]);
Línea 601... Línea 601...
601
    }
601
    }
602
 
602
 
Línea 603... Línea 603...
603
    public function test_optional_with_subscribed_discussion_and_post() {
603
    public function test_optional_with_subscribed_discussion_and_post(): void {
604
        $this->resetAfterTest(true);
604
        $this->resetAfterTest(true);
Línea 644... Línea 644...
644
 
644
 
645
        $this->send_notifications_and_assert($author, []);
645
        $this->send_notifications_and_assert($author, []);
646
        $this->send_notifications_and_assert($recipient, [$reply]);
646
        $this->send_notifications_and_assert($recipient, [$reply]);
Línea 647... Línea 647...
647
    }
647
    }
648
 
648
 
Línea 649... Línea 649...
649
    public function test_automatic_with_subscribed_discussion_in_unsubscribed_forum() {
649
    public function test_automatic_with_subscribed_discussion_in_unsubscribed_forum(): void {
650
        $this->resetAfterTest(true);
650
        $this->resetAfterTest(true);
Línea 702... Línea 702...
702
 
702
 
703
        $this->send_notifications_and_assert($author, [$reply]);
703
        $this->send_notifications_and_assert($author, [$reply]);
704
        $this->send_notifications_and_assert($recipient, [$reply]);
704
        $this->send_notifications_and_assert($recipient, [$reply]);
Línea 705... Línea 705...
705
    }
705
    }
706
 
706
 
Línea 707... Línea 707...
707
    public function test_optional_with_unsubscribed_discussion_in_subscribed_forum() {
707
    public function test_optional_with_unsubscribed_discussion_in_subscribed_forum(): void {
708
        $this->resetAfterTest(true);
708
        $this->resetAfterTest(true);
Línea 744... Línea 744...
744
 
744
 
745
    /**
745
    /**
746
     * Test that a user unsubscribed from a forum who has subscribed to a discussion, only receives posts made after
746
     * Test that a user unsubscribed from a forum who has subscribed to a discussion, only receives posts made after
747
     * they subscribed to the discussion.
747
     * they subscribed to the discussion.
748
     */
748
     */
749
    public function test_forum_discussion_subscription_forum_unsubscribed_discussion_subscribed_after_post() {
749
    public function test_forum_discussion_subscription_forum_unsubscribed_discussion_subscribed_after_post(): void {
Línea 750... Línea 750...
750
        $this->resetAfterTest(true);
750
        $this->resetAfterTest(true);
751
 
751
 
Línea 787... Línea 787...
787
        $this->queue_tasks_and_assert($expect);
787
        $this->queue_tasks_and_assert($expect);
Línea 788... Línea 788...
788
 
788
 
789
        $this->send_notifications_and_assert($author, [$reply]);
789
        $this->send_notifications_and_assert($author, [$reply]);
Línea 790... Línea 790...
790
    }
790
    }
791
 
791
 
792
    public function test_subscription_by_inactive_users() {
792
    public function test_subscription_by_inactive_users(): void {
Línea 793... Línea 793...
793
        global $DB;
793
        global $DB;
Línea 834... Línea 834...
834
        $this->send_notifications_and_assert($u1, []);
834
        $this->send_notifications_and_assert($u1, []);
835
        $this->send_notifications_and_assert($u2, []);
835
        $this->send_notifications_and_assert($u2, []);
836
        $this->send_notifications_and_assert($u3, [$post]);
836
        $this->send_notifications_and_assert($u3, [$post]);
837
    }
837
    }
Línea 838... Línea 838...
838
 
838
 
839
    public function test_forum_message_inbound_multiple_posts() {
839
    public function test_forum_message_inbound_multiple_posts(): void {
Línea 840... Línea 840...
840
        $this->resetAfterTest(true);
840
        $this->resetAfterTest(true);
841
 
841
 
842
        // Create a course, with a forum.
842
        // Create a course, with a forum.
Línea 897... Línea 897...
897
        foreach ($messages as $message) {
897
        foreach ($messages as $message) {
898
            $this->assertMatchesRegularExpression('/Reply-To: moodlemoodle123\+[^@]*@example.com/', $message->header);
898
            $this->assertMatchesRegularExpression('/Reply-To: moodlemoodle123\+[^@]*@example.com/', $message->header);
899
        }
899
        }
900
    }
900
    }
Línea 901... Línea 901...
901
 
901
 
902
    public function test_long_subject() {
902
    public function test_long_subject(): void {
Línea 903... Línea 903...
903
        $this->resetAfterTest(true);
903
        $this->resetAfterTest(true);
904
 
904
 
Línea 934... Línea 934...
934
    }
934
    }
Línea 935... Línea 935...
935
 
935
 
936
    /**
936
    /**
937
     * Test inital email and reply email subjects
937
     * Test inital email and reply email subjects
938
     */
938
     */
939
    public function test_subjects() {
939
    public function test_subjects(): void {
Línea 940... Línea 940...
940
        $this->resetAfterTest(true);
940
        $this->resetAfterTest(true);
Línea 941... Línea 941...
941
 
941
 
Línea 1145... Línea 1145...
1145
     * Verify forum emails body using templates to generate the expected results.
1145
     * Verify forum emails body using templates to generate the expected results.
1146
     *
1146
     *
1147
     * @dataProvider forum_post_email_templates_provider
1147
     * @dataProvider forum_post_email_templates_provider
1148
     * @param array $data provider samples.
1148
     * @param array $data provider samples.
1149
     */
1149
     */
1150
    public function test_forum_post_email_templates($data) {
1150
    public function test_forum_post_email_templates($data): void {
1151
        global $DB;
1151
        global $DB;
Línea 1152... Línea 1152...
1152
 
1152
 
Línea 1153... Línea 1153...
1153
        $this->resetAfterTest();
1153
        $this->resetAfterTest();
Línea 1276... Línea 1276...
1276
    }
1276
    }
Línea 1277... Línea 1277...
1277
 
1277
 
1278
    /**
1278
    /**
1279
     * Ensure that posts already mailed are not re-sent.
1279
     * Ensure that posts already mailed are not re-sent.
1280
     */
1280
     */
1281
    public function test_already_mailed() {
1281
    public function test_already_mailed(): void {
Línea 1282... Línea 1282...
1282
        global $DB;
1282
        global $DB;
Línea 1283... Línea 1283...
1283
 
1283
 
Línea 1305... Línea 1305...
1305
    }
1305
    }
Línea 1306... Línea 1306...
1306
 
1306
 
1307
    /**
1307
    /**
1308
     * Ensure that posts marked mailnow are not suspect to the maxeditingtime.
1308
     * Ensure that posts marked mailnow are not suspect to the maxeditingtime.
1309
     */
1309
     */
1310
    public function test_mailnow() {
1310
    public function test_mailnow(): void {
Línea 1311... Línea 1311...
1311
        global $CFG, $DB;
1311
        global $CFG, $DB;
1312
 
1312
 
Línea 1349... Línea 1349...
1349
    }
1349
    }
Línea 1350... Línea 1350...
1350
 
1350
 
1351
    /**
1351
    /**
1352
     * Ensure that if a user has no permission to view a post, then it is not sent.
1352
     * Ensure that if a user has no permission to view a post, then it is not sent.
1353
     */
1353
     */
1354
    public function test_access_coursemodule_hidden() {
1354
    public function test_access_coursemodule_hidden(): void {
Línea 1355... Línea 1355...
1355
        global $CFG, $DB;
1355
        global $CFG, $DB;
Línea 1356... Línea 1356...
1356
 
1356
 
Línea 1398... Línea 1398...
1398
    }
1398
    }
Línea 1399... Línea 1399...
1399
 
1399
 
1400
    /**
1400
    /**
1401
     * Ensure that if a user loses permission to view a post after it is queued, that it is not sent.
1401
     * Ensure that if a user loses permission to view a post after it is queued, that it is not sent.
1402
     */
1402
     */
1403
    public function test_access_coursemodule_hidden_after_queue() {
1403
    public function test_access_coursemodule_hidden_after_queue(): void {
Línea 1404... Línea 1404...
1404
        global $CFG, $DB;
1404
        global $CFG, $DB;
Línea 1405... Línea 1405...
1405
 
1405
 
Línea 1449... Línea 1449...
1449
    }
1449
    }
Línea 1450... Línea 1450...
1450
 
1450
 
1451
    /**
1451
    /**
1452
     * Ensure that messages are not sent until the timestart.
1452
     * Ensure that messages are not sent until the timestart.
1453
     */
1453
     */
1454
    public function test_access_before_timestart() {
1454
    public function test_access_before_timestart(): void {
Línea 1455... Línea 1455...
1455
        global $CFG, $DB;
1455
        global $CFG, $DB;
Línea 1456... Línea 1456...
1456
 
1456
 
Línea 1509... Línea 1509...
1509
    }
1509
    }
Línea 1510... Línea 1510...
1510
 
1510
 
1511
    /**
1511
    /**
1512
     * Ensure that messages are not sent after the timeend.
1512
     * Ensure that messages are not sent after the timeend.
1513
     */
1513
     */
1514
    public function test_access_after_timeend() {
1514
    public function test_access_after_timeend(): void {
Línea 1515... Línea 1515...
1515
        global $CFG, $DB;
1515
        global $CFG, $DB;
Línea 1516... Línea 1516...
1516
 
1516
 
Línea 1569... Línea 1569...
1569
    }
1569
    }
Línea 1570... Línea 1570...
1570
 
1570
 
1571
    /**
1571
    /**
1572
     * Test notification comes with customdata.
1572
     * Test notification comes with customdata.
1573
     */
1573
     */
1574
    public function test_notification_customdata() {
1574
    public function test_notification_customdata(): void {
Línea 1575... Línea 1575...
1575
        $this->resetAfterTest(true);
1575
        $this->resetAfterTest(true);
Línea 1576... Línea 1576...
1576
 
1576