A standard set of fixtures for unit tests?
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable. |
What you get when Moodle in installed
When Moodle is installed, you don't just get empty database tables in the database, you also get some data created in some of the tables. The following is what I get from a fresh install of HEAD on Postgres using
SELECT relname, reltuples FROM pg_class WHERE relname LIKE 'mdl_%' AND relkind = 'r' AND reltuples > 0 ORDER BY reltuples DESC
Table | rows |
---|---|
mdl_role_capabilities | 600 |
mdl_capabilities | 236 |
mdl_config | 205 |
mdl_log_display | 104 |
mdl_survey_questions | 73 |
mdl_config_plugins | 35 |
mdl_block | 31 |
mdl_mnet_rpc | 17 |
mdl_mnet_service2rpc | 17 |
mdl_modules | 15 |
mdl_role_allow_assign | 13 |
mdl_user_preferences | 8 |
mdl_role_allow_override | 7 |
mdl_role | 7 |
mdl_block_instance | 6 |
mdl_survey | 5 |
mdl_quiz_report | 4 |
mdl_mnet_service | 4 |
mdl_message_providers | 4 |
mdl_context | 3 |
mdl_message_processors | 3 |
mdl_mnet_host | 2 |
mdl_user | 2 |
mdl_mnet_application | 2 |
mdl_events_handlers | 2 |
mdl_cache_flags | 1 |
mdl_course_categories | 1 |
mdl_role_assignments | 1 |
mdl_course | 1 |
Interpreting that, we have
- Version information for all installed plugins (and Moodle itself).
- Defaults for all the config variables.
- The standard roles and their capabilites
- The Admin user.
- The Guest user.
- The Miscellaneous category.
- The site course.
- The log_display information.
- Configuration of the messaging system.
- Some mnet stuff.
- Some survey module stuff.
Proposed standard test fixture
Oops, apparently Nicolas's generator script already had a default configuration a bit like this.
To make life easier for test writers, should we have something like the following: (This is the set up I normally end up creating in most of my dev sites.)
- A test course, short name 'TST100', full name 'Test course'.
- The following user accounts (These are firstname lastname (username)
- Student One (s1)
- Student Two (s2)
- Student Three (s3)
- Student Four (s4)
- Odd Teacher (t1)
- Even Teacher (t2)
- Those users enrolled in test course in the obvious roles.
- Two groups in the course, Group 1 (t1, s1, s3) and Group 2 (t2, s2, s4).
That is just a minimal set (so easy to maintain). Any more specific tests will have to set up their own test data. This list of test data is probably useful enough to consider having it always present. Of course, suggestions for extending this list are welcome.