Problem/Motivation
Currently \Drupal\Tests\file\Kernel\FileSaveUploadTest::setUp() creates a file to test uploads using \file_put_contents('test.bbb', 'test');
This creates a left over file test.bbb in the app root when tests are done.
Steps to reproduce
Proposed resolution
Write the file to the OS temporary directory instead.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3455183
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
Comment #3
kim.pepperComment #4
mstrelan commentedThis was also spotted in #3445847: PHPUnit 10 behaves differently when invoked outside web root and I added a tearDown method to remove the created file. We can remove that tearDown method now in this issue.
Comment #5
mstrelan commentedAh cross-post, disregard #4.
Comment #6
smustgrave commentedSeems like a good refactor.
Comment #7
mondrakeIt’s a Kernel test, why not using vfs instead?
Comment #10
xjmDefinitely much better.
Committed to 11.x and 11.0.x. There's a merge conflict on cherry-pick to 10.4.x, so we would need a different backport version.
Thanks!
Comment #13
pooja_sharma commentedPorted the changes to 10.4.x, PLease review MR 9371
Comment #14
smustgrave commentedProbably missed 10.4 but could do 10.5
Comment #16
smustgrave commentedPretty clean backport
Comment #19
alexpottSeems fair enough to backport to 10.5.x.
Committed and pushed 76c2d39afb4 to 10.6.x and 8ee22c46ac4 to 10.5.x. Thanks!
I think this is a bug. Tests should not leave files around.