Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Class: messagelib_test  - X-Ref

Tests for messagelib.php.

test_message_provider_disabled()   X-Ref
No description

test_message_get_providers_for_user()   X-Ref
No description

test_message_get_providers_for_user_more()   X-Ref
No description

test_send_message_redirection()   X-Ref
No description

test_send_message()   X-Ref
No description

test_message_send_to_conversation_individual()   X-Ref
Tests calling message_send() with $eventdata representing a message to an individual conversation.

This test will verify:
- that the 'messages' record is created.
- that the processors will be called for each conversation member, except the sender.
- the a single event will be generated - 'message_sent'

Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
need to be sure this is covered.

test_message_send_to_self_conversation()   X-Ref
Tests calling message_send() with $eventdata representing a message to a self-conversation.

This test will verify:
- that the 'messages' record is created.
- that the processors is not called (for now self-conversations are not processed).
- the a single event will be generated - 'message_sent'

Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
need to be sure this is covered.

test_message_send_to_conversation_group()   X-Ref
Tests calling message_send() with $eventdata representing a message to an group conversation.

This test will verify:
- that the 'messages' record is created.
- that the processors will be called for each conversation member, except the sender.
- the a single event will be generated - 'group_message_sent'

Note: We won't redirect/capture messages in this test because doing so causes message_send() to return early, before
processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we
need to be sure this is covered.

test_send_message_to_conversation_group_with_buffering()   X-Ref
Verify that sending a message to a conversation is an action which can be buffered by the manager if in a DB transaction.

This should defer all processor calls (for 2 members in this case), and event creation (1 event).

test_rollback()   X-Ref
No description

test_forced_rollback()   X-Ref
No description

test_message_attachment_send()   X-Ref
No description

test_send_message_when_muted()   X-Ref
No description

message_type_present($component, $name, $providers)   X-Ref
Is a particular message type in the list of message types.

param: string $component
param: string $name a message name.
param: array $providers as returned by message_get_providers_for_user.
return: bool whether the message type is present.