Skip to content

fix(php): strip .000 milliseconds from WireMock datetime query params#13450

Merged
iamnamananand996 merged 1 commit intomainfrom
devin/1773328085-php-wiremock-datetime-fix
Mar 12, 2026
Merged

fix(php): strip .000 milliseconds from WireMock datetime query params#13450
iamnamananand996 merged 1 commit intomainfrom
devin/1773328085-php-wiremock-datetime-fix

Conversation

@iamnamananand996
Copy link
Copy Markdown
Contributor

Description

Refs: getbrevo/brevo-php#109

Fixes a datetime format mismatch between WireMock stubs and PHP SDK serialization that causes wire tests to fail. The shared mock-utils package generates datetime query parameter values using Date.toISOString() (e.g., 2022-01-02T00:00:00.000Z), but PHP's DateTimeInterface::RFC3339 format omits fractional seconds (e.g., 2022-01-02T00:00:00Z). Since WireMock's equalTo is an exact-match comparator, stubs for endpoints with datetime query parameters never fire.

Link to Devin Session
Requested by: @iamnamananand996

Changes Made

  • Added stripDatetimeMilliseconds static method to WireTestSetupGenerator that strips .000 from datetime-formatted query parameter values in WireMock stub mappings before writing wiremock-mappings.json
  • Follows the same approach already used by the Python SDK generator (generators/python-v2/sdk/src/wire-tests/WireTestSetupGenerator.ts)
  • Bumped PHP SDK version to 2.1.12

Testing

  • Unit tests added/updated — no unit tests were added for the new method; the approach mirrors the Python generator's proven pattern
  • Lint/type checks pass (pnpm run check)

Review Checklist

  • Only query parameters are handled — if datetime values also appear as path parameters in WireMock equalTo matchers, those would still mismatch. Verify this is sufficient for the reported issue.
  • Regex only matches .000 — non-zero fractional seconds (e.g., .500Z) are intentionally left untouched. This is correct since PHP's RFC3339 drops all fractional seconds, but would still cause a mismatch if the IR contains datetimes with non-zero millis. Unlikely in practice since autogenerated examples typically use round seconds.
  • No changes to shared mock-utils — the fix is scoped to the PHP generator's post-processing step, avoiding impact on other generators.

PHP's DateTimeInterface::RFC3339 format omits fractional seconds
(e.g., 2022-01-02T00:00:00Z) while mock-utils generates datetime
values with milliseconds via Date.toISOString() (e.g.,
2022-01-02T00:00:00.000Z). Since WireMock's equalTo matcher is
exact-match, the stubs never fired for endpoints with datetime
query parameters.

This follows the same approach used by the Python generator.
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Copy Markdown
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI
  • Postman

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

@iamnamananand996 iamnamananand996 merged commit c899223 into main Mar 12, 2026
87 of 88 checks passed
@iamnamananand996 iamnamananand996 deleted the devin/1773328085-php-wiremock-datetime-fix branch March 12, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants