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
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.