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: behat_core_generator  - X-Ref

Behat data generator class for core entities.

get_creatable_entities()   X-Ref
No description

get_gradeitem_id(string $name)   X-Ref
Get the grade item id using a name.

param: string $name
return: int The grade item id

preprocess_course($data)   X-Ref
Remove any empty custom fields, to avoid errors when creating the course.

param: array $data
return: array

preprocess_user($data)   X-Ref
If password is not set it uses the username.

param: array $data
return: array

preprocess_cohort($data)   X-Ref
If contextlevel and reference are specified for cohort, transform them to the contextid.

param: array $data
return: array

preprocess_grade_item($data)   X-Ref
Preprocesses the creation of a grade item. Converts gradetype text to a number.

param: array $data
return: array

process_activity($data)   X-Ref
Adapter to modules generator.

param: array $data
return: void

process_block_instance($data)   X-Ref
Add a block to a page.

param: array $data should mostly match the fields of the block_instances table.

process_customlang($data)   X-Ref
Creates language customisation.

param: array $data
return: void

process_langpack($data)   X-Ref
Imports a langpack.

param: array $data

process_enrol_user($data)   X-Ref
Adapter to enrol_user() data generator.

param: array $data
return: void

process_permission_override($data)   X-Ref
Allows/denies a capability at the specified context

param: array $data
return: void

process_system_role_assign($data)   X-Ref
Assigns a role to a user at system context

Used by "system role assigns" can be deleted when
system role assign will be deprecated in favour of
"role assigns"

param: array $data
return: void

process_role_assign($data)   X-Ref
Assigns a role to a user at the specified context

param: array $data
return: void

process_role($data)   X-Ref
Creates a role.

param: array $data
return: void

process_role_capability($data)   X-Ref
Assign capabilities to a role.

param: array $data

process_cohort_member($data)   X-Ref
Adds members to cohorts

param: array $data
return: void

process_question_category($data)   X-Ref
Create a question category.

param: array $data the row of data from the behat script.

process_question($data)   X-Ref
Create a question.

Creating questions relies on the question/type/.../tests/helper.php mechanism.
We start with test_question_maker::get_question_form_data($data['qtype'], $data['template'])
and then overlay the values from any other fields of $data that are set.

There is a special case that allows you to set qtype to 'missingtype'.
This creates an example of broken question, such as you might get if you
install a question type, create some questions of that type, and then
uninstall the question type (which is prevented through the UI but can
still happen). This special lets tests verify that these questions are
handled OK.

param: array $data the row of data from the behat script.

process_message_contacts($data)   X-Ref
Adds user to contacts

param: array $data
return: void

process_private_messages(array $data)   X-Ref
Send a new message from user to contact in a private conversation

param: array $data
return: void

process_group_messages(array $data)   X-Ref
Send a new message from user to a group conversation

param: array $data
return: void

process_favourite_conversations(array $data)   X-Ref
Mark a private conversation as favourite for user

param: array $data
return: void

process_mute_group_conversations(array $data)   X-Ref
Mute an existing group conversation for user

param: array $data
return: void

process_mute_private_conversations(array $data)   X-Ref
Mute a private conversation for user

param: array $data
return: void

preprocess_analytics_model($data)   X-Ref
Transform indicators string into array.

param: array $data
return: array

process_analytics_model($data)   X-Ref
Creates an analytics model

param: target $data
return: void

process_user_preferences(array $data)   X-Ref
Set a preference value for user

param: array $data
return: void

process_contentbank_content(array $data)   X-Ref
Create content in the given context's content bank.

param: array $data
return: void

process_user_private_files(array $data)   X-Ref
Create content in the given user's private files.

param: array $data
return: void

process_badge_external_backpack(array $data)   X-Ref
Create a exetrnal backpack.

param: array $data

process_setup_backpack_connected(array $data)   X-Ref
Setup a backpack connected for user.

param: array $data

process_notification(array $data)   X-Ref
Creates notifications to specific user.

param: array $data
return: void

process_last_access_times(array $data)   X-Ref
Creates user last access data within given courses.

param: array $data
return: void