Note:

This site is no longer used and is in read-only mode. Instead please go to our new Moodle Developer Resource site.

DB layer 2.0 functional testing: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Work in progress}}{{Development:dmllib 2.0}}{{Moodle_2.0}}== DDL tests ==
{{Template:WillNotMigrate}}
Based on tests already used in xmldb, the following methods have been implemented in simpletest:


* create_table
{{Template:Development:dmllib 2.0}}{{Moodle_2.0}}
* drop_table
* add_enum_field
* add_numeric_field
* drop_field
* change_field_type
* change_field_precision
* change_field_sign
* change_field_nullability
* change_field_default
* add_unique_index
* add_non_unique_index
* find_index_name
* drop_index
* add_unique_key
* add_foreign_unique_key
* drop_key
* add_foreign_key
* drop_foreign_key
* change_field_enum
* rename_index >>>'''experimental'''<<<
* rename_key >>>'''experimental'''<<<
* rename_field
* rename_table
* table_exists
* field_exists
* index_exists
* find_check_constraint_name
* check_constraint_exists
* find_key_name
* find_sequence_name
* delete_tables_from_xmldb_file
* install_from_xmldb_file
* create_temp_table


== DML tests ==
Functional unit tests can be used to test the interaction of Moodle and database, it is testing following:
The following methods have been implemented in unit tests:
* SQL database server
* PHP database driver
* Moodle DB connection settings, driver configuration and server settings
* Moodle DDL generator
* Moodle DML driver


* fix_sql_params
You can test current database specified in config.php, you can also specify other DB servers via following config.php settings, for example:
* get_tables
<syntaxhighlight lang="php">
* get_indexes
$CFG->func_test_db_1 = array("native", "mysqli", "localhost", "root", "yourpassword", "moodle", "tst_", array('dbengine'=>'InnoDB'));
* get_columns
$CFG->func_test_db_2 = array("native", "mysqli", "localhost", "root", "yourpassword", "moodle2", "tst_", array('dbengine'=>'MyISAM'));
* execute
$CFG->func_test_db_3 = array("native", "pgsql", "localhost", "moodleuser", "yourpassword", "moodle2", "tst_", NULL);
* get_in_or_equal
$CFG->func_test_db_4 = array("native", "mssql", "192.168.15.41", "sa", "yourpassword", "moodle", "tst_", NULL);
* fix_table_names
</syntaxhighlight>
* get_recordset
* get_recordset_list
* get_recordset_select
* get_recordset_sql
* get_records
* get_records_list
* get_records_select
* get_records_sql
* get_records_menu
* get_records_select_menu
* get_records_sql_menu
* get_record
* get_record_select
* get_record_sql
* get_field
* get_field_select
* get_field_sql
* get_fieldset_select
* get_fieldset_sql
* insert_record_raw
* insert_record
* update_record_raw
* update_record
* set_field
* set_field_select
* count_records
* count_records_select
* count_records_sql
* record_exists
* record_exists_select
* record_exists_sql
* delete_records
* delete_records_select


== Still to do ==
== DDL tests ==
All DDL test must pass on any production server.


The tests need to be expanded to include boundary conditions, including invalid or incomplete parameters.
== DML tests ==
Ideally all DML tests should pass on production servers.


* How do these methods behave when given invalid params?
Common problems:
* Are exceptions in place, and are they caught appropriately?
* MySQL MyISAM engine does ACID compliant and does not support transactions, please consider upgrading to InnoDB.
* MySQL supports only a limited number of collations, this may cause significant problems for non-english languages
* Oracle is known to fail in multiple tests (work in progress)

Latest revision as of 08:10, 10 February 2025


Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


Moodle 2.0


Functional unit tests can be used to test the interaction of Moodle and database, it is testing following:

  • SQL database server
  • PHP database driver
  • Moodle DB connection settings, driver configuration and server settings
  • Moodle DDL generator
  • Moodle DML driver

You can test current database specified in config.php, you can also specify other DB servers via following config.php settings, for example:

$CFG->func_test_db_1 = array("native", "mysqli", "localhost", "root", "yourpassword", "moodle", "tst_", array('dbengine'=>'InnoDB'));
$CFG->func_test_db_2 = array("native", "mysqli", "localhost", "root", "yourpassword", "moodle2", "tst_", array('dbengine'=>'MyISAM'));
$CFG->func_test_db_3 = array("native", "pgsql", "localhost", "moodleuser", "yourpassword", "moodle2", "tst_", NULL);
$CFG->func_test_db_4 = array("native", "mssql", "192.168.15.41", "sa", "yourpassword", "moodle", "tst_", NULL);

DDL tests

All DDL test must pass on any production server.

DML tests

Ideally all DML tests should pass on production servers.

Common problems:

  • MySQL MyISAM engine does ACID compliant and does not support transactions, please consider upgrading to InnoDB.
  • MySQL supports only a limited number of collations, this may cause significant problems for non-english languages
  • Oracle is known to fail in multiple tests (work in progress)