Skip to content

test: recorded contract fixtures to catch API/model drift - #67

Merged
justpilot merged 1 commit into
4.xfrom
test/4x-contract-fixtures
Oct 25, 2026
Merged

justpilot merged 1 commit into
4.xfrom
test/4x-contract-fixtures

Conversation

@justpilot

Copy link
Copy Markdown
Owner

Summary

  • Recorder tools/record-fixtures.php (composer fixtures:record): read-only GETs against the sandbox (one list with per_page=3 per resource, one single GET where data exists, plus sub-resources of the first entry). Hard cap of 150 requests; the full run took 72. Anonymizes names, companies, e-mails, phone numbers, addresses, bank data, tax/VAT ids, URLs, free texts, file contents and the Billomat ID with deterministic placeholders in the same format; types, enums, amounts, dates and ids stay unchanged. --cache=DIR reuses raw responses (outside the repo).
  • Fixtures: 72 files under tests/Fixtures/Contract/<resource>/<list|get>.json (51 resources).
  • ContractFixturesTest (unit suite, no network): runs every fixture through the real *Api method and fails on unknown fields (non-empty $extra, recursively; for handwritten models: fields toArray() doesn't export) and on non-empty values lost during hydration (unknown enum values, unparsable dates, unknown payment_types entries). Accepted differences live in KNOWN_DRIFT; stale entries fail the test.
  • Docs: docs/testing.md (re-recording, what is anonymized), CHANGELOG.

Drift found

  • client-property-values / supplier-property-values are returned with every client/supplier but weren't mapped -> added to the codegen definitions as Client::$propertyValues / Supplier::$propertyValues (composer generate).
  • Role (handwritten) ignored created/updated -> added.
  • User.rights (permission map like Role::$permissions) stays in User::$extra for now: the generator has no map type yet. Documented in KNOWN_DRIFT.

No unknown enum values were found in the recorded data. The sandbox has no offers, credit notes, reminders, letters, recurrings, incomings, articles or inbox documents, so those only have an (empty) list.json; re-record once the sandbox has data.

Checks

composer lint, analyse, refactor:dry, generate:check, test (3102 tests) and mutate on the diff (15/15 killed, 100 % MSI) pass locally.

Add tools/record-fixtures.php (composer fixtures:record), which records
read-only GET responses from the Billomat sandbox, anonymizes personal
data with deterministic placeholders and stores them under
tests/Fixtures/Contract/. ContractFixturesTest feeds every fixture through
the real *Api method and fails on unknown fields or values lost during
hydration (e.g. unknown enum values).

Drift found and fixed: Client/Supplier now map the client-property-values
and supplier-property-values Billomat returns, Role maps created/updated.
User.rights stays a documented known drift.
@justpilot
justpilot force-pushed the test/4x-contract-fixtures branch from 0baa44c to db04aad Compare October 25, 2026 18:08
@justpilot
justpilot merged commit bf46926 into 4.x Oct 25, 2026
8 checks passed
@justpilot
justpilot deleted the test/4x-contract-fixtures branch October 25, 2026 18:10
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.

1 participant