Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
- Individual tests have access to the
TestBase::$original*
properties containing environment data of the parent site (test runner). - Tests must not have access to environment information of the test runner.
Proposed solution
-
Introduce a new + single + central + private
TestBase::$original
(array/object) storage. -
Move all values being backed up in
TestBase::prepareEnvironment()
intoTestBase::$original
. -
Do something about
Drupal\simpletest\BrokenSetUpTest
(which relies on data sharing between parent/child site), or simply delete it.
Comments
Comment #1
sunI'll work on this, but postponing this on the following two issues:
#2170023: Use exceptions when something goes wrong in test setup
#2171683: Remove all Simpletest overrides and rely on native multi-site functionality instead
Also, given that a malformed test is able to destroy the entire parent site by (un)intentionally accessing or changing those
$original*
variables, this is at least major.Comment #2
sunComment #3
jhedstromThis just moves the existing properties that should not be accessible to private. Creating a central private and single property seems unnecessarily complex (and any sort of type hinting would be removed).
Comment #4
tim.plunkettEmpty patch :(
Comment #5
jhedstromThat's the easiest way to make testbot go green =)
Comment #6
dawehnerDoes anyone mind to update why?
Comment #7
jhedstromre: #6 I think this comment from #1 is still relevant:
Comment #9
jhedstromSo
BrokenSetupTest
relies onTestBase::$originalFileDirectory
, so switching that back to protected.Comment #10
Mile23Applies cleanly to 8.1.x.
As a review: There are plenty of $original* properties which must have been added since the last time this issue was addressed.
$originalContainer
stands out. :-)Comment #12
zuhair_akChanged all the $original* variables to private except TestBase::$originalFileDirectory ref #9.
Comment #14
zuhair_akI was naive enought to think that this patch will pass the test :| . Can someone point me in the direction where additional changes had to be made to make it work. I had forgotten to add the interdiff.txt above and have added now.
Comment #15
Revathi.B CreditAttribution: Revathi.B commentedComment #24
quietone CreditAttribution: quietone as a volunteer commentedTriaging issues in simpletest.module as part of the Bug Smash Initiative to determine if they should be in the Simpletest Project or core.
This looks like it a Phpunit issue, changing component.