Skip to content

Tests: Optimize WP_Test_REST_Attachments_Controller fixtures - #13619

Draft
SainathPoojary wants to merge 1 commit into
WordPress:trunkfrom
SainathPoojary:fix/66074-attachment-permissions
Draft

SainathPoojary wants to merge 1 commit into
WordPress:trunkfrom
SainathPoojary:fix/66074-attachment-permissions

Conversation

@SainathPoojary

Copy link
Copy Markdown

Optimizes fixture setup in WP_Test_REST_Attachments_Controller by avoiding unnecessary image processing in tests that do not check generated image sizes.

Three permission tests previously uploaded JPEG files and generated intermediate image sizes before asserting that the REST request was rejected. The permission callback returns the expected error before image editing begins, so these tests now create attachment records directly with the required MIME type, status, and file path.

The EXIF orientation test still uploads and edits a real image, but it only checks the full-size image dimensions after rotation. It now skips intermediate image size generation while preserving the real upload, EXIF correction, rotation, and all assertions.

All 200 tests and 1,159 assertions remain unchanged and pass.

Performance

Measured locally across three consecutive runs comparing trunk to this branch:

Run Trunk Test Time (junit.xml) Trunk Wall Time Fix Test Time (junit.xml) Fix Wall Time
Run 1 8.337s 9.176s 6.950s 7.777s
Run 2 8.178s 9.020s 6.904s 7.739s
Run 3 8.466s 9.314s 7.166s 7.984s
Average 8.327s 9.170s 7.007s 7.833s

Trac ticket: https://core.trac.wordpress.org/ticket/66074

Use of AI Tools

AI assistance: Yes
Tool(s): Github Copilot
Used for: Edge-case checks and assistance with the PR description, implementation and testing were done and reviewed by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant