Use composer metadata as primary source for version and ping build
All checks were successful
CI/CD Pipeline / deploy (push) Successful in 23s
CI/CD Pipeline / promote_stable (push) Successful in 2s

This commit is contained in:
2026-02-24 23:26:30 +01:00
parent 78bdd869ef
commit 8e86fcdbd9
4 changed files with 64 additions and 16 deletions

View File

@@ -1,9 +1,8 @@
<?php
use App\Models\Setting;
it('returns ping status with build and notification state', function (): void {
Setting::updateOrCreate(['key' => 'build'], ['value' => '1337']);
$composer = json_decode((string) file_get_contents(base_path('composer.json')), true);
$expectedBuild = isset($composer['build']) ? (int) $composer['build'] : null;
$response = $this->getJson('/ping');
@@ -11,7 +10,7 @@ it('returns ping status with build and notification state', function (): void {
$response->assertJson([
'connect' => 'ok',
'version_status' => [
'build' => 1337,
'build' => $expectedBuild,
],
'notification_state' => false,
]);

View File

@@ -1,16 +1,15 @@
<?php
use App\Models\Setting;
it('returns version and build info', function (): void {
Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']);
Setting::updateOrCreate(['key' => 'build'], ['value' => '42']);
it('returns version and build info from composer metadata', function (): void {
$composer = json_decode((string) file_get_contents(base_path('composer.json')), true);
$expectedVersion = (string) ($composer['version'] ?? '');
$expectedBuild = isset($composer['build']) ? (int) $composer['build'] : null;
$response = $this->getJson('/api/version');
$response->assertOk();
$response->assertJsonFragment([
'version' => '1.2.3',
'build' => 42,
'version' => $expectedVersion,
'build' => $expectedBuild,
]);
});