Tests: Use assertTrue()/assertFalse() instead of assertSame() with boolean values.#12511
Tests: Use assertTrue()/assertFalse() instead of assertSame() with boolean values.#12511Soean wants to merge 2 commits into
assertTrue()/assertFalse() instead of assertSame() with boolean values.#12511Conversation
…ith boolean values. Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Pull request overview
This PR updates WordPress core PHPUnit tests to use PHPUnit’s dedicated boolean assertions (assertTrue()/assertFalse()) instead of assertSame() when asserting boolean outcomes, improving readability and (per PR description) producing clearer failure messages.
Changes:
- Replaced
assertSame( true, … )withassertTrue( … )in REST API and Interactivity API tests. - Replaced
assertSame( false, … )withassertFalse( … )in REST API and block type variation callback tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/phpunit/tests/rest-api/wpRestMenusController.php | Uses assertTrue() for the auto_add boolean assertion in the menus REST controller test. |
| tests/phpunit/tests/rest-api/rest-post-meta-fields.php | Uses assertFalse() for the authenticated boolean meta assertion in a REST post meta test. |
| tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php | Uses assertTrue() for boolean handling assertions when binding attribute values. |
| tests/phpunit/tests/blocks/wpBlockType.php | Uses assertTrue()/assertFalse() for $callback_called boolean assertions in block variation callback tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
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.