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

Issue fork drupal-3230714

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Beakerboy created an issue. See original summary.

beakerboy’s picture

Issue summary: View changes
beakerboy’s picture

Status: Active » Needs review

daffie’s picture

I 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.xml file. 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....

mondrake’s picture

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

mondrake’s picture

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

beakerboy’s picture

Is 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?

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

#8 surely not in the short term. In the meantime yes, this a stop-gap.

  • catch committed f35afca on 9.3.x
    Issue #3230714 by Beakerboy, mondrake: ConnectionUnitTest should be...
catch’s picture

Status: Reviewed & tested by the community » Fixed

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.

This would be good, agreed though about fixing the current logic.

Committed f35afca and pushed to 9.3.x. Thanks!

mondrake’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.