Problem/Motivation
In #3074043: Move simpletest.module DB-related functions to TestDatabase, deprecate we're trying to deprecate top-level simpletest module functions by moving them to Drupal\Core\Test\TestDatabase
.
It so happens that we can't test many of our changes, because TestDatabase
is mostly static and thus can't be mocked.
Proposed resolution
- Test runners (simpletest.module and run-test.sh) run tests opening
TestRun
objects that have state and an execution log. TestDatabase
objects only cares about setting up the SUT database, not the results logging.- Each
TestRun
object is associated with aTestRunResultsStorageInterface
object, which responsibility is to store permanently the state and execution log of each test run. This interface is storage agnostic, implementations could use a database or anything else. SimpletestTestRunResultsStorage
is at the moment the only implementation ofTestRunResultsStorageInterface
, which is using the database and the legacy {simpletest} and {simpletest_test_id} tables for the purpose.