Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Trait matrix_helper_trait to generate initial setup for matrix mock and associated helpers.

Copyright: 2023 Safat Shahin <safat.shahin@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 295 lines (9 kb)
Included or required: 4 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions


Functions that are not part of a class:

initialise_mock_configs()   X-Ref
Initialize the mock configs in settings.

return: void

get_matrix_server_url()   X-Ref
Get the mock server url.

return: string

get_matrix_access_token()   X-Ref
Get the matrix access token.

return: string

initialise_mock_server()   X-Ref
This test requires mock server to be present.

return: void

get_matrix_room_data(string $roomid)   X-Ref
Get matrix room data from matrix server.

param: string $roomid The id of the room
return: \stdClass

get_matrix_user_data(string $roomid, string $matrixuserid)   X-Ref
Get matrix user data from matrix server.

param: string $roomid The id of the room
param: string $matrixuserid The id of the user
return: \stdClass

backoffice_get_all_users()   X-Ref
A backoffice call to get all registered users from our mock server.

return: array

backoffice_create_users_and_rooms(array $users = [],array $rooms = [],)   X-Ref
A backoffice method to create users and rooms on our mock server.

param: array $users
param: array $rooms

request(array $jsonarray = [], array $headers = [])   X-Ref
The http request for the api call.

param: array $jsonarray The array of json
param: array $headers The array of headers
return: \core\http_client

get_backoffice_uri(string $endpoint)   X-Ref
Get the URI of a backoffice endpoint on the mock server.

param: string $endpoint
return: string

backoffice_get_all_rooms()   X-Ref
Fetch all rooms from the back office.

return: array

backoffice_get_room()   X-Ref
Return the first room from the server.

In most cases there is only one room.
return: \stdClass

reset_mock()   X-Ref
Reset the mock server

return: void

create_matrix_room(?string $component = 'core_course',?string $itemtype = 'example',?int $itemid = 1,?string $roomname = null,?string $roomtopic = null,?\stored_file $roomavatar = null,array $members = [],?context $context = null,)   X-Ref
Helper to create a room.

param: null|string $component
param: null|string $itemtype
param: null|int $itemid
param: null|string $roomname
param: null|string $roomtopic
param: null|stored_file $roomavatar
param: array $members
return: api