Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
Data generator.
Copyright: | 2012 Petr Skoda {@link http://skodak.org} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1524 lines (57 kb) |
Included or required: | 1 time |
Referenced: | 0 times |
Includes or requires: | 0 files |
testing_data_generator:: (0 methods):
aptent:: (35 methods):
reset()
get_plugin_generator()
create_user()
create_category()
create_cohort()
create_course()
create_course_section()
create_block()
create_module()
create_group()
create_group_member()
create_grouping()
create_grouping_group()
create_repository()
create_repository_type()
create_scale()
create_role()
create_role_capability()
create_tag()
combine_defaults_and_record()
enrol_user()
role_assign()
create_grade_category()
create_grade_grade()
create_grade_item()
create_grade_outcome()
create_lti_tool()
create_event()
create_custom_field_category()
create_custom_field()
create_custom_profile_field_category()
create_custom_profile_field()
create_and_enrol()
create_user_course_lastaccess()
get_default_plugin_generator()
Class: testing_data_generator - X-Ref
Data generator class for unit tests and other tools that need to create fake test sites.reset() X-Ref |
To be called from data reset code only, do not use in tests. return: void |
get_plugin_generator($component) X-Ref |
Return generator for given plugin or component. return: component_generator_base or rather an instance of the appropriate subclass. param: string $component the component name, e.g. 'mod_forum' or 'core_question'. |
create_user($record=null, array $options=null) X-Ref |
Create a test user return: stdClass user record param: array|stdClass $record param: array $options |
create_category($record=null, array $options=null) X-Ref |
Create a test course category return: core_course_category course category record param: array|stdClass $record param: array $options |
create_cohort($record=null, array $options=null) X-Ref |
Create test cohort. return: stdClass cohort record param: array|stdClass $record param: array $options |
create_course($record=null, array $options=null) X-Ref |
Create a test course return: stdClass course record param: array|stdClass $record param: array $options with keys: |
create_course_section($record = null, array $options = null) X-Ref |
Create course section if does not exist yet return: stdClass param: array|stdClass $record must contain 'course' and 'section' attributes param: array|null $options |
create_block($blockname, $record=null, array $options=array() X-Ref |
Create a test block. The $record passed in becomes the basis for the new row added to the block_instances table. You only need to supply the values of interest. Any missing values have sensible defaults filled in, and ->blockname will be set based on $blockname. The $options array provides additional data, not directly related to what will be inserted in the block_instance table, which may affect the block that is created. The meanings of any data passed here depends on the particular type of block being created. return: stdClass new block_instance record. param: string $blockname the type of block to create. E.g. 'html'. param: array|stdClass $record forms the basis for the entry to be inserted in the block_instances table. param: array $options further, block-specific options to control how the block is created. |
create_module($modulename, $record=null, array $options=null) X-Ref |
Create a test activity module. The $record should contain the same data that you would call from ->get_data() when the mod_[type]_mod_form is submitted, except that you only need to supply values of interest. The only required value is 'course'. Any missing values will have a sensible default supplied. The $options array provides additional data, not directly related to what would come back from the module edit settings form, which may affect the activity that is created. The meanings of any data passed here depends on the particular type of activity being created. return: stdClass activity record new new record that was just inserted in the table param: string $modulename the type of activity to create. E.g. 'forum' or 'quiz'. param: array|stdClass $record data, as if from the module edit settings form. param: array $options additional data that may affect how the module is created. |
create_group($record) X-Ref |
Create a test group for the specified course $record should be either an array or a stdClass containing infomation about the group to create. At the very least it needs to contain courseid. Default values are added for name, description, and descriptionformat if they are not present. This function calls groups_create_group() to create the group within the database. return: stdClass group record param: array|stdClass $record |
create_group_member($record) X-Ref |
Create a test group member return: boolean param: array|stdClass $record |
create_grouping($record) X-Ref |
Create a test grouping for the specified course $record should be either an array or a stdClass containing infomation about the grouping to create. At the very least it needs to contain courseid. Default values are added for name, description, and descriptionformat if they are not present. This function calls groups_create_grouping() to create the grouping within the database. return: stdClass grouping record param: array|stdClass $record |
create_grouping_group($record) X-Ref |
Create a test grouping group return: boolean param: array|stdClass $record |
create_repository($type, $record=null, array $options = null) X-Ref |
Create an instance of a repository. return: stdClass repository instance record param: string type of repository to create an instance for. param: array|stdClass $record data to use to up set the instance. param: array $options options |
create_repository_type($type, $record=null, array $options = null) X-Ref |
Create an instance of a repository. return: repository_type object param: string type of repository to create an instance for. param: array|stdClass $record data to use to up set the instance. param: array $options options |
create_scale($record=null, array $options=null) X-Ref |
Create a test scale return: stdClass block instance record param: array|stdClass $record param: array $options |
create_role($record=null) X-Ref |
Creates a new role in the system. You can fill $record with the role 'name', 'shortname', 'description' and 'archetype'. If an archetype is specified it's capabilities, context where the role can be assigned and all other properties are copied from the archetype; if no archetype is specified it will create an empty role. return: int The new role id param: array|stdClass $record |
create_role_capability(int $roleid, array $rolecapabilities, context $context = null) X-Ref |
Set role capabilities for the specified role. param: int $roleid The Role to set capabilities for param: array $rolecapabilities The list of capability =>permission to set for this role param: null|context $context The context to apply this capability to |
create_tag($record = null) X-Ref |
Create a tag. return: stdClass the tag record param: array|stdClass $record |
combine_defaults_and_record(array $defaults, $record) X-Ref |
Helper method which combines $defaults with the values specified in $record. If $record is an object, it is converted to an array. Then, for each key that is in $defaults, but not in $record, the value from $defaults is copied. return: array updated $record. param: array $defaults the default value for each field with param: array|stdClass $record |
enrol_user($userid, $courseid, $roleidorshortname = null, $enrol = 'manual',$timestart = 0, $timeend = 0, $status = null) X-Ref |
Simplified enrolment of user to course using default options. It is strongly recommended to use only this method for 'manual' and 'self' plugins only!!! return: bool success param: int $userid param: int $courseid param: int|string $roleidorshortname optional role id or role shortname, use only with manual plugin param: string $enrol name of enrol plugin, param: int $timestart (optional) 0 means unknown param: int $timeend (optional) 0 means forever param: int $status (optional) default to ENROL_USER_ACTIVE for new enrolments |
role_assign($roleid, $userid, $contextid = false) X-Ref |
Assigns the specified role to a user in the context. return: int new/existing id of the assignment param: int $roleid param: int $userid param: int $contextid Defaults to the system context |
create_grade_category($record = null) X-Ref |
Create a grade_category. return: stdClass the grade category record param: array|stdClass $record |
create_grade_grade(?array $record = null) X-Ref |
Create a grade_grade. return: grade_grade the grade record param: array $record |
create_grade_item($record = null) X-Ref |
Create a grade_item. return: stdClass the grade item record param: array|stdClass $record |
create_grade_outcome($record = null) X-Ref |
Create a grade_outcome. return: stdClass the grade outcome record param: array|stdClass $record |
create_lti_tool($data = array() X-Ref |
Helper function used to create an LTI tool. return: stdClass the tool param: array $data |
create_event($data = []) X-Ref |
Helper function used to create an event. return: stdClass param: array $data |
create_custom_field_category($data) X-Ref |
Create a new course custom field category with the given name. return: \core_customfield\category_controller The created category param: array $data Array with data['name'] of category |
create_custom_field($data) X-Ref |
Create a new custom field return: \core_customfield\field_controller The created field param: array $data Array with 'name', 'shortname' and 'type' of the field |
create_custom_profile_field_category(array $data) X-Ref |
Create a new category for custom profile fields. return: \stdClass New category object param: array $data Array with 'name' and optionally 'sortorder' |
create_custom_profile_field(array $data) X-Ref |
Creates a new custom profile field. Optional fields are: categoryid (or use 'category' to specify by name). If you don't specify either, it will add the field to a 'Testing' category, which will be created for you if necessary. sortorder (if you don't specify this, it will pick the next one in the category). all the other database fields (if you don't specify this, it will pick sensible defaults based on the data type). return: \stdClass Database object from the user_info_field table param: array $data Array with 'datatype', 'shortname', and 'name' |
create_and_enrol($course, $role = 'student', $userparams = null, $enrol = 'manual',$timestart = 0, $timeend = 0, $status = null) X-Ref |
Create a new user, and enrol them in the specified course as the supplied role. return: \stdClass The created user param: \stdClass $course The course to enrol in param: string $role The role to give within the course param: \stdClass $userparams User parameters |
create_user_course_lastaccess(\stdClass $user, \stdClass $course, int $timestamp) X-Ref |
Create a new last access record for a given user in a course. return: \stdClass The user_lastaccess record param: \stdClass $user The user param: \stdClass $course The course the user accessed param: int $timestamp The timestamp for when the user last accessed the course |
get_default_plugin_generator(string $component, ?string $classname = null) X-Ref |
Gets a default generator for a given component. return: component_generator_base The generator. param: string $component The component name, e.g. 'mod_forum' or 'core_question'. param: string $classname The name of the class missing from the generators file. |