Page MenuHomePhabricator

Allow unit tests to test against different database schemas
Closed, ResolvedPublic


We quite often need to support multiple database schemas for backward compatibility. Since this support may be maintained for a long time, we should have tests that ensure that our code works with the different schema versions. This is motivated by the MCR schema migration, but should help with any kind of schema change.

One way to achieve this is to have a method in MediaWikiTestCase which can be overwritten to return information about which tables are going to be altered, and which SQL files should be used to set up the target schema. This would mean that a test for a class that interacts with the database can have a subclass for each supported database schema.

Care must be taken to restore the original schema after each test class.


Related Gerrit Patches:

Event Timeline

daniel created this task.Nov 16 2017, 4:48 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 16 2017, 4:48 PM

Change 391866 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Introduce DB schema overrides for unit tests.

daniel updated the task description. (Show Details)Nov 16 2017, 4:51 PM

Change 391866 merged by jenkins-bot:
[mediawiki/core@master] Introduce DB schema overrides for unit tests.

@daniel Did resolve this task, or is there more?

daniel closed this task as Resolved.Jan 8 2018, 8:02 PM

@Krinkle it's done, thanks