Skip to content

Tests: Use assertNotSame() for admin bar profile URL comparisons. - #14853

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

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

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Part of: #64895

What

Replaces the remaining assertNotEquals() calls in tests/phpunit/tests/adminbar.php with assertNotSame() for profile URL comparisons.

Updated methods:

  • test_admin_bar_contains_correct_links_for_users_with_no_role(): assertNotEquals → assertNotSame
  • test_admin_bar_contains_correct_links_for_users_with_no_role_on_network(): assertNotEquals → assertNotSame

Why

These comparisons are URL strings (get_admin_url() / user_admin_url() vs admin_url()), so assertNotSame() is appropriate. Same approach as [r63632] / [r64079].

How

  • Convert the two profile URL inequality checks 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 Tests_AdminBar
  3. For the multisite cases: npm run test:php -- --group ms-required --filter Tests_AdminBar

Use of AI tools

Cursor

Part of #64895: these comparisons are URL strings, 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

Both comparisons use URL strings, so strict inequality preserves the intended checks without identified correctness issues.

No open issues 🎉

What changed in this PR

This PR updates two admin bar tests to use strict inequality assertions for profile URL strings. No production code changes are included.

Changes:

  • Replace two assertNotEquals() calls with assertNotSame().
  • Leave all other assertions unchanged.
File Description
tests/​phpunit/​tests/​adminbar.php Use strict inequality for two profile URL comparisons.

Review effort: Balanced

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

Both comparisons use URL strings, so the replacements preserve the intended checks without 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 changed comparisons use profile URL strings, and the surrounding assertions still verify the admin bar destinations. The multisite run exercised the changed cases.

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

@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Oct 27, 2026
Use `assertNotSame()` for profile URL comparisons in multisite admin bar tests. Preserve the checks that users without a role on the current site receive links to the appropriate profile screen.

Developed in: #14853

Props shailu25.
See #64895.


git-svn-id: https://develop.svn.wordpress.org/trunk@64781 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 27, 2026
Use `assertNotSame()` for profile URL comparisons in multisite admin bar tests. Preserve the checks that users without a role on the current site receive links to the appropriate profile screen.

Developed in: WordPress/wordpress-develop#14853

Props shailu25.
See #64895.

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


git-svn-id: http://core.svn.wordpress.org/trunk@63931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@shail-mehta
shail-mehta deleted the tests/assert-not-same-adminbar-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.

3 participants