Skip to content

Tests: Use assertNotSame() for attachment JS URL comparison. - #14854

Closed
shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/assert-not-same-media-64895
Closed

shail-mehta wants to merge 1 commit into
WordPress:trunkfrom
shail-mehta:tests/assert-not-same-media-64895

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

Part of: #64895

What

Replaces the remaining assertNotEquals() call in tests/phpunit/tests/media.php with assertNotSame() for the prepared attachment URL check.

Updated method:

  • test_wp_prepare_attachment_for_js(): assertNotEquals( '', $prepped['url'] ) → assertNotSame( '', $prepped['url'] )

Why

#64895 asks for strict assertions when both sides share a type. The prepared attachment url is a string, so assertNotSame() is appropriate.

How

  • Convert the empty-string URL inequality check from assertNotEquals() to assertNotSame()
  • Leave other assertions in the file unchanged

Testing instructions

  1. Start the local WordPress develop environment.
  2. Run: npm run test:php -- --filter test_wp_prepare_attachment_for_js

Use of AI tools

Cursor

Part of #64895: the prepared attachment URL is a string, so strict inequality is appropriate.

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

The one-line change matches the URL’s string contract and preserves the intended non-empty check.

No open issues 🎉

What changed in this PR

Updates the attachment URL test to use a strict assertion, supporting the assertion cleanup in WordPress ticket #64895.

Changes:

  • Replaces assertNotEquals() with assertNotSame() for the empty-string URL comparison.
  • Leaves all other assertions unchanged.
File Description
tests/​phpunit/​tests/​media.php Uses strict inequality for the prepared attachment URL check.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 26, 2026 16:42
@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 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.

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

The narrow assertion change matches the string-valued URL contract and introduces no identified correctness issues.

No open issues 🎉

Review effort: Balanced

@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 prepared URL passes through esc_url_raw(), so the empty-string comparison preserves the existing check for this attachment fixture.

Unit-tests audit completed. Combined randomized runs passed: single-site 497 tests / 1,609 assertions; multisite 521 tests / 1,694 assertions, with one skip in each run. PHPCS and CI passed. Copilot has no open findings.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Oct 27, 2026
Use `assertNotSame()` when checking that `wp_prepare_attachment_for_js()` supplies a non-empty URL for an attachment without media.

Developed in: #14854

Props shailu25.
See #64895.


git-svn-id: https://develop.svn.wordpress.org/trunk@64782 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 27, 2026
Use `assertNotSame()` when checking that `wp_prepare_attachment_for_js()` supplies a non-empty URL for an attachment without media.

Developed in: WordPress/wordpress-develop#14854

Props shailu25.
See #64895.

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


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

Copy link
Copy Markdown
Member

Committed at r64782

@shail-mehta
shail-mehta deleted the tests/assert-not-same-media-64895 branch October 28, 2026 06:35
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.

4 participants