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
No edit summary
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Work in progress}}
{{Template:Development:dmllib 2.0}}{{Moodle_2.0}}
{{Template:Development:dmllib 2.0}}


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


* TestCreateTable
You can test current database specified in config.php, you can also specify other DB servers via following config.php settings, for example:
* TestDropTable
<code php>
* TestAddEnumField
$CFG->func_test_db_1 = array("native", "mysqli", "localhost", "root", "yourpassword", "moodle", "tst_", array('dbengine'=>'InnoDB'));
* TestAddNumericField
$CFG->func_test_db_2 = array("native", "mysqli", "localhost", "root", "yourpassword", "moodle2", "tst_", array('dbengine'=>'MyISAM'));
* TestDropField
$CFG->func_test_db_3 = array("native", "pgsql", "localhost", "moodleuser", "yourpassword", "moodle2", "tst_", NULL);
* TestChangeFieldType
$CFG->func_test_db_4 = array("native", "mssql", "192.168.15.41", "sa", "yourpassword", "moodle", "tst_", NULL);
* TestChangeFieldPrecision
</code>
* TestChangeFieldSign
* TestChangeFieldNullability
* TestChangeFieldDefault
* TestAddUniqueIndex
* TestAddNonUniqueIndex
* TestFindIndexName
* TestDropIndex
* TestAddUniqueKey
* TestAddForeignUniqueKey
* TestDropKey
* TestAddForeignKey
* TestDropForeignKey
* TestChangeFieldEnum
* TestRenameIndex >>>'''Experimental'''<<<
* TestRenameKey >>>'''Experimental'''<<<
* TestRenameField
* TestRenameTable


The following database_manager method still need to be tested:
== DDL tests ==
 
All DDL test must pass on any production server.
* 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


Additionally, 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)

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)