[wp-trac] [WordPress Trac] #63532: Unit Testing: Checking if images already exists before starting tests
WordPress Trac
noreply at wordpress.org
Wed Jun 4 23:04:35 UTC 2025
#63532: Unit Testing: Checking if images already exists before starting tests
--------------------------+---------------------------------------
Reporter: SirLouen | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Keywords: has-test-info needs-patch
Focuses: tests |
--------------------------+---------------------------------------
I've noticed that if for any reason, during testing, a file like `test-
image-large.jpg` is created in the `/wp-
content/uploads/<current_year>/<current_month>`, every additional run of
`test_wp_get_attachment_image_should_use_wp_get_attachment_metadata` will
simply fail (and start creating new files like `test-image-large-1.jpg`,
`test-image-large-2.jpg`, etc., failing permanently)
I was doing some unit testing for another function with dependencies on
media, and I started seeing this function failing and I could not see
where it was coming until I managed to find the culprit
== Reproduction Instructions
1. Create a file called `test-image-large.jpg` in the directory: `/wp-
content/uploads/<current_year>/<current_month>/`
For example: if you are testing in June 2025, then it will be:
`/wp-content/uploads/2025/06/test-image-large.jpg`
2. Run the Unit tests for media:
`npm run test:php -- --group media`
3. Check if it throws any errors.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63532>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list