Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
behat_config_util Class Reference

Behat configuration manager. More...

Public Member Functions

 clean_path ($path)
 Cleans the path returned by get_components_with_tests() to standarize it.
 
 filtered_features_with_tags ($features='', $tags='')
 Search feature files for set of tags.
 
 get_behat_config_for_profile ($profile, $values)
 Parse $CFG->behat_config and return the array with required config structure for behat.yml.
 
 get_clean_feature_key_and_path ($featurepath)
 Return feature key for featurepath.
 
 get_components_contexts ($component='')
 Gets the list of Moodle behat contexts.
 
 get_components_features ($tags='')
 Return list of features.
 
 get_config_file_contents ($features='', $contexts='', $tags='', $parallelruns=0, $currentrun=0)
 Behat config file specifing the main context class, the required Behat extensions and Moodle test wwwroot.
 
 get_current_run ()
 Return current run.
 
 get_number_of_parallel_run ()
 Return parallel runs.
 
 get_theme_config ($themename)
 Return the theme config for a given theme name.
 
 merge_behat_config ($config)
 Merges $CFG->behat_config with the one passed.
 
 merge_behat_profiles ($config)
 Merges $CFG->behat_profiles with the one passed.
 
 merge_config ($config, $localconfig)
 Overrides default config with local config values.
 
 profile_guided_allocate ($features, $nbuckets, $instance)
 Attempt to split feature list into fairish buckets using timing information, if available.
 
 set_parallel_run ($parallelruns, $currentrun)
 Set parallel run to be used for generating config.
 
 set_tag_for_feature_filter ($tags)
 Set the value for tags, so features which are returned will be using filtered by this.
 
 set_theme_suite_to_include_core_features ($themetoset)
 Set value for theme suite to include all core features.
 

Static Public Member Functions

static get_behat_tests_path ()
 The relative path where components stores their behat tests.
 
static get_behat_theme_selector_override_classname ($themename, $selectortype, $includeclass=false)
 Return context name of behat_theme selector to use.
 

Public Attributes

string const ALL_THEMES_TO_RUN = 'ALL'
 used to specify if behat should be initialised with all themes.
 

Protected Member Functions

 build_config ($parallelruns=0, $currentrun=0)
 Build config for behat.yml.
 
 fix_legacy_profile_data (string $profilename, array $data)
 Check for and attempt to fix legacy profile data.
 
 get_behat_contexts_for_theme ($theme)
 Return list of behat contexts for theme and update $this->stepdefinitions list.
 
 get_behat_features_for_theme ($theme)
 Return list of blacklisted behat features for theme and features defined by theme only.
 
 get_behat_profile ($profile, $values)
 Parse $CFG->behat_profile and return the array with required config structure for behat.yml.
 
 get_behat_suites ($parallelruns=0, $currentrun=0)
 Return list of behat suites.
 
 get_blacklisted_tests_for_theme ($theme, $testtype)
 Return blacklisted contexts or features for a theme, as defined in blacklist.json.
 
 get_components_with_tests ()
 List of components which contain behat context or features.
 
 get_default_theme ()
 Return name of default theme.
 
 get_features_for_the_run ($features, $parallelruns, $currentrun)
 Divide features between the runs and return list.
 
 get_list_of_themes ()
 Return list of themes which can be set in moodle.
 
 get_mobile_version_tags ($verbose=true)
 Gets version tags to use for the mobile app.
 
 get_test_directories_overridden_for_theme ($theme, $testtype)
 Returns all the directories having overridden tests.
 
 get_tests_for_theme ($theme, $testtype)
 Return list of features and step definitions in theme.
 
 get_theme_test_directory ($themename)
 Return theme directory.
 
 remove_blacklisted_features_from_list ($features, $blacklist)
 Remove list of blacklisted features from the feature list.
 
 sort_component_contexts (array $contexts)
 Sort the list of components contexts.
 

Detailed Description

Behat configuration manager.

Creates/updates Behat config files getting tests and steps from Moodle codebase

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ build_config()

behat_config_util::build_config ( $parallelruns = 0,
$currentrun = 0 )
protected

Build config for behat.yml.

Parameters
int$parallelrunshow many parallel runs feature needs to be divided.
int$currentruncurrent run for which features should be returned.
Return values
array

◆ clean_path()

behat_config_util::clean_path ( $path)
final

Cleans the path returned by get_components_with_tests() to standarize it.

See also
tests_finder\get_all_directories_with_tests() it returns the path including /tests/
Parameters
string$path
Return values
stringThe string without the last /tests part

◆ filtered_features_with_tags()

behat_config_util::filtered_features_with_tags ( $features = '',
$tags = '' )

Search feature files for set of tags.

Parameters
array$featuresset of feature files.
string$tagslist of tags (currently support && only.)
Return values
arrayfiltered list of feature files with tags.

◆ fix_legacy_profile_data()

behat_config_util::fix_legacy_profile_data ( string $profilename,
array $data )
protected

Check for and attempt to fix legacy profile data.

The Mink Driver used for W3C no longer uses the selenium2 naming but otherwise is backwards compatibly.

Emit a warning that users should update their configuration.

Parameters
string$profilenameThe name of this profile
array$dataThe profile data for this profile
Return values
arrayTh eamended profile data

◆ get_behat_config_for_profile()

behat_config_util::get_behat_config_for_profile ( $profile,
$values )

Parse $CFG->behat_config and return the array with required config structure for behat.yml.

Parameters
string$profileprofile name
array$valuesvalues for profile
Return values
array

◆ get_behat_contexts_for_theme()

behat_config_util::get_behat_contexts_for_theme ( $theme)
protected

Return list of behat contexts for theme and update $this->stepdefinitions list.

Parameters
string$themetheme name.
Return values
Listof contexts

◆ get_behat_features_for_theme()

behat_config_util::get_behat_features_for_theme ( $theme)
protected

Return list of blacklisted behat features for theme and features defined by theme only.

Parameters
string$themetheme name.
Return values
array($blacklistfeatures, $blacklisttags, $features)

◆ get_behat_profile()

behat_config_util::get_behat_profile ( $profile,
$values )
protected

Parse $CFG->behat_profile and return the array with required config structure for behat.yml.

$CFG->behat_profiles = array( 'profile' = array( 'browser' => 'firefox', 'tags' => '@javascript', 'wd_host' => 'http://127.0.0.1:4444/wd/hub', 'capabilities' => array( 'platform' => 'Linux', 'version' => 44 ) ) );

Parameters
string$profileprofile name
array$valuesvalues for profile.
Return values
array

◆ get_behat_suites()

behat_config_util::get_behat_suites ( $parallelruns = 0,
$currentrun = 0 )
protected

Return list of behat suites.

Multiple suites are returned if theme overrides default step definitions/features.

Parameters
int$parallelrunsnumber of parallel runs
int$currentruncurrent run.
Return values
arraylist of suites.

◆ get_behat_tests_path()

static behat_config_util::get_behat_tests_path ( )
staticfinal

The relative path where components stores their behat tests.

Return values
string

◆ get_behat_theme_selector_override_classname()

static behat_config_util::get_behat_theme_selector_override_classname ( $themename,
$selectortype,
$includeclass = false )
staticfinal

Return context name of behat_theme selector to use.

Parameters
string$themenamename of the theme.
string$selectortypeThe type of selector (partial or exact at this stage)
bool$includeclassif class should be included.
Return values
string

◆ get_blacklisted_tests_for_theme()

behat_config_util::get_blacklisted_tests_for_theme ( $theme,
$testtype )
protected

Return blacklisted contexts or features for a theme, as defined in blacklist.json.

Parameters
string$themethemename
string$testtypetest type (contexts|features)
Return values
arraylist of blacklisted contexts or features

◆ get_clean_feature_key_and_path()

behat_config_util::get_clean_feature_key_and_path ( $featurepath)

Return feature key for featurepath.

Parameters
string$featurepath
Return values
arraykey and featurepath.

◆ get_components_contexts()

behat_config_util::get_components_contexts ( $component = '')

Gets the list of Moodle behat contexts.

Class name as a key and the filepath as value

Externalized from update_config_file() to use it from the steps definitions web interface

Parameters
string$componentRestricts the obtained steps definitions to the specified component
Return values
array

◆ get_components_features()

behat_config_util::get_components_features ( $tags = '')

Return list of features.

Parameters
string$tagstags.
Return values
array

◆ get_components_with_tests()

behat_config_util::get_components_with_tests ( )
protected

List of components which contain behat context or features.

Return values
array

◆ get_config_file_contents()

behat_config_util::get_config_file_contents ( $features = '',
$contexts = '',
$tags = '',
$parallelruns = 0,
$currentrun = 0 )

Behat config file specifing the main context class, the required Behat extensions and Moodle test wwwroot.

Parameters
array$featuresThe system feature files
array$contextsThe system steps definitions
string$tagsfilter features with specified tags.
int$parallelrunsnumber of parallel runs.
int$currentruncurrent run for which config file is needed.
Return values
string

◆ get_current_run()

behat_config_util::get_current_run ( )

Return current run.

Return values
intcurrent run.

◆ get_default_theme()

behat_config_util::get_default_theme ( )
protected

Return name of default theme.

Return values
string

◆ get_features_for_the_run()

behat_config_util::get_features_for_the_run ( $features,
$parallelruns,
$currentrun )
protected

Divide features between the runs and return list.

Parameters
array$featureslist of features to be divided.
int$parallelrunshow many parallel runs feature needs to be divided.
int$currentruncurrent run for which features should be returned.
Return values
array

◆ get_list_of_themes()

behat_config_util::get_list_of_themes ( )
protected

Return list of themes which can be set in moodle.

Return values
arraylist of themes with tests.

◆ get_mobile_version_tags()

behat_config_util::get_mobile_version_tags ( $verbose = true)
protected

Gets version tags to use for the mobile app.

This is based on the current mobile app version (from its package.json) and all known mobile app versions (based on the list appversions.json in the lib/behat directory).

Parameters
bool$verboseIf true, outputs information about installed app version
Return values
stringList of tags or '' if not supporting mobile

◆ get_number_of_parallel_run()

behat_config_util::get_number_of_parallel_run ( )

Return parallel runs.

Return values
intnumber of parallel runs.

◆ get_test_directories_overridden_for_theme()

behat_config_util::get_test_directories_overridden_for_theme ( $theme,
$testtype )
protected

Returns all the directories having overridden tests.

Parameters
string$themename of theme
string$testtypeThe kind of test we are looking for
Return values
arrayall directories having tests

◆ get_tests_for_theme()

behat_config_util::get_tests_for_theme ( $theme,
$testtype )
protected

Return list of features and step definitions in theme.

Parameters
string$themetheme name
string$testtypetest type, either features or contexts
Return values
arraylist of contexts $contexts or $features

◆ get_theme_config()

behat_config_util::get_theme_config ( $themename)

Return the theme config for a given theme name.

This is done so we can mock it in PHPUnit.

Parameters
string$themenamename of theme
Return values
theme_config

◆ get_theme_test_directory()

behat_config_util::get_theme_test_directory ( $themename)
protected

Return theme directory.

Parameters
string$themenamename of theme
Return values
stringtheme directory

◆ merge_behat_config()

behat_config_util::merge_behat_config ( $config)

Merges $CFG->behat_config with the one passed.

Parameters
array$configexisting config.
Return values
arraymerged config with $CFG->behat_config

◆ merge_behat_profiles()

behat_config_util::merge_behat_profiles ( $config)

Merges $CFG->behat_profiles with the one passed.

Parameters
array$configexisting config.
Return values
arraymerged config with $CFG->behat_profiles

◆ merge_config()

behat_config_util::merge_config ( $config,
$localconfig )

Overrides default config with local config values.

array_merge does not merge completely the array's values

Parameters
mixed$configThe node of the default config
mixed$localconfigThe node of the local config
Return values
mixedThe merge result

◆ profile_guided_allocate()

behat_config_util::profile_guided_allocate ( $features,
$nbuckets,
$instance )

Attempt to split feature list into fairish buckets using timing information, if available.

Simply add each one to lightest buckets until all files allocated. PGA = Profile Guided Allocation. I made it up just now. CAUTION: workers must agree on allocation, do not be random anywhere!

Parameters
array$featuresBehat feature files array
int$nbucketsNumber of buckets to divide into
int$instanceIndex number of this instance
Return values
array|boolFeature files array, sorted into allocations

◆ remove_blacklisted_features_from_list()

behat_config_util::remove_blacklisted_features_from_list ( $features,
$blacklist )
protected

Remove list of blacklisted features from the feature list.

Parameters
array$featureslist of original features.
array | string$blacklistlist of features which needs to be removed.
Return values
arrayfeatures - blacklisted features.

◆ set_parallel_run()

behat_config_util::set_parallel_run ( $parallelruns,
$currentrun )

Set parallel run to be used for generating config.

Parameters
int$parallelrunsnumber of parallel runs.
int$currentruncurrent run

◆ set_tag_for_feature_filter()

behat_config_util::set_tag_for_feature_filter ( $tags)

Set the value for tags, so features which are returned will be using filtered by this.

Parameters
string$tags

◆ set_theme_suite_to_include_core_features()

behat_config_util::set_theme_suite_to_include_core_features ( $themetoset)

Set value for theme suite to include all core features.

This should be used if your want all core features to be run with theme.

Parameters
bool$themetoset

◆ sort_component_contexts()

behat_config_util::sort_component_contexts ( array $contexts)
protected

Sort the list of components contexts.

This ensures that contexts are sorted consistently. Core hooks defined in the behat_hooks class must be defined first.

Parameters
array$contexts
Return values
arrayThe sorted context list

The documentation for this class was generated from the following file: