Look into good testing strategy for database related code

Ideally we want to test:

  • The service wrapping the DB
  • The migrations for each supported DB type
  • Reset the DB automatically
  • Easy to set up for each bundle
  • Skip DB tests if the DB is missing

The only thing I could get working was sqlite inmemory with custom migrations: https://gitlab.tugraz.at/dbp/formalize/dbp-relay-formalize-bundle/-/merge_requests/73 . This could be improved by adding migrations for sqlite, scoping migrations to the backend, and somehow find all migrations and execute them in the tests.

There is https://github.com/dmaicher/doctrine-test-bundle which might be helpful (??)

GitLab CI has an easy way to pull in a mysql docker container if needed: https://docs.gitlab.com/ee/ci/services/mysql.html

Sadly all guides I find involve manual calls to symfony commands (for migrations for example), which doesn't work in a bundle, and also is error prone.

Edited by Reiter, Christoph