add a way to manually use the test site from a Functional test

Created on 29 April 2021, about 3 years ago
Updated 10 July 2024, 3 days ago

Problem/Motivation

When developing a test, it's easy to get stuck in a situation where the setup of the test is going wrong.

Manipulating a Drupal site at one remove, through the intermediary of browser requests in the test, is a difficult and slow process. Each time a change is made, the test must be run all over again.

This could be improved if there was a way to preserve the test site after the test has run, so that the developer can interact with it and debug it.

Steps to reproduce

Proposed resolution

- Add a switch property to the Functional test base class which preserves the database tables in the test tear-down
- Add a switch in settings.php which allows DrupalKernel::findSitePath() to treat requests from a normal browser as being for a test site, perhaps with a query parameter.

The developer wishing to use the test site would then:

1. Override the switch property in their test class, setting it to TRUE
2. Set the switch in their settings.local.php
3. Run the test
4. After the test is complete, go to their site, with a query string ?testsite=test12345 where 'test12345' is the name of the folder in sites/simpletest that was created for the test

Remaining tasks

User interface changes

API changes

- new class property in the Functional test base class
- new setting in settings.local.php

Data model changes

Release notes snippet

Feature request
Status

Needs review

Version

11.0 🔥

Component
PHPUnit 

Last updated about 16 hours ago

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇺🇸United States smustgrave

    Could the MR be updated for 10.1 please.

  • Pipeline finished with Failed
    3 days ago
    Total: 643s
    #220726
  • Status changed to Needs review 3 days ago
  • 🇬🇧United Kingdom joachim

    Added control of this feature with a BROWSERTEST_PRESERVE_SITE env var, and added documentation to phpunit.xml.dist.

  • Pipeline finished with Failed
    3 days ago
    Total: 590s
    #220928
  • Pipeline finished with Failed
    3 days ago
    Total: 705s
    #220945
  • Pipeline finished with Success
    3 days ago
    Total: 482s
    #221023
Production build 0.69.0 2024