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]

Data generators for acceptance testing.

Copyright: 2012 David MonllaĆ³
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 248 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/behat/behat_base.php

Defines 1 class


Class: behat_data_generators  - X-Ref

Class to set up quickly a Given environment.

The entry point is the Behat steps:
the following "entity types" exist:
| test | data |

Entity type will either look like "users" or "activities" for core entities, or
"mod_forum > subscription" or "core_message > message" for entities belonging
to components.

Generally, you only need to specify properties relevant to your test,
and everything else gets set to sensible defaults.

The actual generation of entities is done by {@link behat_generator_base}.
There is one subclass for each component, e.g. {@link behat_core_generator}
or {@link behat_mod_quiz_generator}. To see the types of entity
that can be created for each component, look at the arrays returned
by the get_creatable_entities() method in each class.

the_following_entities_exist($entitytype, TableNode $data)   X-Ref
Creates the specified elements.

See the class comment for an overview.

param: string    $entitytype The name of the type entity to add
param: TableNode $data

the_following_repeated_entities_exist(string $entitytype, int $count, TableNode $data)   X-Ref
Create multiple entities of one entity type.

param: string $entitytype The name of the type entity to add
param: int $count
param: TableNode $data

the_following_entity_exists($entitytype, TableNode $data)   X-Ref
Creates the specified (singular) element.

See the class comment for an overview.

param: string    $entitytype The name of the type entity to add
param: TableNode $data

parse_entity_type(string $entitytype)   X-Ref
Parse a full entity type like 'users' or 'mod_forum > subscription'.

E.g. parsing 'course' gives ['core', 'course'] and
parsing 'core_message > message' gives ['core_message', 'message'].

param: string $entitytype the entity type
return: string[] with two elements, component and entity type.

get_instance_for_component(string $component)   X-Ref
Get an instance of the appropriate subclass of this class for a given component.

param: string $component The name of the component to generate entities for.
return: behat_generator_base the subclass of this class for the requested component.

get_all_entities()   X-Ref
Get all entities that can be created in all components using the_following_entities_exist()

return: array

get_entity(string $entitytype)   X-Ref
Get the required fields for a specific creatable entity.

param: string $entitytype
return: mixed