Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 24... Línea 24...
24
 * @copyright  2012 The Open Universtiy
24
 * @copyright  2012 The Open Universtiy
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
26
 */
27
class messagelib_test extends \advanced_testcase {
27
class messagelib_test extends \advanced_testcase {
Línea 28... Línea 28...
28
 
28
 
29
    public function test_message_provider_disabled() {
29
    public function test_message_provider_disabled(): void {
30
        $this->resetAfterTest();
30
        $this->resetAfterTest();
Línea 31... Línea 31...
31
        $this->preventResetByRollback();
31
        $this->preventResetByRollback();
32
 
32
 
Línea 64... Línea 64...
64
        message_send($message);
64
        message_send($message);
65
        $emails = $sink->get_messages();
65
        $emails = $sink->get_messages();
66
        $email = reset($emails);
66
        $email = reset($emails);
67
        $this->assertEquals(get_string('unreadnewmessage', 'message', fullname(get_admin())), $email->subject);
67
        $this->assertEquals(get_string('unreadnewmessage', 'message', fullname(get_admin())), $email->subject);
68
    }
68
    }
69
    public function test_message_get_providers_for_user() {
69
    public function test_message_get_providers_for_user(): void {
70
        global $CFG, $DB;
70
        global $CFG, $DB;
Línea 71... Línea 71...
71
 
71
 
Línea 72... Línea 72...
72
        $this->resetAfterTest();
72
        $this->resetAfterTest();
Línea 117... Línea 117...
117
        $this->assertTrue($this->message_type_present('mod_quiz', 'confirmation', $providers));
117
        $this->assertTrue($this->message_type_present('mod_quiz', 'confirmation', $providers));
118
        $this->assertFalse($this->message_type_present('mod_quiz', 'attempt_overdue', $providers));
118
        $this->assertFalse($this->message_type_present('mod_quiz', 'attempt_overdue', $providers));
119
        $this->assertFalse($this->message_type_present('mod_quiz', 'submission', $providers));
119
        $this->assertFalse($this->message_type_present('mod_quiz', 'submission', $providers));
120
    }
120
    }
Línea 121... Línea 121...
121
 
121
 
122
    public function test_message_get_providers_for_user_more() {
122
    public function test_message_get_providers_for_user_more(): void {
Línea 123... Línea 123...
123
        global $DB;
123
        global $DB;
Línea 124... Línea 124...
124
 
124
 
Línea 178... Línea 178...
178
        // Actually, handling PROHIBITs would be too expensive. We do not
178
        // Actually, handling PROHIBITs would be too expensive. We do not
179
        // care if users with PROHIBITs see a few more preferences than they should.
179
        // care if users with PROHIBITs see a few more preferences than they should.
180
        // $this->assertFalse($this->message_type_present('moodle', 'backup', $providers));
180
        // $this->assertFalse($this->message_type_present('moodle', 'backup', $providers));
181
    }
181
    }
Línea 182... Línea 182...
182
 
182
 
183
    public function test_send_message_redirection() {
183
    public function test_send_message_redirection(): void {
Línea 184... Línea 184...
184
        global $DB;
184
        global $DB;
Línea 185... Línea 185...
185
 
185
 
Línea 390... Línea 390...
390
        $this->assertDebuggingCalled('Necessary properties missing in userto object, fetching full record');
390
        $this->assertDebuggingCalled('Necessary properties missing in userto object, fetching full record');
391
        $sink->clear();
391
        $sink->clear();
392
        $user2->emailstop = '0';
392
        $user2->emailstop = '0';
393
    }
393
    }
Línea 394... Línea 394...
394
 
394
 
395
    public function test_send_message() {
395
    public function test_send_message(): void {
396
        global $DB, $CFG;
396
        global $DB, $CFG;
397
        $this->preventResetByRollback();
397
        $this->preventResetByRollback();
Línea 398... Línea 398...
398
        $this->resetAfterTest();
398
        $this->resetAfterTest();
Línea 748... Línea 748...
748
     *
748
     *
749
     * Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
749
     * Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
750
     * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
750
     * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
751
     * need to be sure this is covered.
751
     * need to be sure this is covered.
752
     */
752
     */
753
    public function test_message_send_to_conversation_individual() {
753
    public function test_message_send_to_conversation_individual(): void {
754
        global $DB;
754
        global $DB;
755
        $this->preventResetByRollback();
755
        $this->preventResetByRollback();
756
        $this->resetAfterTest();
756
        $this->resetAfterTest();
Línea 757... Línea 757...
757
 
757
 
Línea 835... Línea 835...
835
     *
835
     *
836
     * Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
836
     * Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
837
     * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
837
     * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
838
     * need to be sure this is covered.
838
     * need to be sure this is covered.
839
     */
839
     */
840
    public function test_message_send_to_self_conversation() {
840
    public function test_message_send_to_self_conversation(): void {
841
        global $DB;
841
        global $DB;
842
        $this->preventResetByRollback();
842
        $this->preventResetByRollback();
843
        $this->resetAfterTest();
843
        $this->resetAfterTest();
Línea 844... Línea 844...
844
 
844
 
Línea 888... Línea 888...
888
     *
888
     *
889
     * Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
889
     * Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
890
     * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
890
     * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
891
     * need to be sure this is covered.
891
     * need to be sure this is covered.
892
     */
892
     */
893
    public function test_message_send_to_conversation_group() {
893
    public function test_message_send_to_conversation_group(): void {
894
        global $DB;
894
        global $DB;
895
        $this->preventResetByRollback();
895
        $this->preventResetByRollback();
896
        $this->resetAfterTest();
896
        $this->resetAfterTest();
Línea 897... Línea 897...
897
 
897
 
Línea 974... Línea 974...
974
    /**
974
    /**
975
     * Verify that sending a message to a conversation is an action which can be buffered by the manager if in a DB transaction.
975
     * Verify that sending a message to a conversation is an action which can be buffered by the manager if in a DB transaction.
976
     *
976
     *
977
     * This should defer all processor calls (for 2 members in this case), and event creation (1 event).
977
     * This should defer all processor calls (for 2 members in this case), and event creation (1 event).
978
     */
978
     */
979
    public function test_send_message_to_conversation_group_with_buffering() {
979
    public function test_send_message_to_conversation_group_with_buffering(): void {
980
        global $DB, $CFG;
980
        global $DB, $CFG;
981
        $this->preventResetByRollback();
981
        $this->preventResetByRollback();
982
        $this->resetAfterTest();
982
        $this->resetAfterTest();
Línea 983... Línea 983...
983
 
983
 
Línea 1049... Línea 1049...
1049
        $this->assertCount(2, $emails);
1049
        $this->assertCount(2, $emails);
1050
        $this->assertCount(1, $events);
1050
        $this->assertCount(1, $events);
1051
        $this->assertInstanceOf('\core\event\group_message_sent', $events[0]);
1051
        $this->assertInstanceOf('\core\event\group_message_sent', $events[0]);
1052
    }
1052
    }
Línea 1053... Línea 1053...
1053
 
1053
 
1054
    public function test_rollback() {
1054
    public function test_rollback(): void {
Línea 1055... Línea 1055...
1055
        global $DB;
1055
        global $DB;
1056
 
1056
 
Línea 1111... Línea 1111...
1111
 
1111
 
1112
        message_send($message);
1112
        message_send($message);
1113
        $this->assertEquals(1, $mailsink->count());
1113
        $this->assertEquals(1, $mailsink->count());
Línea 1114... Línea 1114...
1114
    }
1114
    }
1115
 
1115
 
Línea 1116... Línea 1116...
1116
    public function test_forced_rollback() {
1116
    public function test_forced_rollback(): void {
1117
        global $DB;
1117
        global $DB;
1118
 
1118
 
Línea 1155... Línea 1155...
1155
 
1155
 
1156
        message_send($message);
1156
        message_send($message);
1157
        $this->assertDebuggingCalled('Not sending email due to $CFG->noemailever config setting');
1157
        $this->assertDebuggingCalled('Not sending email due to $CFG->noemailever config setting');
Línea 1158... Línea 1158...
1158
    }
1158
    }
1159
 
1159
 
1160
    public function test_message_attachment_send() {
1160
    public function test_message_attachment_send(): void {
1161
        global $CFG;
1161
        global $CFG;
Línea 1162... Línea 1162...
1162
        $this->preventResetByRollback();
1162
        $this->preventResetByRollback();
Línea 1210... Línea 1210...
1210
        $storedfileexists = $fs->file_exists($filerecord['contextid'], $filerecord['component'], $filerecord['filearea'],
1210
        $storedfileexists = $fs->file_exists($filerecord['contextid'], $filerecord['component'], $filerecord['filearea'],
1211
                                             $filerecord['itemid'], $filerecord['filepath'], $filerecord['filename']);
1211
                                             $filerecord['itemid'], $filerecord['filepath'], $filerecord['filename']);
1212
        $this->assertTrue($storedfileexists);
1212
        $this->assertTrue($storedfileexists);
1213
    }
1213
    }
Línea 1214... Línea 1214...
1214
 
1214
 
1215
    public function test_send_message_when_muted() {
1215
    public function test_send_message_when_muted(): void {
1216
        $this->preventResetByRollback();
1216
        $this->preventResetByRollback();
Línea 1217... Línea 1217...
1217
        $this->resetAfterTest();
1217
        $this->resetAfterTest();
1218
 
1218