Skip to content

Tests: Add unit coverage for wp_exif_date2ts() - #15423

Open
shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/65819-cover-wp-exif-date2ts
Open

shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/65819-cover-wp-exif-date2ts

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Trac ticket: #66476

What

Adds a dedicated PHPUnit class for wp_exif_date2ts(), covering Exif Y:m:d H:i:s conversion to a unix timestamp and surrounding whitespace trimming.

Test-only; no production code changes.

Why

wp_exif_date2ts() had no direct @covers coverage. It is used when reading image EXIF created_timestamp metadata. Small helper coverage fits the #65819 test cleanup track.

How

Add tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php with @covers ::wp_exif_date2ts, using a data provider for a valid Exif datetime and a whitespace-trimmed input.

Testing Instructions

docker compose up -d mysql
docker compose run --rm php ./vendor/bin/phpunit --filter Tests_Admin_Includes_Image_WpExifDate2ts

Expected: OK (2 tests, 2 assertions).

Use of AI Tools

  • Cursor

Cover Exif Y:m:d H:i:s conversion to a unix timestamp.

See #65819.
@shail-mehta
shail-mehta force-pushed the tests/65819-cover-wp-exif-date2ts branch from 876740a to bf7d828 Compare November 3, 2026 16:40

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

No active review issues were identified in this test-only change.

No open issues 🎉

What changed in this PR

Adds direct PHPUnit coverage for wp_exif_date2ts(), the helper used to convert EXIF dates into image creation timestamps, as part of the #65819 test cleanup. No production code changes.

Changes:

  • Adds a dedicated test class with @covers ::wp_exif_date2ts.
  • Tests valid EXIF datetime conversion and surrounding whitespace trimming through two data-provider cases.
File Description
tests/​phpunit/​tests/​admin/​includes/​image/​wpExifDate2ts.php Adds two test cases for EXIF date conversion and whitespace handling.

Review effort: Balanced

Cover Exif Y:m:d H:i:s conversion to a unix timestamp.

See #65819.

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 date-conversion test lacks a whitespace-padded data-provider case, leaving the documented whitespace-trimming behavior untested.

1 open issue

Review effort: Balanced

Refactor test to accept input from data provider for Exif datetime conversion.

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

No active review issues are recorded for the added EXIF datetime conversion and whitespace-trimming tests.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review November 3, 2026 17:13
@github-actions

github-actions Bot commented Nov 3, 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.

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

Props shailu25, lancewillett.

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.

@lancewillett

Copy link
Copy Markdown
Member

Thanks, @shail-mehta. Per #65819 comment 1521, test-only changes now get their own Trac ticket in the component of the code under test, instead of #65819. That now includes open PRs like this one.

Could you open a new ticket for this change (likely Media)? Please add the has-patch and has-unit-tests keywords, and update the Trac link in this PR's description. I will review it under the new ticket.

AI review · claude-opus-5-5

@shail-mehta

Copy link
Copy Markdown
Member Author

Created Ticket: #66476

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