Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

DB layer 2.0 functional testing: Difference between revisions

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


* create_table
Functional unit tests can be used to test the interaction of Moodle and database, it is testing following:
* drop_table
* SQL database server
* add_enum_field
* PHP database driver
* add_numeric_field
* Moodle DB connection settings, driver configuration and server settings
* drop_field
* Moodle DDL generator
* change_field_type
* Moodle DML driver
* 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 ==
You can test current database specified in config.php, you can also specify other DB servers via following config.php settings, for example:
The following methods have been implemented in unit tests:
<code php>
$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);
</code>


* fix_sql_params
== DDL tests ==
* get_tables
All DDL test must pass on any production server.
* get_indexes
* get_columns
* execute
* get_in_or_equal
* fix_table_names
* 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 ==
== DML tests ==
 
Ideally all DML tests should pass on production servers.
The tests need to be expanded to include boundary conditions, including invalid or incomplete parameters.


* 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)

Revision as of 18:45, 3 September 2010

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)