Skip to content

Tests: Use create_upload_object() in getAvailablePostMimeTypes tests - #15994

Closed
shail-mehta wants to merge 2 commits into
WordPress:trunkfrom
shail-mehta:tests/42990-create-upload-object-mime-types
Closed

shail-mehta wants to merge 2 commits into
WordPress:trunkfrom
shail-mehta:tests/42990-create-upload-object-mime-types

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Part of : #42990

What?

Switch the remaining easy _make_attachment() callers in tests/phpunit/tests/post/getAvailablePostMimeTypes.php to self::factory()->attachment->create_upload_object().

Why?

Use create_upload_object() consistently before deprecating WP_UnitTestCase::_make_attachment().

These two calls only uploaded via wp_upload_bits(), asserted $upload['error'], then called _make_attachment() — the same pattern already converted in the earlier PRs.

How?

  • Replaced JPEG and PDF upload + _make_attachment() setup with create_upload_object().
  • Dropped the two assertEmpty( $upload['error'] ) guards that went away with $upload.
  • Left harder callers untouched (attachments.php uses $upload['file'] / empty GUID; template.php needs $upload['url']; wpAjaxCropImage.php builds the upload array by hand).

Testing Instructions

  1. npm run env:start
  2. npm run test:php -- --filter Tests_Post_GetAvailablePostMimeTypes
  3. Repeat with -c tests/phpunit/multisite.xml and with --order-by=random.

Use of AI Tools

  • Cursor

Follow-up to [65522] and [65523]. See #42990.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the attachment-factory test setup change.

No open issues 🎉

What changed in this PR

This PR standardizes attachment setup in the get_available_post_mime_types() tests ahead of deprecating WP_UnitTestCase::_make_attachment().

Changes:

  • Replaces manual JPEG and PDF uploads with create_upload_object().
  • Removes upload-error assertions tied to the deleted $upload setup while preserving the MIME-type assertions.
File Description
tests/​phpunit/​tests/​post/​getAvailablePostMimeTypes.php Uses the attachment factory to simplify JPEG and PDF test setup.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review November 14, 2026 14:20
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shailu25.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@shail-mehta shail-mehta self-assigned this Nov 16, 2026

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The factory uses the same upload and attachment-creation path, while the test keeps its exact MIME-list assertion. This removes duplicated fixture code without adding tests. Randomized single-site and multisite checks and PHPCS passed; the existing skip is also present on the baseline.

AI review · gpt-6

@lancewillett lancewillett moved this from Backlog to In review in WordPress Project Build Tooling Nov 17, 2026
wporg-sync pushed a commit that referenced this pull request Nov 17, 2026
Replace duplicated upload and attachment setup with `create_upload_object()` in MIME type, template, and AJAX crop tests. Remove the unused custom-logo URL fixture.

Follow-up to r65522, r65523.

Developed in: #15994, #15995, #15998

Props shailu25, huzaifaalmesbah, desrosj.
See #42990.


git-svn-id: https://develop.svn.wordpress.org/trunk@65562 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 17, 2026
Replace duplicated upload and attachment setup with `create_upload_object()` in MIME type, template, and AJAX crop tests. Remove the unused custom-logo URL fixture.

Follow-up to r65522, r65523.

Developed in: WordPress/wordpress-develop#15994, WordPress/wordpress-develop#15995, WordPress/wordpress-develop#15998

Props shailu25, huzaifaalmesbah, desrosj.
See #42990.

Built from https://develop.svn.wordpress.org/trunk@65562


git-svn-id: http://core.svn.wordpress.org/trunk@64635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@lancewillett

Copy link
Copy Markdown
Member

arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
Replace duplicated upload and attachment setup with `create_upload_object()` in MIME type, template, and AJAX crop tests. Remove the unused custom-logo URL fixture.

Follow-up to r65522, r65523.

Developed in: WordPress#15994, WordPress#15995, WordPress#15998

Props shailu25, huzaifaalmesbah, desrosj.
See #42990.


git-svn-id: https://develop.svn.wordpress.org/trunk@65562 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants