Skip to content

test(api): fix stale ApiV1 version/release-date assertions#245

Merged
HugoFara merged 1 commit into
mainfrom
fix/apiv1-version-test
Jun 30, 2026
Merged

test(api): fix stale ApiV1 version/release-date assertions#245
HugoFara merged 1 commit into
mainfrom
fix/apiv1-version-test

Conversation

@HugoFara

Copy link
Copy Markdown
Owner

Problem

ApiV1Test::testVersionConstantExists and testReleaseDateConstantExists assert that ApiV1::VERSION / ApiV1::RELEASE_DATE still exist:

$this->assertTrue($reflection->hasConstant('VERSION'));

Those local constants were removed in 48d418dc1 ("fix(api): source /api/v1/version from ApplicationInfo"), which fixed the API silently reporting a stale "3.0.2" through 3.1.x/3.2.0 by reading from ApplicationInfo (the single source of truth) instead. The tests were never updated, so they assert a contract that no longer holds.

Why it slipped through

ApiV1Test::setUp() constructs new ApiV1() and has a DB-skip guard, so the entire class is skipped in unit CI (which runs without MySQL). The two assertions therefore stayed green on CI and never blocked the 3.2.1 release — but they fail in any run with a test database present (local dev, composer test:integration). I hit them while running the full suite during #244.

Fix

Rewrite the two tests to assert the actual post-48d418dc1 contract:

  • ApiV1 no longer carries a drift-prone local version constant (hasConstant(...) is now expected false — a regression guard against re-introducing a hardcoded version), and
  • the values the /version endpoint serves come from ApplicationInfo in the API's promised shape — bare semver X.Y.Z (no -fork) and an ISO YYYY-MM-DD date.

Test-only change; no production code touched.

Verification

  • ./vendor/bin/phpcs --standard=PSR12 — 0
  • ./vendor/bin/psalm --threads=1 — 0
  • composer test:no-coverage with a local test DB — 0 failures (previously 2); the two rewritten tests now actually execute and pass (OK (9 tests, 41 assertions) for ApiV1Test).

…constants

`ApiV1Test::testVersionConstantExists` / `testReleaseDateConstantExists`
asserted that `ApiV1::VERSION` / `ApiV1::RELEASE_DATE` still exist. Those local
constants were removed when the `/version` endpoint was switched to source from
`ApplicationInfo` (the single source of truth, commit 48d418d) — the
hardcoded `VERSION = "3.0.2"` had silently misreported the API version through
3.1.x and 3.2.0.

The tests skip in unit CI (no MySQL → `ApiV1Test::setUp()` skips the whole
class), so they stayed green on CI and never blocked a release — but they fail
in any run with a test database present (local / integration).

Rewrite them to assert the real contract: ApiV1 no longer carries a
drift-prone version constant, and the values the endpoint serves come from
`ApplicationInfo` in the API's promised shape (bare semver `X.Y.Z` / ISO date).

Gates: phpcs PSR12 (0), psalm --threads=1 (0), full phpunit — 0 failures
(previously 2 with a DB present).
@HugoFara HugoFara merged commit 8f2a344 into main Jun 30, 2026
14 checks passed
@HugoFara HugoFara deleted the fix/apiv1-version-test branch June 30, 2026 22:13
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