Problem/Motivation
In Drupal 8, Drupal\KernelTests\Core\Database\ConnectionUnitTest was skipped for all database other than mysql. In drupal 9, the test was expanded to be able to be run on psql, but the condition was now to only skip for sqlite. A more universal approach would be to skip for any non-mysql and non-psql database.
Steps to reproduce
Run this test on sqlsrv database. it was skipped in D8, but throws exceptions on D9.
Proposed resolution
change:
if ($this->connection->databaseType() == 'sqlite') {
$this->markTestSkipped("This tests can not run with an SQLite database.");
}
To
$database_type = $this->connection->databaseType();
if ($database_type != 'mysql' && $database_type != 'pgsql') {
$this->markTestSkipped("This tests only runs on MySQL and PostgreSQL");
}
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
beakerboyComment #3
beakerboyComment #5
daffie commentedI am not sure if skipping the tests for all database drivers other then MySQL and PostgreSQL is the right solution. I think that the solution will need to be that database driver modules can override tests for core. In this case for MS SQL server the overridden test will skip these assertions. Every module can or should be able to add a
phpunit.xmlfile. In that file you can override tests from core and replace them with custom ones. See: https://phpunit.readthedocs.io/en/9.5/configuration.html#the-exclude-ele....Comment #6
mondrake@Beakerboy @daffie it would be nice to get #3110546: Allow contributed modules (mostly database drivers) to override tests in core to a landing... that allows running tests on contrib drivers excluding a list of core test classes - then the contrib db driver module can readd those tests extending from core classes and making the chnages needed. I've been using that in DruDbal for over 1.5 years now.
https://github.com/mondrake/drudbal/blob/master/.github/workflows/mysql....
Comment #7
mondrakeAlso, would be nice to complete #3129043: Move core database drivers to modules of their own, and with that done, split the Database tests in 'core' ones and 'driver specific' ones, with the 'driver specifc' ones running dependent on the db driver in use by the SUT. But that is way ahead.
Comment #8
beakerboyIs this test changing as a part of the "move database drivers" issue? Is it worth waiting for that to maybe eventually get through, or can this small change happen while we are waiting?
Comment #9
mondrake#8 surely not in the short term. In the meantime yes, this a stop-gap.
Comment #11
catchThis would be good, agreed though about fixing the current logic.
Committed f35afca and pushed to 9.3.x. Thanks!
Comment #12
mondrakeFiled #3231950: Split Database tests in 'core' ones and 'driver specific' ones as a D10 follow-up.