Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

Utils for behat-related stuff

Copyright: 2012 David MonllaĆ³
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 512 lines (18 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 7 files
 lib/behat/classes/behat_command.php
 lib/behat/classes/behat_config_manager.php
 lib/csslib.php
 lib/filelib.php
 lib/clilib.php
 lib/testing/classes/util.php
 lib/behat/lib.php

Defines 1 class


Class: behat_util  - X-Ref

Init/reset utilities for Behat database and dataroot

install_site()   X-Ref
Installs a site using $CFG->dataroot and $CFG->prefix

return: void

build_themes($mtraceprogress = false)   X-Ref
Build theme CSS.


drop_site()   X-Ref
Drops dataroot and remove test database tables

return: void

drop_dataroot()   X-Ref
Delete files and directories under dataroot.


check_server_status()   X-Ref
Checks if $CFG->behat_wwwroot is available and using same versions for cli and web.

return: void

test_environment_problem()   X-Ref
Checks whether the test database and dataroot is ready
Stops execution if something went wrong

return: void

start_test_mode($themesuitewithallfeatures = false, $tags = '', $parallelruns = 0, $run = 0)   X-Ref
Enables test mode

It uses CFG->behat_dataroot

Starts the test mode checking the composer installation and
the test environment and updating the available
features and steps definitions.

Stores a file in dataroot/behat to allow Moodle to switch
to the test environment when using cli-server.
param: bool $themesuitewithallfeatures List themes to include core features.
param: string $tags comma separated tag, which will be given preference while distributing features in parallel run.
param: int $parallelruns number of parallel runs.
param: int $run current run.
return: void

get_behat_status()   X-Ref
Returns the status of the behat test environment

return: int Error code

stop_test_mode()   X-Ref
Disables test mode

return: void

is_test_mode_enabled()   X-Ref
Checks whether test environment is enabled or disabled

To check is the current script is running in the test
environment

return: bool

get_test_file_path()   X-Ref
Returns the path to the file which specifies if test environment is enabled

return: string

remove_added_config()   X-Ref
Removes config settings that were added to the main $CFG config within the Behat CLI
run.

Database storage is already handled by reset_database and existing config values will
be reset automatically by initialise_cfg(), so we only need to remove added ones.

reset_all_data()   X-Ref
Reset contents of all database tables to initial values, reset caches, etc.


restore_saved_themes()   X-Ref
Restore theme CSS stored during behat setup.


pause(Session $session, string $message)   X-Ref
Pause execution immediately.

param: Session $session
param: string $message The message to show when pausing.

get_site_info()   X-Ref
Gets a text-based site version description.

return: string The site info