Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions tests/backend/Api/V1/ApiV1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Lwt\Tests\Api\V1;

use Lwt\Api\V1\ApiV1;
use Lwt\Shared\Infrastructure\ApplicationInfo;
use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Container\Container;
use Lwt\Shared\Infrastructure\Container\CoreServiceProvider;
Expand Down Expand Up @@ -137,21 +138,44 @@ public function testConstructorAcceptsContainer(): void
}

/**
* Test VERSION constant exists.
* The `version` endpoint must source its version from ApplicationInfo
* (the single source of truth), not a local constant that drifts.
*
* Regression guard: ApiV1 used to carry a hardcoded `VERSION = "3.0.2"`
* that was never bumped, so the API misreported the version through 3.1.x
* and 3.2.0. It now reads from ApplicationInfo and strips the `-fork`
* suffix to serve bare semver to clients.
*/
public function testVersionConstantExists(): void
public function testVersionSourcedFromApplicationInfo(): void
{
// ApiV1 must not reintroduce its own version constant.
$reflection = new \ReflectionClass(ApiV1::class);
$this->assertTrue($reflection->hasConstant('VERSION'));
$this->assertFalse(
$reflection->hasConstant('VERSION'),
'ApiV1 should source its version from ApplicationInfo, not a local constant'
);

// The value the endpoint serves is bare semver (X.Y.Z, no "-fork").
$apiVersion = \explode('-', ApplicationInfo::getRawVersion())[0];
$this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $apiVersion);
}

/**
* Test RELEASE_DATE constant exists.
* The `version` endpoint must source its release date from ApplicationInfo,
* not a local constant.
*/
public function testReleaseDateConstantExists(): void
public function testReleaseDateSourcedFromApplicationInfo(): void
{
$reflection = new \ReflectionClass(ApiV1::class);
$this->assertTrue($reflection->hasConstant('RELEASE_DATE'));
$this->assertFalse(
$reflection->hasConstant('RELEASE_DATE'),
'ApiV1 should source its release date from ApplicationInfo, not a local constant'
);

$this->assertMatchesRegularExpression(
'/^\d{4}-\d{2}-\d{2}$/',
ApplicationInfo::getReleaseDate()
);
}

/**
Expand Down