Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
test

Directories

directory extension
  
 
directory features
  
 

Classes

class  base_testcase
 Base test case class. More...
 
class  behat_accessibility
 Steps definitions to assist with accessibility testing. More...
 
class  behat_action_menu
 Steps definitions to open and close action menus. More...
 
class  behat_base
 Base class of all steps definitions. More...
 
class  behat_command
 Behat command related utils. More...
 
class  behat_component_named_replacement
 A class for recording the definition of Mink replacements. More...
 
class  behat_component_named_selector
 Class representing a named selector that can be used in Behat tests. More...
 
class  behat_config_manager
 Behat configuration manager. More...
 
class  behat_context_helper
 Helper to get behat contexts. More...
 
class  behat_data_generators
 Data generators for acceptance testing. More...
 
class  behat_deprecated
 Steps definitions that are now deprecated and will be removed in the next releases. More...
 
class  behat_deprecated_base
 Base class for steps definitions classes that contain deprecated steps. More...
 
class  behat_exact_named_selector
 Moodle-specific named exact selectors. More...
 
class  behat_field_manager
 Form fields helper. More...
 
class  behat_filters
 Steps definitions related to filters. More...
 
class  behat_init_context
 Loads main subcontexts. More...
 
class  behat_login
 Behat login related steps definitions. More...
 
class  behat_moodlenet
 Steps definitions related to MoodleNet. More...
 
class  behat_navigation
 Steps definitions to navigate through the navigation tree nodes. More...
 
class  behat_partial_named_selector
 Moodle-specific selectors. More...
 
class  behat_permissions
 Steps definitions related with permissions. More...
 
class  behat_selectors
 Moodle selectors manager. More...
 
interface  behat_session_interface
 The Interface for a behat root context. More...
 
class  behat_transformations
 Transformations to apply to steps arguments. More...
 
class  behat_util
 Init/reset utilities for Behat database and dataroot. More...
 
class  component_generator_base
 Component generator base class. More...
 
class  default_block_generator
 Default block generator class. More...
 
class  mod_chat_generator
 mod_chat data generator class. More...
 
class  nasty_strings
 Nasty strings manager. More...
 
class  phpunit_dataset
 Lightweight dataset class for phpunit, supports XML, CSV and array datasets. More...
 
class  restore_date_testcase
 Advanced PHPUnit test case customised for testing restore dates in Moodle. More...
 
class  test_lock
 Tests lock. More...
 
class  testing_block_generator
 Block generator base class. More...
 
class  testing_module_generator
 Module generator base class. More...
 
class  testing_util
 Testing util classes. More...
 
class  tests_finder
 Tests finder. More...
 

Functions

 behat_check_config_vars ()
 Checks that the behat config vars are properly set.
 
 behat_clean_init_config ()
 Restrict the config.php settings allowed.
 
 behat_error ($errorcode, $text='')
 Exits with an error code.
 
 behat_error_handler ($errno, $errstr, $errfile, $errline)
 PHP errors handler to use when running behat tests.
 
 behat_get_command_flags (string $option, $value)
 Get command flags for an option/value combination.
 
 behat_get_error_string ($errtype)
 Return logical error string.
 
 behat_get_run_process ()
 Get behat run process from either $_SERVER or command config.
 
 behat_get_shutdown_process_errors ()
 Return php errors save which were save during shutdown.
 
 behat_is_requested_url ($url)
 Checks if the URL requested by the user matches the provided argument.
 
 behat_is_test_site ()
 Should we switch to the test site data?
 
 behat_shutdown_function ()
 Before shutdown save last error entries, so we can fail the test.
 
 behat_update_vars_for_process ()
 Fix variables for parallel behat testing.
 
 cli_execute_parallel ($cmds, $cwd=null, $delay=0)
 Execute commands in parallel.
 
 testing_cli_argument_path ($moodlepath)
 Returns relative path against current working directory, to be used for shell execution hints.
 
 testing_cli_fix_directory_separator ($path)
 Fix DIRECTORY_SEPARATOR for windows.
 
 testing_error ($errorcode, $text='')
 Prints an error and stops execution.
 
 testing_fix_file_permissions ($file)
 Try to change permissions to $CFG->dirroot or $CFG->dataroot if possible.
 
 testing_initdataroot ($dataroot, $framework)
 Mark empty dataroot to be used for testing.
 
 testing_is_cygwin ()
 Find out if running under Cygwin on Windows.
 
 testing_is_mingw ()
 Returns whether a mingw CLI is running.
 
 testing_update_composer_dependencies (bool $selfupdate=true, bool $updatedependencies=true)
 Perform necessary steps to install and/or upgrade composer and its dependencies.
 

Variables

const BEHAT_EXITCODE_CONFIG 250
 Behat basic functions.
 
const BEHAT_EXITCODE_INSTALL 254
 
const BEHAT_EXITCODE_INSTALLED 256
 
const BEHAT_EXITCODE_PERMISSIONS 252
 
const BEHAT_EXITCODE_REINSTALL 253
 
const BEHAT_EXITCODE_REQUIREMENT 251
 
const BEHAT_PARALLEL_SITE_NAME "behatrun"
 The behat test site fullname and shortname.
 
const TESTING_EXITCODE_COMPOSER 255
 Testing general functions.
 

Detailed Description

Function Documentation

◆ behat_check_config_vars()

behat_check_config_vars ( )

Checks that the behat config vars are properly set.

Return values
voidStops execution with error code if something goes wrong.

◆ behat_clean_init_config()

behat_clean_init_config ( )

Restrict the config.php settings allowed.

When running the behat features the config.php settings should not affect the results.

Return values
void

◆ behat_error()

behat_error ( $errorcode,
$text = '' )

Exits with an error code.

Parameters
mixed$errorcode
string$text
Return values
voidStops execution with error code

◆ behat_error_handler()

behat_error_handler ( $errno,
$errstr,
$errfile,
$errline )

PHP errors handler to use when running behat tests.

Adds specific CSS classes to identify the messages.

Parameters
int$errno
string$errstr
string$errfile
int$errline
Return values
bool

◆ behat_get_command_flags()

behat_get_command_flags ( string $option,
$value )

Get command flags for an option/value combination.

Parameters
string$option
string | bool | null$value
Return values
string

◆ behat_get_error_string()

behat_get_error_string ( $errtype)

Return logical error string.

Parameters
int$errtypephp error type.
Return values
stringstring which will be returned.

◆ behat_get_run_process()

behat_get_run_process ( )

Get behat run process from either $_SERVER or command config.

Return values
bool|intfalse if single run, else run process number.

◆ behat_get_shutdown_process_errors()

behat_get_shutdown_process_errors ( )

Return php errors save which were save during shutdown.

Return values
array

◆ behat_is_requested_url()

behat_is_requested_url ( $url)

Checks if the URL requested by the user matches the provided argument.

Parameters
string$url
Return values
boolReturns true if it matches.

◆ behat_is_test_site()

behat_is_test_site ( )

Should we switch to the test site data?

Return values
bool

◆ behat_update_vars_for_process()

behat_update_vars_for_process ( )

Fix variables for parallel behat testing.

  • behat_wwwroot = behat_wwwroot{behatrunprocess}
  • behat_dataroot = behat_dataroot{behatrunprocess}
  • behat_prefix = behat_prefix.{behatrunprocess}_ (For oracle it will be firstletter of prefix and behatrunprocess)

◆ cli_execute_parallel()

cli_execute_parallel ( $cmds,
$cwd = null,
$delay = 0 )

Execute commands in parallel.

Parameters
array$cmdslist of commands to be executed.
string$cwdabsolute path of working directory.
int$delaytime in seconds to add delay between each parallel process.
Return values
arraylist of processes.

◆ testing_cli_argument_path()

testing_cli_argument_path ( $moodlepath)

Returns relative path against current working directory, to be used for shell execution hints.

Parameters
string$moodlepathstarting with "/", ex: "/admin/tool/cli/init.php"
Return values
stringpath relative to current directory or absolute path

◆ testing_cli_fix_directory_separator()

testing_cli_fix_directory_separator ( $path)

Fix DIRECTORY_SEPARATOR for windows.

In PHP on Windows, DIRECTORY_SEPARATOR is set to the backslash (::) character. However, if you're running a Cygwin/Msys/Git shell exec() calls will return paths using the forward slash (/) character.

NOTE: Because PHP on Windows will accept either forward or backslashes, paths should be built using ONLY forward slashes, regardless of OS. MOODLE_DIRECTORY_SEPARATOR should only be used when parsing paths returned by the shell.

Parameters
string$path
Return values
string

◆ testing_error()

testing_error ( $errorcode,
$text = '' )

Prints an error and stops execution.

Parameters
integer$errorcode
string$text
Return values
voidexits

◆ testing_fix_file_permissions()

testing_fix_file_permissions ( $file)

Try to change permissions to $CFG->dirroot or $CFG->dataroot if possible.

Parameters
string$file
Return values
boolsuccess

◆ testing_initdataroot()

testing_initdataroot ( $dataroot,
$framework )

Mark empty dataroot to be used for testing.

Parameters
string$datarootThe dataroot directory
string$frameworkThe test framework
Return values
void

◆ testing_is_cygwin()

testing_is_cygwin ( )

Find out if running under Cygwin on Windows.

Return values
bool

◆ testing_is_mingw()

testing_is_mingw ( )

Returns whether a mingw CLI is running.

MinGW sets $_SERVER['TERM'] to cygwin, but it can not run .bat files; this function may be useful when we need to output proposed commands to users using Windows CLI interfaces.

@externalurl http://sourceforge.net/p/mingw/bugs/1902

Return values
bool

◆ testing_update_composer_dependencies()

testing_update_composer_dependencies ( bool $selfupdate = true,
bool $updatedependencies = true )

Perform necessary steps to install and/or upgrade composer and its dependencies.

Installation is mandatory, but upgrade is optional.

Note: This function does not return, but will call exit() on error.

Parameters
bool$selfupdatePerform a composer self-update to update the composer.phar utility
bool$updatedependenciesUpgrade dependencies

Variable Documentation

◆ BEHAT_EXITCODE_CONFIG

const BEHAT_EXITCODE_CONFIG 250

Behat basic functions.

It does not include MOODLE_INTERNAL because is part of the bootstrap.

This script should not be usually included, neither any of its functions used, within mooodle code at all. It's for exclusive use of behat and moodle setup.php. For places requiring a different/special behavior needing to check if are being run as part of behat tests, use: if (defined('BEHAT_SITE_RUNNING')) { ...

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

◆ TESTING_EXITCODE_COMPOSER

const TESTING_EXITCODE_COMPOSER 255

Testing general functions.

Note: these functions must be self contained and must not rely on any library or include

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