Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

DML layer tests.

Copyright: 2008 Nicolas Connault
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 5857 lines (275 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 classes

core_dml_testcase:: (104 methods):
  setUp()
  get_test_table()
  test_diagnose()
  test_get_server_info()
  test_get_in_or_equal()
  test_fix_table_names()
  test_fix_sql_params()
  test_strtok()
  test_tweak_param_names()
  test_get_tables()
  test_get_indexes()
  test_get_columns()
  test_get_manager()
  test_setup_is_unicodedb()
  test_set_debug()
  test_execute()
  test_get_recordset()
  test_get_recordset_static()
  test_get_recordset_iterator_keys()
  test_get_recordset_list()
  test_get_recordset_select()
  test_get_recordset_sql()
  test_export_table_recordset()
  test_get_records()
  test_get_records_list()
  test_get_records_sql()
  test_get_records_menu()
  test_get_records_select_menu()
  test_get_records_sql_menu()
  test_get_record()
  test_get_record_select()
  test_get_record_sql()
  test_get_field()
  test_get_field_select()
  test_get_field_sql()
  test_get_fieldset_select()
  test_get_fieldset_sql()
  test_insert_record_raw()
  test_insert_record()
  test_insert_records()
  test_insert_record_with_nullable_unique_index()
  test_import_record()
  test_update_record_raw()
  test_update_record()
  test_set_field()
  test_set_field_select()
  test_count_records()
  test_count_records_select()
  test_count_records_sql()
  test_record_exists()
  test_record_exists_select()
  test_record_exists_sql()
  test_recordset_locks_delete()
  test_recordset_locks_update()
  test_delete_records()
  test_delete_records_select()
  test_delete_records_subquery()
  test_delete_records_list()
  test_object_params()
  test_sql_null_from_clause()
  test_sql_bitand()
  test_sql_bitnot()
  test_sql_bitor()
  test_sql_bitxor()
  test_sql_modulo()
  test_sql_ceil()
  test_cast_char2int()
  test_cast_char2real()
  test_sql_compare_text()
  test_unique_index_collation_trouble()
  test_sql_equal()
  test_sql_like()
  test_sql_like_escape()
  test_coalesce()
  test_sql_concat()
  sql_concat_join_provider()
  test_concat_join()
  test_sql_fullname()
  test_sql_order_by_text()
  test_sql_substring()
  test_sql_length()
  test_sql_position()
  test_sql_empty()
  test_sql_isempty()
  test_sql_isnotempty()
  test_sql_regex()
  test_set_field_select_complicated()
  test_get_records_sql_complicated()
  test_replace_all_text()
  test_onelevel_commit()
  test_transaction_ignore_error_trouble()
  test_onelevel_rollback()
  test_nested_transactions()
  test_transactions_forbidden()
  test_wrong_transactions()
  test_concurent_transactions()
  test_session_locks()
  test_bound_param_types()
  test_bound_param_reserved()
  test_limits_and_offsets()
  test_invalid_limits_debugging()
  test_queries_counter()
  test_sql_intersect()
  test_four_byte_character_insertion()

moodle_database_for_testing:: (35 methods):
  public_fix_table_names()
  driver_installed()
  get_dbfamily()
  get_dbtype()
  get_dblibrary()
  get_name()
  get_configuration_help()
  connect()
  get_server_info()
  allowed_param_types()
  get_last_error()
  get_tables()
  get_indexes()
  fetch_columns()
  normalise_value()
  set_debug()
  get_debug()
  change_database_structure()
  execute()
  get_recordset_sql()
  get_records_sql()
  get_fieldset_sql()
  insert_record_raw()
  insert_record()
  import_record()
  update_record_raw()
  update_record()
  set_field_select()
  delete_records_select()
  sql_concat()
  sql_concat_join()
  sql_substr()
  begin_transaction()
  commit_transaction()
  rollback_transaction()

dml_test_object_one:: (1 method):
  __toString()


Class: core_dml_testcase  - X-Ref

setUp()   X-Ref
No description

get_test_table($suffix = '')   X-Ref
Get a xmldb_table object for testing, deleting any existing table
of the same name, for example if one was left over from a previous test
run that crashed.

param: string $suffix table name suffix, use if you need more test tables
return: xmldb_table the table object.

test_diagnose()   X-Ref
No description

test_get_server_info()   X-Ref
No description

test_get_in_or_equal()   X-Ref
No description

test_fix_table_names()   X-Ref
No description

test_fix_sql_params()   X-Ref
No description

test_strtok()   X-Ref
No description

test_tweak_param_names()   X-Ref
No description

test_get_tables()   X-Ref
No description

test_get_indexes()   X-Ref
No description

test_get_columns()   X-Ref
No description

test_get_manager()   X-Ref
No description

test_setup_is_unicodedb()   X-Ref
No description

test_set_debug()   X-Ref
No description

test_execute()   X-Ref
No description

test_get_recordset()   X-Ref
No description

test_get_recordset_static()   X-Ref
No description

test_get_recordset_iterator_keys()   X-Ref
No description

test_get_recordset_list()   X-Ref
No description

test_get_recordset_select()   X-Ref
No description

test_get_recordset_sql()   X-Ref
No description

test_export_table_recordset()   X-Ref
No description

test_get_records()   X-Ref
No description

test_get_records_list()   X-Ref
No description

test_get_records_sql()   X-Ref
No description

test_get_records_menu()   X-Ref
No description

test_get_records_select_menu()   X-Ref
No description

test_get_records_sql_menu()   X-Ref
No description

test_get_record()   X-Ref
No description

test_get_record_select()   X-Ref
No description

test_get_record_sql()   X-Ref
No description

test_get_field()   X-Ref
No description

test_get_field_select()   X-Ref
No description

test_get_field_sql()   X-Ref
No description

test_get_fieldset_select()   X-Ref
No description

test_get_fieldset_sql()   X-Ref
No description

test_insert_record_raw()   X-Ref
No description

test_insert_record()   X-Ref
No description

test_insert_records()   X-Ref
No description

test_insert_record_with_nullable_unique_index()   X-Ref
No description

test_import_record()   X-Ref
No description

test_update_record_raw()   X-Ref
No description

test_update_record()   X-Ref
No description

test_set_field()   X-Ref
No description

test_set_field_select()   X-Ref
No description

test_count_records()   X-Ref
No description

test_count_records_select()   X-Ref
No description

test_count_records_sql()   X-Ref
No description

test_record_exists()   X-Ref
No description

test_record_exists_select()   X-Ref
No description

test_record_exists_sql()   X-Ref
No description

test_recordset_locks_delete()   X-Ref
No description

test_recordset_locks_update()   X-Ref
No description

test_delete_records()   X-Ref
No description

test_delete_records_select()   X-Ref
No description

test_delete_records_subquery()   X-Ref
No description

test_delete_records_list()   X-Ref
No description

test_object_params()   X-Ref
No description

test_sql_null_from_clause()   X-Ref
No description

test_sql_bitand()   X-Ref
No description

test_sql_bitnot()   X-Ref
No description

test_sql_bitor()   X-Ref
No description

test_sql_bitxor()   X-Ref
No description

test_sql_modulo()   X-Ref
No description

test_sql_ceil()   X-Ref
No description

test_cast_char2int()   X-Ref
No description

test_cast_char2real()   X-Ref
No description

test_sql_compare_text()   X-Ref
No description

test_unique_index_collation_trouble()   X-Ref
No description

test_sql_equal()   X-Ref
No description

test_sql_like()   X-Ref
No description

test_sql_like_escape()   X-Ref
Test DML libraries sql_like_escape method


test_coalesce()   X-Ref
No description

test_sql_concat()   X-Ref
No description

sql_concat_join_provider()   X-Ref
No description

test_concat_join($concat, $fields, $params, $expected)   X-Ref

param: string $concat The string to use when concatanating.
param: array $fields The fields to concatanate
param: array $params Any parameters to provide to the query
param: @string $expected The expected result

test_sql_fullname()   X-Ref
No description

test_sql_order_by_text()   X-Ref
No description

test_sql_substring()   X-Ref
No description

test_sql_length()   X-Ref
No description

test_sql_position()   X-Ref
No description

test_sql_empty()   X-Ref
No description

test_sql_isempty()   X-Ref
No description

test_sql_isnotempty()   X-Ref
No description

test_sql_regex()   X-Ref
No description

test_set_field_select_complicated()   X-Ref
Test some complicated variations of set_field_select.


test_get_records_sql_complicated()   X-Ref
Test some more complex SQL syntax which moodle uses and depends on to work
useful to determine if new database libraries can be supported.


test_replace_all_text()   X-Ref
No description

test_onelevel_commit()   X-Ref
No description

test_transaction_ignore_error_trouble()   X-Ref
No description

test_onelevel_rollback()   X-Ref
No description

test_nested_transactions()   X-Ref
No description

test_transactions_forbidden()   X-Ref
No description

test_wrong_transactions()   X-Ref
No description

test_concurent_transactions()   X-Ref
No description

test_session_locks()   X-Ref
No description

test_bound_param_types()   X-Ref
No description

test_bound_param_reserved()   X-Ref
No description

test_limits_and_offsets()   X-Ref
No description

test_invalid_limits_debugging()   X-Ref
Test debugging messages about invalid limit number values.


test_queries_counter()   X-Ref
No description

test_sql_intersect()   X-Ref
No description

test_four_byte_character_insertion()   X-Ref
Test that the database has full utf8 support (4 bytes).


Class: moodle_database_for_testing  - X-Ref

This class is not a proper subclass of moodle_database. It is
intended to be used only in unit tests, in order to gain access to the
protected methods of moodle_database, and unit test them.

public_fix_table_names($sql)   X-Ref
No description

driver_installed()   X-Ref
No description

get_dbfamily()   X-Ref
No description

get_dbtype()   X-Ref
No description

get_dblibrary()   X-Ref
No description

get_name()   X-Ref
No description

get_configuration_help()   X-Ref
No description

connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null)   X-Ref
No description

get_server_info()   X-Ref
No description

allowed_param_types()   X-Ref
No description

get_last_error()   X-Ref
No description

get_tables($usecache=true)   X-Ref
No description

get_indexes($table)   X-Ref
No description

fetch_columns(string $table)   X-Ref
No description

normalise_value($column, $value)   X-Ref
No description

set_debug($state)   X-Ref
No description

get_debug()   X-Ref
No description

change_database_structure($sql, $tablenames = null)   X-Ref
No description

execute($sql, array $params=null)   X-Ref
No description

get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)   X-Ref
No description

get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)   X-Ref
No description

get_fieldset_sql($sql, array $params=null)   X-Ref
No description

insert_record_raw($table, $params, $returnid=true, $bulk=false, $customsequence=false)   X-Ref
No description

insert_record($table, $dataobject, $returnid=true, $bulk=false)   X-Ref
No description

import_record($table, $dataobject)   X-Ref
No description

update_record_raw($table, $params, $bulk=false)   X-Ref
No description

update_record($table, $dataobject, $bulk=false)   X-Ref
No description

set_field_select($table, $newfield, $newvalue, $select, array $params=null)   X-Ref
No description

delete_records_select($table, $select, array $params=null)   X-Ref
No description

sql_concat()   X-Ref
No description

sql_concat_join($separator="' '", $elements=array()   X-Ref
No description

sql_substr($expr, $start, $length=false)   X-Ref
No description

begin_transaction()   X-Ref
No description

commit_transaction()   X-Ref
No description

rollback_transaction()   X-Ref
No description

Class: dml_test_object_one  - X-Ref

Dumb test class with toString() returning 1.

__toString()   X-Ref
No description