Allow BTB to test an existing, already installed Drupal site instead of installing from scratch

Created on 1 September 2016, over 8 years ago
Updated 23 May 2023, over 1 year ago

Problem/Motivation

When writing tests it would be helpful to use the test classes to run against an installation of Drupal created by means other than the test setup. When writing functional tests and integration tests for whole-site builds and not specific features isolated to specific modules, the approach to writing tests has typically been:

  1. Set up a functioning version of the website on CI by either importing a database from another environment (or reinstalling and importing config).
  2. Create a base test class which overrides setup to halt the installation of Drupal.
  3. Write tests which all work against the same, single environment setup on CI that closely reflects the production environment.

Alternatives to this are writing the site as an installation profile that can be used for each test or importing the websites configuration folder during every test run. The issue with these two approaches is how slow they are and missing out on creating a test environment that exactly represents production, beyond just the configuration and code.

Examples of things which impact a site during runtime are the sites content, all configuration created/available for modification on production and the database schema (a site having gone through every updb as opposed to a fresh module installation). Once an environment is replicated on CI, tests of this kind are impacted by these factors, making them useful for determining the real status of a site.

Proposed resolution

Add a property to BrowserTestBase which forgoes the installation of Drupal, sets the test class up to run against the parent site and cleans up entities created during the test.

Remaining tasks

  1. Seek approval for this feature. See #68
  2. Ensure the entities are cleaned up automatically. 📌 Add events for matching entity hooks Needs work
  3. Make sure approach is compatible with and possibly blocked by #2796105: Move similar methods in BrowserTestBase / WebTestBase to a trait; untangle installDrupal() .

User interface changes

None.

API changes

Additional properly on BTB that controls the Drupal installation status.

Data model changes

None.

Feature request
Status

Closed: won't fix

Version

10.1

Component
PHPUnit 

Last updated about 17 hours ago

Created by

🇦🇺Australia Sam152

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024