[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/testing/generator/ -> data_generator.php (summary)

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: 1012 lines (37 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

testing_data_generator:: (24 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_tag()
  combine_defaults_and_record()
  enrol_user()
  role_assign()
  create_grade_category()
  create_grade_item()
  create_grade_outcome()


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.

param: string $component the component name, e.g. 'mod_forum' or 'core_question'.
return: component_generator_base or rather an instance of the appropriate subclass.

create_user($record=null, array $options=null)   X-Ref
Create a test user

param: array|stdClass $record
param: array $options
return: stdClass user record

create_category($record=null, array $options=null)   X-Ref
Create a test course category

param: array|stdClass $record
param: array $options
return: coursecat course category record

create_cohort($record=null, array $options=null)   X-Ref
Create test cohort.

param: array|stdClass $record
param: array $options
return: stdClass cohort record

create_course($record=null, array $options=null)   X-Ref
Create a test course

param: array|stdClass $record
param: array $options with keys:
return: stdClass course record

create_course_section($record = null, array $options = null)   X-Ref
Create course section if does not exist yet

param: array|stdClass $record must contain 'course' and 'section' attributes
param: array|null $options
return: stdClass

create_block($blockname, $record=null, array $options=null)   X-Ref
Create a test block

param: string $blockname
param: array|stdClass $record
param: array $options
return: stdClass block instance record

create_module($modulename, $record=null, array $options=null)   X-Ref
Create a test module

param: string $modulename
param: array|stdClass $record
param: array $options
return: stdClass activity record

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.
param: array|stdClass $record
return: stdClass group record

create_group_member($record)   X-Ref
Create a test group member

param: array|stdClass $record
return: boolean

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.
param: array|stdClass $record
return: stdClass grouping record

create_grouping_group($record)   X-Ref
Create a test grouping group

param: array|stdClass $record
return: boolean

create_repository($type, $record=null, array $options = null)   X-Ref
Create an instance of a repository.

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
return: stdClass repository instance record

create_repository_type($type, $record=null, array $options = null)   X-Ref
Create an instance of a repository.

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
return: repository_type object

create_scale($record=null, array $options=null)   X-Ref
Create a test scale

param: array|stdClass $record
param: array $options
return: stdClass block instance record

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.

param: array|stdClass $record
return: int The new role id

create_tag($record = null)   X-Ref
Create a tag.

param: array|stdClass $record
return: stdClass the tag 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.

param: array $defaults the default value for each field with
param: array|stdClass $record
return: array updated $record.

enrol_user($userid, $courseid, $roleid = 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!!!

param: int $userid
param: int $courseid
param: int $roleid optional role id, 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
return: bool success

role_assign($roleid, $userid, $contextid = false)   X-Ref
Assigns the specified role to a user in the context.

param: int $roleid
param: int $userid
param: int $contextid Defaults to the system context
return: int new/existing id of the assignment

create_grade_category($record = null)   X-Ref
Create a grade_category.

param: array|stdClass $record
return: stdClass the grade category record

create_grade_item($record = null)   X-Ref
Create a grade_item.

param: array|stdClass $record
return: stdClass the grade item record

create_grade_outcome($record = null)   X-Ref
Create a grade_outcome.

param: array|stdClass $record
return: stdClass the grade outcome record



Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1