Skip to content

Tests: Use assertIsCallable() for callable assertions. - #13017

Open
rootzero00 wants to merge 2 commits into
WordPress:trunkfrom
rootzero00:test/65819-callable-assertions-193824cc
Open

Tests: Use assertIsCallable() for callable assertions.#13017
rootzero00 wants to merge 2 commits into
WordPress:trunkfrom
rootzero00:test/65819-callable-assertions-193824cc

Conversation

@rootzero00

@rootzero00 rootzero00 commented Aug 12, 2026

Copy link
Copy Markdown

Replaces eight generic assertTrue( is_callable() ) assertions with
PHPUnit's dedicated assertIsCallable() assertion in:

  • tests/phpunit/tests/customize/widgets.php
  • tests/phpunit/tests/multisite/wpCacheSwitchToBlogFallback.php

This is a test-only cleanup and does not change WordPress runtime behavior.

The multisite assertions were added as a review-driven follow-up after the
same pattern was identified in Tests_Multisite_WpCacheSwitchToBlogFallback.

Trac ticket: https://core.trac.wordpress.org/ticket/65819

Testing

  • npm run test:php -- --filter Tests_WP_Customize_Widgets --colors=never --do-not-cache-result

    • PASS: 28 tests, 410 assertions
  • npm run test:php -- -c tests/phpunit/multisite.xml --filter Tests_Multisite_WpCacheSwitchToBlogFallback::test_wp_cache_switch_to_blog_function_exists --colors=never --do-not-cache-result

    • PASS: 1 test, 4 assertions
  • npm run test:php -- -c tests/phpunit/multisite.xml --filter Tests_Multisite_WpCacheSwitchToBlogFallback --colors=never --do-not-cache-result

    • PASS: 25 tests, 136 assertions
  • npm run env:composer -- lint tests/phpunit/tests/multisite/wpCacheSwitchToBlogFallback.php

    • PASS

Fresh upstream verification confirmed that neither changed test file has
changed upstream since the candidate parent.

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT
Model(s): GPT-5.6 Sol
Used for: Investigation support, contribution workflow and validation
planning, and drafting assistance. The change was reviewed, understood,
signed, and tested by me.


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.

Replaces generic `assertTrue( is_callable() )` assertions in the Customize widgets tests with the dedicated PHPUnit assertion.

See #65819.
@github-actions

github-actions Bot commented Aug 12, 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 raulsalvat, soean.

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

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@Soean

Soean commented Aug 12, 2026

Copy link
Copy Markdown
Member

We have the same pattern in Tests_Multisite_WpCacheSwitchToBlogFallback:

$this->assertTrue( is_callable( 'wp_cache_switch_to_blog' ) );
$this->assertTrue( is_callable( 'wp_cache_switch_to_blog_fallback' ) );

Replaces generic `assertTrue( is_callable() )` assertions with PHPUnit's
dedicated callable assertion in the multisite cache fallback tests.

See #65819.
@rootzero00 rootzero00 changed the title Customize: Use assertIsCallable() for callable assertions. Tests: Use assertIsCallable() for callable assertions. Aug 12, 2026
@rootzero00

Copy link
Copy Markdown
Author

Thanks — I've added those two occurrences in
Tests_Multisite_WpCacheSwitchToBlogFallback as a focused follow-up.

The additional change is limited to that one file (+2/-2), replacing the
two assertTrue( is_callable() ) assertions with assertIsCallable().

Fresh validation passes:

  • targeted multisite method: 1 test, 4 assertions
  • full multisite class: 25 tests, 136 assertions
  • existing Customize class: 28 tests, 410 assertions
  • PHP coding standards: PASS

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.

2 participants