test(api): fix stale ApiV1 version/release-date assertions#245
Merged
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ApiV1Test::testVersionConstantExistsandtestReleaseDateConstantExistsassert thatApiV1::VERSION/ApiV1::RELEASE_DATEstill exist: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 fromApplicationInfo(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()constructsnew 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-
48d418dc1contract:hasConstant(...)is now expected false — a regression guard against re-introducing a hardcoded version), and/versionendpoint serves come fromApplicationInfoin the API's promised shape — bare semverX.Y.Z(no-fork) and an ISOYYYY-MM-DDdate.Test-only change; no production code touched.
Verification
./vendor/bin/phpcs --standard=PSR12— 0./vendor/bin/psalm --threads=1— 0composer test:no-coveragewith a local test DB — 0 failures (previously 2); the two rewritten tests now actually execute and pass (OK (9 tests, 41 assertions)forApiV1Test).