Allow contributed modules (mostly database drivers) to override tests in core

Created on 1 February 2020, over 4 years ago
Updated 3 February 2021, over 3 years ago

Problem/Motivation

Lastly discussed from #3098426-10: EntityQueryTest::testToString fails with non-core db drivers → onwards, but really popped up several times already,

+    if (!in_array(Database::getConnection()->driver(), ['mysql', 'sqlite', 'pgsql'])) {
+      $this->markTestSkipped("This test only runs for Drupal core database drivers");
+    }

feels fragile.

We should have a more structured way to include/exclude tests that are database specific in the test runs.

Proposed resolution

Add a new annotation for test classes called @overridesTestClass. The annotation must be used with a fully-qualified class name of the test class that is to be overrridden. When used will the overridden test class not be run. It is best to use this annotation in combination with extending the overridden class by current test class. The current test class can then override anything it needs to. The current test class will then be run instead of the overridden test class.

Remaining tasks

TBD

User interface changes

None

API changes

New annotation @overridesTestClass will be ccreated for test classes.

Data model changes

None

📌 Task
Status

Needs work

Version

11.0 🔥

Component
PHPUnit  →

Last updated about 4 hours ago

Created by

🇮🇹Italy mondrake 🇮🇹

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.69.0 2024