[wp-trac] [WordPress Trac] #63532: Unit Testing: Checking if images already exists before starting tests

WordPress Trac noreply at wordpress.org
Fri Aug 22 02:33:29 UTC 2025


#63532: Unit Testing: Checking if images already exists before starting tests
-------------------------------------------------+-------------------------
 Reporter:  SirLouen                             |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.9
Component:  Media                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests has-test-   |     Focuses:  tests
  info dev-feedback                              |
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 Replying to [comment:9 johnbillion]:
 > What's the cause of a pre-existing image existing in the first place?
 Does that happen if you cancel the command while the tests are running and
 before it's had a chance to clean up? I remember that happening in the
 past, eg. #51735.

 One cause can be that the Docker environment included in WordPress-Develop
 shares the uploads directory for both the installation and the test suite.
 If a developer uploads `tests/phpunit/data/images/canola.jpg` for some
 manual testing and then runs the test suite, the image will exist.

 Replying to [comment:6 SergeyBiryukov]:
 > I think a safer approach would perhaps be to delete the pre-existing
 file, otherwise there might be a collision if a test expects an attachment
 with the same name but different data.

 In the case of a collision due to manual testing, this may cause problems
 for the developer using the environment as their test images will be
 deleted from the development environment.

 ----

 For the test suite, could we filter the uploads path and URL to use `wp-
 content/test-suite-uploads/` as a disposable location for attachment
 tests? That would allow the test suite to delete the directory each time
 it's started to avoid the issue?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63532#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list