Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_message\tests\helper Class Reference

The helper class providing util methods for testing. More...

Static Public Member Functions

static send_fake_message_to_conversation (\stdClass $userfrom, int $convid, string $message='Hello world!', int $time=null)
 Sends a message to a conversation.
 
static send_fake_read_notification (\stdClass $userfrom, stdClass $userto, string $message='Hello world!', int $timecreated=0, int $timeread=0)
 Send a fake read notification.
 
static send_fake_unread_notification (\stdClass $userfrom, stdClass $userto, string $message='Hello world!', int $timecreated=0)
 Send a fake unread notification.
 

Detailed Description

The helper class providing util methods for testing.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ send_fake_message_to_conversation()

static core_message\tests\helper::send_fake_message_to_conversation ( \stdClass $userfrom,
int $convid,
string $message = 'Hello world!',
int $time = null )
static

Sends a message to a conversation.

Parameters
stdClass$userfromuser object of the one sending the message.
int$convidid of the conversation in which we'll send the message.
string$messagemessage to send.
int$timethe time the message was sent.
Return values
intthe id of the message which was sent.
Exceptions
dml_exceptionif the conversation doesn't exist.

◆ send_fake_read_notification()

static core_message\tests\helper::send_fake_read_notification ( \stdClass $userfrom,
stdClass $userto,
string $message = 'Hello world!',
int $timecreated = 0,
int $timeread = 0 )
static

Send a fake read notification.

message_send() does not support transaction, this function will simulate a message sent from a user to another. We should stop using it once message_send() will support transactions. This is not clean at all, this is just used to add rows to the table.

Parameters
stdClass$userfromuser object of the one sending the message.
stdClass$usertouser object of the one receiving the message.
string$messagemessage to send.
int$timecreatedtime the message was created.
int$timereadthe the message was read
Return values
intthe id of the message

◆ send_fake_unread_notification()

static core_message\tests\helper::send_fake_unread_notification ( \stdClass $userfrom,
stdClass $userto,
string $message = 'Hello world!',
int $timecreated = 0 )
static

Send a fake unread notification.

message_send() does not support transaction, this function will simulate a message sent from a user to another. We should stop using it once message_send() will support transactions. This is not clean at all, this is just used to add rows to the table.

Parameters
stdClass$userfromuser object of the one sending the message.
stdClass$usertouser object of the one receiving the message.
string$messagemessage to send.
int$timecreatedtime the message was created.
Return values
intthe id of the message

The documentation for this class was generated from the following file: