Skip to content

Tests: Add unit tests for timer_float() - #14484

Open
shail-mehta wants to merge 4 commits into
WordPress:trunkfrom
shail-mehta:65819-add-timer-float-tests
Open

shail-mehta wants to merge 4 commits into
WordPress:trunkfrom
shail-mehta:65819-add-timer-float-tests

Conversation

@shail-mehta

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

Copy link
Copy Markdown
Member

What

See Trac Ticket: #65819.

Adds unit tests for timer_float().

Why

This helper had no dedicated coverage.

How

Covers float elapsed time from REQUEST_TIME_FLOAT and that successive calls increase.

Testing

  • npm run test:php -- --filter Tests_Load_TimerFloat
  • npm run test:php -- --filter Tests_Load_TimerFloat --order-by=random
  • vendor/bin/phpcs tests/phpunit/tests/load/timerFloat.php

AI Tools

Cursor

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.

🟡 Changes recommended

The assertions accept absolute timestamps, leaving the elapsed-time subtraction unverified.

1 open issue
What changed in this PR

Adds dedicated PHPUnit coverage for WordPress’s timer_float() helper, addressing Trac #65819.

Changes:

  • Tests the elapsed-time return value and increase between calls.
  • Preserves and restores REQUEST_TIME_FLOAT between tests.
File Description
tests/​phpunit/​tests/​load/​load/​timerFloat.php Adds two timer tests and request-time cleanup.

Review effort: Balanced

Comment thread tests/phpunit/tests/load/load/timerFloat.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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 focused tests cover the intended behavior, restore shared state, and have no identified blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 19, 2026 09:35
@github-actions

github-actions Bot commented Oct 19, 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 shailu25, mukesh27.

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

@mukeshpanchal27 mukeshpanchal27 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 tests look correct. One problem with the file location.

*
* @covers ::timer_float
*/
class Tests_Load_TimerFloat extends WP_UnitTestCase {

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 path has load twice: tests/phpunit/tests/load/load/timerFloat.php. Could the file move to tests/phpunit/tests/load/timerFloat.php, next to the other load.php tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved in test file in load folder.

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

Static review found no blocking issues in these focused tests; tests were not executed.

No open issues 🎉

Review effort: Balanced

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