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.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 6510 lines (286 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

api_test:: (158 methods):
  test_mark_all_read_for_user_touser()
  test_mark_all_read_for_user_touser_with_fromuser()
  test_mark_all_read_for_user_touser_with_type()
  test_count_blocked_users()
  test_message_search_users_messagingallusers_disabled()
  test_message_search_users_messagingallusers_enabled()
  test_message_search_users_self_conversations()
  test_message_search_users_with_empty_result()
  test_message_search_users_limit_offset()
  test_message_search_users_with_cap()
  test_message_search_users_messaging_disabled()
  test_get_conversations_between_users()
  test_get_self_conversation()
  test_search_messages()
  test_get_favourite_conversations()
  test_get_favourite_conversations_limit_offset()
  test_get_favourite_conversations_with_deleted_user()
  test_set_favourite_conversation()
  test_set_favourite_conversation_nonexistent_conversation()
  test_set_favourite_conversation_non_member()
  test_unset_favourite_conversation()
  test_unset_favourite_conversation_not_favourite()
  test_unset_favourite_conversation_non_existent_conversation()
  create_conversation_test_data()
  test_get_conversations_no_restrictions()
  test_get_conversations_message_format()
  test_get_conversations_some_muted()
  test_get_conversations_limit_offset()
  test_get_conversations_type_filter()
  test_get_conversations_self_conversations()
  test_get_conversations_with_deleted_user()
  test_get_conversations_deleted_messages()
  test_get_conversations_favourite_conversations_single()
  test_get_conversations_favourite_conversations()
  test_get_conversations_user_in_group_and_individual_chat()
  test_get_conversations_group_linked()
  get_conversations_mixed_provider()
  test_create_conversation_duplicate_conversations()
  test_get_conversations_mixed()
  test_get_user_contacts()
  test_get_conversation_messages()
  test_get_group_conversation_messages()
  test_get_conversation_messages_sorting()
  test_get_conversation_messages_time_from_only()
  test_get_conversation_messages_time_to_only()
  test_get_conversation_messages_time_from_and_to()
  test_get_conversation_messages_limitfrom_only()
  test_get_conversation_messages_limitnum()
  test_get_most_recent_conversation_message()
  test_can_mark_all_messages_as_read()
  test_can_delete_conversation()
  test_delete_conversation_by_id()
  test_count_unread_conversations()
  test_count_unread_conversations_disabled()
  test_get_all_message_preferences()
  test_can_send_message()
  test_can_send_message_without_sendmessage_cap()
  test_can_send_message_when_contact()
  test_can_send_message_when_not_contact()
  test_can_send_message_when_blocked()
  test_can_send_message_site_messaging_setting()
  test_can_send_message_with_messageanyuser_cap()
  test_can_send_message_even_if_blocked()
  test_can_send_message_even_if_blocked_with_message_any_user_cap()
  test_can_send_message_even_if_blocked_with_read_all_message_cap()
  test_can_send_message_even_if_blocked_shared_course()
  test_can_send_message_even_if_blocked_shared_course_with_message_any_user_cap()
  test_can_send_message_to_conversation_basic()
  test_can_send_message_to_conversation_sendmessage_cap()
  test_can_send_message_to_conversation_messageanyuser_cap()
  test_can_send_message_to_conversation_non_member()
  test_can_send_message_to_conversation_privacy_contacts_only()
  test_can_send_message_to_conversation_privacy_contacts_course()
  test_can_send_message_to_conversation_privacy_sitewide()
  test_can_send_message_to_conversation_when_blocked()
  test_get_user_privacy_messaging_preference()
  test_get_message_processor()
  test_update_processor_status()
  is_user_enabled()
  test_get_blocked_users()
  test_get_contacts_with_unread_message_count()
  test_get_contacts_with_unread_message_count_no_messages()
  test_get_non_contacts_with_unread_message_count()
  test_mark_message_as_read()
  test_mark_notification_as_read()
  test_get_conversation_between_users_no_conversation()
  test_count_conversation_members_no_existing_conversation()
  test_count_conversation_members_existing_conversation()
  test_add_members_to_individual_conversation()
  test_add_members_to_existing_conversation()
  test_add_members_to_no_existing_conversation()
  test_add_members_to_no_existing_user()
  test_add_members_to_current_conversation_member()
  test_add_members_for_multiple_users()
  test_add_members_for_multiple_not_valid_users()
  test_remove_members_from_individual_conversation()
  test_remove_members_from_existing_conversation()
  test_remove_members_from_no_existing_conversation()
  test_remove_members_for_no_existing_user()
  test_remove_members_for_multiple_users()
  test_remove_members_for_multiple_no_valid_users()
  test_count_conversation_members_empty_conversation()
  test_can_create_contact_request()
  test_create_contact_request()
  test_confirm_contact_request()
  test_decline_contact_request()
  test_get_contact_requests()
  test_get_contact_requests_blocked_sender()
  test_get_contact_requests_no_requests()
  test_get_contact_requests_with_limits()
  test_add_contact()
  test_remove_contact()
  test_block_user()
  test_unblock_user()
  test_mute_conversation()
  test_unmute_conversation()
  test_is_conversation_muted()
  test_is_contact()
  test_get_contact()
  test_is_blocked()
  test_does_contact_request_exist()
  test_get_received_contact_requests_count()
  test_get_received_contact_requests_count_blocked_sender()
  test_get_contact_requests_between_users()
  test_is_user_in_conversation()
  test_is_user_in_conversation_when_not()
  test_can_create_group_conversation()
  test_create_conversation_individual()
  test_create_conversation_group()
  test_create_conversation_invalid()
  test_create_conversation_individual_too_many_members()
  test_create_conversation_with_area()
  test_get_conversation_by_area()
  test_enable_conversation()
  test_disable_conversation()
  test_update_conversation_name()
  test_get_conversation_members()
  test_get_conversation_members_with_contact_requests()
  test_get_conversation_members_with_self_conversation()
  test_send_message_to_conversation_individual_conversation()
  test_send_message_to_conversation_group_conversation()
  test_send_message_to_conversation_linked_group_conversation()
  test_send_message_to_conversation_non_existent_conversation()
  test_send_message_to_conversation_non_member()
  test_send_message_to_conversation_blocked_user()
  test_get_conversation_with_muted_conversation()
  get_conversation_counts_test_cases()
  test_get_conversation_counts()
  test_count_contacts()
  test_get_unread_conversation_counts()
  test_delete_all_conversation_data()
  test_can_delete_message_for_all_users_teacher()
  test_can_delete_message_for_all_users_student()
  test_delete_message_for_all_users_group_conversation()
  test_delete_message_for_all_users_individual_conversation()
  test_get_conversation_messages_timefrom_higher_than_last_timecreated()
  create_delete_message_test_data()
  sort_contacts()


Class: api_test  - X-Ref

Test message API.

test_mark_all_read_for_user_touser()   X-Ref
No description

test_mark_all_read_for_user_touser_with_fromuser()   X-Ref
No description

test_mark_all_read_for_user_touser_with_type()   X-Ref
No description

test_count_blocked_users()   X-Ref
Test count_blocked_users.


test_message_search_users_messagingallusers_disabled()   X-Ref
Tests searching for users when site-wide messaging is disabled.

This test verifies that any contacts are returned, as well as any non-contacts whose profile we can view.
If checks this by placing some users in the same course, where default caps would permit a user to view another user's
profile.

test_message_search_users_messagingallusers_enabled()   X-Ref
Tests searching for users when site-wide messaging is enabled.

This test verifies that any contacts are returned, as well as any non-contacts,
provided the searching user can view their profile.

test_message_search_users_self_conversations()   X-Ref
Verify searching for users find themselves when they have self-conversations.


test_message_search_users_with_empty_result()   X-Ref
Verify searching for users works even if no matching users from either contacts, or non-contacts can be found.


test_message_search_users_limit_offset()   X-Ref
Test verifying that limits and offsets work for both the contacts and non-contacts return data.


test_message_search_users_with_cap()   X-Ref
Tests searching users as a user having the 'moodle/user:viewdetails' capability.


test_message_search_users_messaging_disabled()   X-Ref
Tests searching users with messaging disabled.


test_get_conversations_between_users()   X-Ref
Tests getting conversations between 2 users.


test_get_self_conversation()   X-Ref
Tests getting self-conversations.


test_search_messages()   X-Ref
Tests searching messages.


test_get_favourite_conversations()   X-Ref
Test verifying that favourited conversations can be retrieved.


test_get_favourite_conversations_limit_offset()   X-Ref
Tests retrieving favourite conversations with a limit and offset to ensure pagination works correctly.


test_get_favourite_conversations_with_deleted_user()   X-Ref
Tests retrieving favourite conversations when a conversation contains a deleted user.


test_set_favourite_conversation()   X-Ref
Test confirming that conversations can be marked as favourites.


test_set_favourite_conversation_nonexistent_conversation()   X-Ref
Test verifying that trying to mark a non-existent conversation as a favourite, results in an exception.


test_set_favourite_conversation_non_member()   X-Ref
Test verifying that a conversation cannot be marked as favourite unless the user is a member of that conversation.


test_unset_favourite_conversation()   X-Ref
Test confirming that those conversations marked as favourites can be unfavourited.


test_unset_favourite_conversation_not_favourite()   X-Ref
Test verifying that a valid conversation cannot be unset as a favourite if it's not marked as a favourite.


test_unset_favourite_conversation_non_existent_conversation()   X-Ref
Test verifying that a non-existent conversation cannot be unset as a favourite.


create_conversation_test_data()   X-Ref
Helper to seed the database with initial state.


test_get_conversations_no_restrictions()   X-Ref
Test verifying get_conversations when no limits, offsets, type filters or favourite restrictions are used.


test_get_conversations_message_format()   X-Ref
Test verifying that html format messages are supported, and that message_format_message_text() is being called appropriately.


test_get_conversations_some_muted()   X-Ref
Test verifying get_conversations identifies if a conversation is muted or not.


test_get_conversations_limit_offset()   X-Ref
Tests retrieving conversations with a limit and offset to ensure pagination works correctly.


test_get_conversations_type_filter()   X-Ref
Test verifying the type filtering behaviour of the


test_get_conversations_self_conversations()   X-Ref
Tests retrieving conversations when a 'self' conversation exists.


test_get_conversations_with_deleted_user()   X-Ref
Tests retrieving conversations when a conversation contains a deleted user.


test_get_conversations_deleted_messages()   X-Ref
Test confirming the behaviour of get_conversations() when users delete all messages.


test_get_conversations_favourite_conversations_single()   X-Ref
Test verifying the behaviour of get_conversations() when fetching favourite conversations with only a single
favourite.


test_get_conversations_favourite_conversations()   X-Ref
Test verifying the behaviour of get_conversations() when fetching favourite conversations.


test_get_conversations_user_in_group_and_individual_chat()   X-Ref
Test verifying get_conversations when there are users in a group and/or individual conversation. The reason this
test is performed is because we do not need as much data for group conversations (saving DB calls), so we want
to confirm this happens.


test_get_conversations_group_linked()   X-Ref
Test verifying that group linked conversations are returned and contain a subname matching the course name.


get_conversations_mixed_provider()   X-Ref
The data provider for get_conversations_mixed.

This provides sets of data to for testing.
return: array

test_create_conversation_duplicate_conversations()   X-Ref
Test that creation can't create the same conversation twice for 1:1 conversations.


test_get_conversations_mixed($usersdata, $contacts, $messagesdata, $expectations)   X-Ref
Test get_conversations with a mixture of messages.

param: array $usersdata The list of users to create for this test.
param: array $messagesdata The list of messages to create.
param: array $expectations The list of expected outcomes.

test_get_user_contacts()   X-Ref
Tests retrieving user contacts.


test_get_conversation_messages()   X-Ref
Tests retrieving conversation messages.


test_get_group_conversation_messages()   X-Ref
Tests retrieving group conversation messages.


test_get_conversation_messages_sorting()   X-Ref
Test verifying the sorting param for get_conversation_messages is respected().


test_get_conversation_messages_time_from_only()   X-Ref
Test retrieving conversation messages by providing a minimum timecreated value.


test_get_conversation_messages_time_to_only()   X-Ref
Test retrieving conversation messages by providing a maximum timecreated value.


test_get_conversation_messages_time_from_and_to()   X-Ref
Test retrieving conversation messages by providing a minimum and maximum timecreated value.


test_get_conversation_messages_limitfrom_only()   X-Ref
Test retrieving conversation messages by providing a limitfrom value.


test_get_conversation_messages_limitnum()   X-Ref
Test retrieving conversation messages by providing a limitnum value.


test_get_most_recent_conversation_message()   X-Ref
Tests retrieving most recent conversation message.


test_can_mark_all_messages_as_read()   X-Ref
Tests checking if a user can mark all messages as read.


test_can_delete_conversation()   X-Ref
Tests checking if a user can delete a conversation.


test_delete_conversation_by_id()   X-Ref
Tests deleting a conversation by conversation id.


test_count_unread_conversations()   X-Ref
Tests counting unread conversations.


test_count_unread_conversations_disabled()   X-Ref
Tests counting unread conversations where one conversation is disabled.


test_get_all_message_preferences()   X-Ref
Tests deleting a conversation.


test_can_send_message()   X-Ref
Tests the user can send a message.


test_can_send_message_without_sendmessage_cap()   X-Ref
Tests the user can't send a message without proper capability.


test_can_send_message_when_contact()   X-Ref
Tests the user can send a message when they are contact.


test_can_send_message_when_not_contact()   X-Ref
Tests the user can't send a message if they are not a contact and the user
has requested messages only from contacts.


test_can_send_message_when_blocked()   X-Ref
Tests the user can't send a message if they are blocked.


test_can_send_message_site_messaging_setting()   X-Ref
Tests the user can send a message when site-wide messaging setting is enabled,
even if they are not a contact and are not members of the same course.


test_can_send_message_with_messageanyuser_cap()   X-Ref
Tests the user with the messageanyuser capability can send a message.


test_can_send_message_even_if_blocked()   X-Ref
Tests the user when blocked will not be able to send messages if they are blocked.


test_can_send_message_even_if_blocked_with_message_any_user_cap()   X-Ref
Tests the user will be able to send a message even if they are blocked as the user
has the capability 'moodle/site:messageanyuser'.


test_can_send_message_even_if_blocked_with_read_all_message_cap()   X-Ref
Tests the user will be able to send a message even if they are blocked as the user
has the capability 'moodle/site:readallmessages'.


test_can_send_message_even_if_blocked_shared_course()   X-Ref
Tests the user can not always send a message if they are blocked just because they share a course.


test_can_send_message_even_if_blocked_shared_course_with_message_any_user_cap()   X-Ref
Tests the user can always send a message even if they are blocked because they share a course and
have the capability 'moodle/site:messageanyuser' at the course context.


test_can_send_message_to_conversation_basic()   X-Ref
Verify the expected behaviour of the can_send_message_to_conversation() method for authenticated users with default settings.


test_can_send_message_to_conversation_sendmessage_cap()   X-Ref
Verify the behaviour of can_send_message_to_conversation() for authenticated users without the sendmessage capability.


test_can_send_message_to_conversation_messageanyuser_cap()   X-Ref
Verify the behaviour of can_send_message_to_conversation() for authenticated users without the messageanyuser capability.


test_can_send_message_to_conversation_non_member()   X-Ref
Test verifying that users cannot send messages to conversations they are not a part of.


test_can_send_message_to_conversation_privacy_contacts_only()   X-Ref
Test verifying the behaviour of the can_send_message_to_conversation method when privacy is set to contacts only.


test_can_send_message_to_conversation_privacy_contacts_course()   X-Ref
Test verifying the behaviour of the can_send_message_to_conversation method when privacy is set to contacts / course members.


test_can_send_message_to_conversation_privacy_sitewide()   X-Ref
Test verifying the behaviour of the can_send_message_to_conversation method when privacy is set to any user.


test_can_send_message_to_conversation_when_blocked()   X-Ref
Test verifying the behaviour of the can_send_message_to_conversation method when a user is blocked.


test_get_user_privacy_messaging_preference()   X-Ref
Tests get_user_privacy_messaging_preference method.


test_get_message_processor()   X-Ref
No description

test_update_processor_status()   X-Ref
Test method update_processor_status.


is_user_enabled()   X-Ref
Test method is_user_enabled.


test_get_blocked_users()   X-Ref
Test returning blocked users.


test_get_contacts_with_unread_message_count()   X-Ref
Test returning contacts with unread message count.
MDL-69643


test_get_contacts_with_unread_message_count_no_messages()   X-Ref
Test returning contacts with unread message count when there are no messages.


test_get_non_contacts_with_unread_message_count()   X-Ref
Test returning non-contacts with unread message count.
MDL-69643


test_mark_message_as_read()   X-Ref
Test marking a message as read.


test_mark_notification_as_read()   X-Ref
Test marking a notification as read.


test_get_conversation_between_users_no_conversation()   X-Ref
Test a conversation is not returned if there is none.


test_count_conversation_members_no_existing_conversation()   X-Ref
Test count_conversation_members for non existing conversation.


test_count_conversation_members_existing_conversation()   X-Ref
Test count_conversation_members for existing conversation.


test_add_members_to_individual_conversation()   X-Ref
Test add_members_to_conversation for an individual conversation.


test_add_members_to_existing_conversation()   X-Ref
Test add_members_to_conversation for existing conversation.


test_add_members_to_no_existing_conversation()   X-Ref
Test add_members_to_conversation for non existing conversation.


test_add_members_to_no_existing_user()   X-Ref
Test add_member_to_conversation for non existing user.


test_add_members_to_current_conversation_member()   X-Ref
Test add_members_to_conversation for current conversation member.


test_add_members_for_multiple_users()   X-Ref
Test add_members_to_conversation for multiple users.


test_add_members_for_multiple_not_valid_users()   X-Ref
Test add_members_to_conversation for multiple users, included non existing and current conversation members


test_remove_members_from_individual_conversation()   X-Ref
Test remove_members_from_conversation for individual conversation.


test_remove_members_from_existing_conversation()   X-Ref
Test remove_members_from_conversation for existing conversation.


test_remove_members_from_no_existing_conversation()   X-Ref
Test remove_members_from_conversation for non existing conversation.


test_remove_members_for_no_existing_user()   X-Ref
Test remove_members_from_conversation for non existing user.


test_remove_members_for_multiple_users()   X-Ref
Test remove_members_from_conversation for multiple users.


test_remove_members_for_multiple_no_valid_users()   X-Ref
Test remove_members_from_conversation for multiple non valid users.


test_count_conversation_members_empty_conversation()   X-Ref
Test count_conversation_members for empty conversation.


test_can_create_contact_request()   X-Ref
Test can create a contact request.


test_create_contact_request()   X-Ref
Test creating a contact request.


test_confirm_contact_request()   X-Ref
Test confirming a contact request.


test_decline_contact_request()   X-Ref
Test declining a contact request.


test_get_contact_requests()   X-Ref
Test retrieving contact requests.


test_get_contact_requests_blocked_sender()   X-Ref
Test the get_contact_requests() function when the user has blocked the sender of the request.


test_get_contact_requests_no_requests()   X-Ref
Test getting contact requests when there are none.


test_get_contact_requests_with_limits()   X-Ref
Test getting contact requests with limits.


test_add_contact()   X-Ref
Test adding contacts.


test_remove_contact()   X-Ref
Test removing contacts.


test_block_user()   X-Ref
Test blocking users.


test_unblock_user()   X-Ref
Test unblocking users.


test_mute_conversation()   X-Ref
Test muting a conversation.


test_unmute_conversation()   X-Ref
Test unmuting a conversation.


test_is_conversation_muted()   X-Ref
Test if a conversation is muted.


test_is_contact()   X-Ref
Test is contact check.


test_get_contact()   X-Ref
Test get contact.


test_is_blocked()   X-Ref
Test is blocked checked.


test_does_contact_request_exist()   X-Ref
Test the contact request exist check.


test_get_received_contact_requests_count()   X-Ref
Test the get_received_contact_requests_count() function.


test_get_received_contact_requests_count_blocked_sender()   X-Ref
Test the get_received_contact_requests_count() function when the user has blocked the sender of the request.


test_get_contact_requests_between_users()   X-Ref
Test the get_contact_requests_between_users() function.


test_is_user_in_conversation()   X-Ref
Test the user in conversation check.


test_is_user_in_conversation_when_not()   X-Ref
Test the user in conversation check when they are not.


test_can_create_group_conversation()   X-Ref
Test can create a group conversation.


test_create_conversation_individual()   X-Ref
Test creating an individual conversation.


test_create_conversation_group()   X-Ref
Test creating a group conversation.


test_create_conversation_invalid()   X-Ref
Test creating an invalid conversation.


test_create_conversation_individual_too_many_members()   X-Ref
Test creating an individual conversation with too many members.


test_create_conversation_with_area()   X-Ref
Test create message conversation with area.


test_get_conversation_by_area()   X-Ref
Test get_conversation_by_area.


test_enable_conversation()   X-Ref
Test enable_conversation.


test_disable_conversation()   X-Ref
Test disable_conversation.


test_update_conversation_name()   X-Ref
Test update_conversation_name.


test_get_conversation_members()   X-Ref
Test returning members in a conversation with no contact requests.


test_get_conversation_members_with_contact_requests()   X-Ref
Test returning members in a conversation with contact requests.


test_get_conversation_members_with_self_conversation()   X-Ref
Test returning members of a self conversation.


test_send_message_to_conversation_individual_conversation()   X-Ref
Test verifying that messages can be sent to existing individual conversations.


test_send_message_to_conversation_group_conversation()   X-Ref
Test verifying that messages can be sent to existing group conversations.


test_send_message_to_conversation_linked_group_conversation()   X-Ref
Test verifying that messages can be sent to existing linked group conversations.


test_send_message_to_conversation_non_existent_conversation()   X-Ref
Test verifying that messages cannot be sent to conversations that don't exist.


test_send_message_to_conversation_non_member()   X-Ref
Test verifying that messages cannot be sent to conversations by users who are not members.


test_send_message_to_conversation_blocked_user()   X-Ref
Test verifying that messages cannot be sent to conversations by users who are not members.


test_get_conversation_with_muted_conversation()   X-Ref
Test the get_conversation() function with a muted conversation.


get_conversation_counts_test_cases()   X-Ref
Data provider for test_get_conversation_counts().


test_get_conversation_counts($conversationconfigs,$deletemessagesuser,$deletemessages,$arguments,$expectedcounts,$expectedunreadcounts,$deletedusers)   X-Ref
Test the get_conversation_counts() function.

param: array $conversationconfigs Conversations to create
param: int $deletemessagesuser The user who is deleting the messages
param: array $deletemessages The list of messages to delete (by index)
param: array $arguments Arguments for the count conversations function
param: array $expectedcounts the expected conversation counts
param: array $expectedunreadcounts the expected unread conversation counts
param: array $deletedusers the array of users to soft delete.

test_count_contacts()   X-Ref
Test the count_contacts() function.


test_get_unread_conversation_counts($conversationconfigs,$deletemessagesuser,$deletemessages,$arguments,$expectedcounts,$expectedunreadcounts,$deletedusers)   X-Ref
Test the get_unread_conversation_counts() function.

param: array $conversationconfigs Conversations to create
param: int $deletemessagesuser The user who is deleting the messages
param: array $deletemessages The list of messages to delete (by index)
param: array $arguments Arguments for the count conversations function
param: array $expectedcounts the expected conversation counts
param: array $expectedunreadcounts the expected unread conversation counts
param: array $deletedusers the list of users to soft-delete.

test_delete_all_conversation_data()   X-Ref
No description

test_can_delete_message_for_all_users_teacher()   X-Ref
Tests the user can delete message for all users as a teacher.


test_can_delete_message_for_all_users_student()   X-Ref
Tests the user can delete message for all users as a student.


test_delete_message_for_all_users_group_conversation()   X-Ref
Tests tdelete message for all users in group conversation.


test_delete_message_for_all_users_individual_conversation()   X-Ref
Tests delete message for all users in private conversation.


test_get_conversation_messages_timefrom_higher_than_last_timecreated()   X-Ref
Test retrieving conversation messages by providing a timefrom higher than last message timecreated. It should return no
messages but keep the return structure to not break when called from the ws.


create_delete_message_test_data()   X-Ref
Helper to seed the database with initial state with data.


sort_contacts($a, $b)   X-Ref
Comparison function for sorting contacts.

param: \stdClass $a
param: \stdClass $b
return: bool