Skip to content

Build/Test Tools: Ensure strict assertion in comment dir - #13601

Closed
3kori wants to merge 4 commits into
WordPress:trunkfrom
3kori:test/64895-change-assertions-in-comment-redo
Closed

3kori wants to merge 4 commits into
WordPress:trunkfrom
3kori:test/64895-change-assertions-in-comment-redo

Conversation

@3kori

@3kori 3kori commented Sep 18, 2026

Copy link
Copy Markdown
  • In comment/commentsTemplate.php
    Changed assertEquals to assertSame because the expected and actual values produce identical arrays.

  • In comment/pingback.php
    Tests_Comment_Pingback::test_pingback - Changed assertEquals to assertSame because the expected and actual values produce identical arrays.

    Tests_Comment_Pingback::test_pingback_no_ping_back & Tests_Comment_Pingback::test_pingback_error_response - Changed assertEquals to assertSame because the expected and actual values produce empty arrays.

  • In comment/query.php
    Test_Comment_Query::test_get_comments_for_post - Changed assertEquals to assertSame and cast the expected value ($post_id) from an integer to a string because the WP_Comment::comment_post_ID is a numeric string.

    Test_Comment_Query::test_orderby_meta - Changed assertEquals to assertSame and cast the expected value ($comment_id) from an integer to a string because the WP_Comment::comment_ID is a numeric string.

    Test_Comment_Query::test_get_comments_by_user - Changed assertEquals to assertSame and cast the expected value ($users) from an integer to a string because the WP_Comment::user_id is a numeric string.

    Test_Comment_Query::test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC and Test_Comment_Query::test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC - Changed assertEquals to assertSame and cast the expected array value ($comments) from an integer to a string because the WP_Comment::comment_ID is a numeric string.

    Test_Comment_Query::test_comment_query_object - Kept assertEquals because the expected and actual output give different object instances but the same values.

Trac ticket: #64895

Use of AI Tools

N/A

Note

This is a redo of #13593 because of mishaps on my end.


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.

@github-actions

github-actions Bot commented Sep 18, 2026

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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props r1k0, lancewillett, mukesh27.

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

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.

Copilot review overview

🟢 Approval recommended

Only a minor wording nit remains; no blocking issues were identified.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This pull request tightens comment-related PHPUnit assertions by using strict comparisons and matching expected value types.

Changes:

  • Replaces loose assertions with assertSame().
  • Casts numeric database IDs to strings where required.
  • Retains value-based comparison for distinct object instances.
File Description
tests/​phpunit/​tests/​comment/​query.php Tightens comment query assertions and expected ID types; one minor wording nit noted.
tests/​phpunit/​tests/​comment/​pingback.php Tightens pingback result assertions.
tests/​phpunit/​tests/​comment/​commentsTemplate.php Tightens the offset assertion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/phpunit/tests/comment/query.php Outdated
$this->assertNotEmpty( $query2->comments );

/*
* Keep assertEquals() because the different objects instances
@lancewillett

Copy link
Copy Markdown
Member

Changes look good. I fixed a minor wording issue raised by Copilot in b2dbaf1

@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Sep 21, 2026
Compare comment query IDs as strings and use strict assertions for pagination offsets and pingback results. Explain why comment object arrays retain value-based comparison.

Developed in: #13601

Props r1k0, mukesh27.
See #64895.


git-svn-id: https://develop.svn.wordpress.org/trunk@63774 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 21, 2026
Compare comment query IDs as strings and use strict assertions for pagination offsets and pingback results. Explain why comment object arrays retain value-based comparison.

Developed in: WordPress/wordpress-develop#13601

Props r1k0, mukesh27.
See #64895.

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


git-svn-id: http://core.svn.wordpress.org/trunk@62946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.

4 participants