Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

Data generators for acceptance testing.

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

Defines 1 class

behat_data_generators:: (4 methods):
  the_following_entities_exist()
  the_following_entity_exists()
  parse_entity_type()
  get_instance_for_component()


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_entity_exists($entitytype, TableNode $data)   X-Ref
Creates the specified 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.