Collection of utility methods.
More...
|
static | bootstrap_init () |
| Called during bootstrap only!
|
|
static | bootstrap_moodle_info () |
| Print some Moodle related info to console.
|
|
static | build_config_file () |
| Builds dirroot/phpunit.xml file using defaults from /phpunit.xml.dist.
|
|
static | clean_tables_updated_by_scenario_list () |
| Delete tablesupdatedbyscenario file.
|
|
static | drop_site ($displayprogress=false) |
| Drop all test site data.
|
|
static | get_data_generator () |
| Get data generator.
|
|
static | get_dataroot () |
| Return the dataroot.
|
|
static | get_environment () |
| Return list of environment versions on which tests will run.
|
|
static | get_git_hash () |
| Try to get current git hash of the Moodle in $CFG->dirroot.
|
|
static | get_global_backup ($name) |
| Returns original state of global variable.
|
|
static | get_originaldatafilesjson () |
| Return the name of the JSON file containing the init filenames.
|
|
static | get_sequencenames () |
| Returns the names of sequences for each autoincrementing id field in all standard tables.
|
|
static | get_site_info () |
| Gets a text-based site version description.
|
|
static | get_tablestructure () |
| Returns structure of all tables right after installation.
|
|
static | initialise_cfg () |
| Load global $CFG;.
|
|
static | install_site () |
| Perform a fresh test site installation.
|
|
static | is_test_data_updated () |
| Returns whether test database and dataroot were created using the current version codebase.
|
|
static | is_test_site () |
| Does this site (db and dataroot) appear to be used for production? We try very hard to prevent accidental damage done to production servers!!
|
|
static | reset_all_data ($detectchanges=false) |
| Reset contents of all database tables to initial values, reset caches, etc.
|
|
static | reset_all_database_sequences (array $empties=null) |
| Reset all database sequences to initial values.
|
|
static | reset_database () |
| Reset all database tables to default values.
|
|
static | reset_dataroot () |
| Purge dataroot directory.
|
|
static | reset_updated_table_list () |
| Reset updated table list.
|
|
static | set_dataroot ($dataroot) |
| Set the dataroot.
|
|
static | set_table_modified_by_sql ($sql) |
| Set state of modified tables.
|
|
static | testing_ready_problem () |
| Is this site initialised to run unit tests?
|
|
|
static int | $lastdbwrites = null |
| last value of db writes counter, used for db resetting
|
|
static array | $tableupdated = [] |
| list of updated tables.
|
|
|
static | drop_database ($displayprogress=false) |
| Drop the whole test database.
|
|
static | drop_dataroot () |
| Drops the test framework dataroot.
|
|
static | get_framework () |
| Returns the testing framework name.
|
|
static | get_tabledata () |
| Returns contents of all tables right after installation.
|
|
static | get_tables_updated_by_scenario_list_path () |
| Returns the path to the file which holds list of tables updated in scenario.
|
|
static | guess_unmodified_empty_tables () |
| Returns list of tables that are unmodified and empty.
|
|
static | save_original_data_files () |
| Save the list of the original dataroot files into a json file.
|
|
static | skip_original_data_files ($utilclassname) |
| Skip the original dataroot files to not been reset.
|
|
static | store_database_state () |
| Stores the status of the database.
|
|
static | store_versions_hash () |
| Stores the version hash in both database and dataroot.
|
|
|
static array | $datarootskipondrop = array('.', '..', 'lock') |
| Files to skip when dropping dataroot folder.
|
|
static array | $datarootskiponreset = array('.', '..', 'phpunittestdir.txt', 'phpunit', '.htaccess') |
| Files to skip when resetting dataroot folder.
|
|
static array | $debuggings = array() |
| list of debugging messages triggered during the last test execution
|
|
static phpunit_message_sink | $eventsink = null |
| alternative target for moodle messaging
|
|
static testing_data_generator | $generator = null |
|
static array | $globals = array() |
| An array of original globals, restored after each test.
|
|
static phpunit_message_sink | $messagesink = null |
| alternative target for moodle messaging
|
|
static phpunit_phpmailer_sink | $phpmailersink = null |
| alternative target for phpmailer messaging
|
|
static array | $sequencenames = null |
| original structure of all database tables
|
|
static int | $sequencenextstartingid = null |
| next sequence value for a single test cycle.
|
|
static array | $tabledata = null |
| original content of all database tables
|
|
static array | $tablestructure = null |
| original structure of all database tables
|
|
static string | $versionhash = null |
| current version hash from php files
|
|
Collection of utility methods.
- Copyright
- 2012 Petr Skoda
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ build_config_file()
static phpunit_util::build_config_file |
( |
| ) |
|
|
static |
Builds dirroot/phpunit.xml file using defaults from /phpunit.xml.dist.
- Return values
-
bool | true means main config file created, false means only dataroot file created |
◆ clean_tables_updated_by_scenario_list()
static testing_util::clean_tables_updated_by_scenario_list |
( |
| ) |
|
|
staticinherited |
Delete tablesupdatedbyscenario file.
This should be called before suite, to ensure full db reset.
◆ drop_database()
static testing_util::drop_database |
( |
| $displayprogress = false | ) |
|
|
staticprotectedinherited |
Drop the whole test database.
- Parameters
-
◆ drop_dataroot()
static testing_util::drop_dataroot |
( |
| ) |
|
|
staticprotectedinherited |
Drops the test framework dataroot.
Reimplemented in behat_util.
◆ drop_site()
static phpunit_util::drop_site |
( |
| $displayprogress = false | ) |
|
|
static |
Drop all test site data.
Note: To be used from CLI scripts only.
- Parameters
-
bool | $displayprogress | if true, this method will echo progress information. |
- Return values
-
void | may terminate execution with exit code |
◆ get_data_generator()
static testing_util::get_data_generator |
( |
| ) |
|
|
staticinherited |
Get data generator.
- Return values
-
◆ get_dataroot()
static testing_util::get_dataroot |
( |
| ) |
|
|
staticinherited |
Return the dataroot.
It's useful when mocking the dataroot when unit testing this class itself.
- Return values
-
◆ get_environment()
static testing_util::get_environment |
( |
| ) |
|
|
staticinherited |
Return list of environment versions on which tests will run.
Environment includes:
- moodleversion
- phpversion
- dbtype
- dbversion
- os
- Return values
-
◆ get_framework()
static testing_util::get_framework |
( |
| ) |
|
|
staticfinalprotectedinherited |
Returns the testing framework name.
- Return values
-
◆ get_git_hash()
static testing_util::get_git_hash |
( |
| ) |
|
|
staticinherited |
Try to get current git hash of the Moodle in $CFG->dirroot.
- Return values
-
string | null if unknown, sha1 hash if known |
◆ get_global_backup()
static phpunit_util::get_global_backup |
( |
| $name | ) |
|
|
static |
Returns original state of global variable.
- Parameters
-
- Return values
-
◆ get_originaldatafilesjson()
static testing_util::get_originaldatafilesjson |
( |
| ) |
|
|
staticinherited |
Return the name of the JSON file containing the init filenames.
- Return values
-
◆ get_sequencenames()
static testing_util::get_sequencenames |
( |
| ) |
|
|
staticinherited |
Returns the names of sequences for each autoincrementing id field in all standard tables.
- Return values
-
array\$table,=>$sequencename | |
◆ get_site_info()
static testing_util::get_site_info |
( |
| ) |
|
|
staticinherited |
Gets a text-based site version description.
- Return values
-
Reimplemented in behat_util.
◆ get_tabledata()
static testing_util::get_tabledata |
( |
| ) |
|
|
staticprotectedinherited |
Returns contents of all tables right after installation.
- Return values
-
◆ get_tables_updated_by_scenario_list_path()
static testing_util::get_tables_updated_by_scenario_list_path |
( |
| ) |
|
|
staticfinalprotectedinherited |
Returns the path to the file which holds list of tables updated in scenario.
- Return values
-
◆ get_tablestructure()
static testing_util::get_tablestructure |
( |
| ) |
|
|
staticinherited |
Returns structure of all tables right after installation.
- Return values
-
◆ guess_unmodified_empty_tables()
static testing_util::guess_unmodified_empty_tables |
( |
| ) |
|
|
staticprotectedinherited |
Returns list of tables that are unmodified and empty.
- Return values
-
array | of table names, empty if unknown |
◆ install_site()
static phpunit_util::install_site |
( |
| ) |
|
|
static |
Perform a fresh test site installation.
Note: To be used from CLI scripts only.
- Return values
-
void | may terminate execution with exit code |
◆ is_test_data_updated()
static testing_util::is_test_data_updated |
( |
| ) |
|
|
staticinherited |
Returns whether test database and dataroot were created using the current version codebase.
- Return values
-
◆ is_test_site()
static testing_util::is_test_site |
( |
| ) |
|
|
staticinherited |
Does this site (db and dataroot) appear to be used for production? We try very hard to prevent accidental damage done to production servers!!
- Return values
-
◆ reset_all_data()
static phpunit_util::reset_all_data |
( |
| $detectchanges = false | ) |
|
|
static |
Reset contents of all database tables to initial values, reset caches, etc.
Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
- Parameters
-
bool | $detectchanges | true - changes in global state and database are reported as errors false - no errors reported null - only critical problems are reported as errors |
- Return values
-
◆ reset_all_database_sequences()
static testing_util::reset_all_database_sequences |
( |
array | $empties = null | ) |
|
|
staticinherited |
Reset all database sequences to initial values.
- Parameters
-
array | $empties | tables that are known to be unmodified and empty |
- Return values
-
◆ reset_database()
static phpunit_util::reset_database |
( |
| ) |
|
|
static |
Reset all database tables to default values.
- Return values
-
bool | true if reset done, false if skipped |
Reimplemented from testing_util.
◆ reset_dataroot()
static testing_util::reset_dataroot |
( |
| ) |
|
|
staticinherited |
Purge dataroot directory.
- Return values
-
◆ reset_updated_table_list()
static testing_util::reset_updated_table_list |
( |
| ) |
|
|
staticinherited |
Reset updated table list.
This should be done after every reset.
◆ set_dataroot()
static testing_util::set_dataroot |
( |
| $dataroot | ) |
|
|
staticinherited |
Set the dataroot.
It's useful when mocking the dataroot when unit testing this class itself.
- Parameters
-
string | $dataroot | the dataroot of the test framework. |
◆ set_table_modified_by_sql()
static testing_util::set_table_modified_by_sql |
( |
| $sql | ) |
|
|
staticinherited |
Set state of modified tables.
- Parameters
-
string | $sql | sql which is updating the table. |
◆ skip_original_data_files()
static testing_util::skip_original_data_files |
( |
| $utilclassname | ) |
|
|
staticprotectedinherited |
Skip the original dataroot files to not been reset.
- Parameters
-
string | $utilclassname | the util class name.. |
◆ store_database_state()
static testing_util::store_database_state |
( |
| ) |
|
|
staticprotectedinherited |
Stores the status of the database.
Serializes the contents and the structure and stores it in the test framework space in dataroot
◆ testing_ready_problem()
static phpunit_util::testing_ready_problem |
( |
| ) |
|
|
static |
Is this site initialised to run unit tests?
- Return values
-
int | array errorcode=>message, 0 means ok |
The documentation for this class was generated from the following file:
- lib/phpunit/classes/util.php