mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-03 04:02:10 +02:00
WebApiBootstrap now reuses DatabaseStage + LegacyCoreStage for the "connect, wire
the domain services, run initCore, reconnect if the settings cache is incomplete"
step, so that logic has a single source of truth shared with the main kernel.
The web-API-specific parts stay inline because they are order-sensitive and not
container-based: the prelude split around the ini_set defaults, RequestGuard
(flood/host/PHP_ERRORS/Logger from the file cache), and the $gitRelease global.
The redundant explicit require_once of LegacyInitializer/DatabaseHandler/
GitHubReleases is dropped — those autoload. The endpoint cache list is now a
class constant.
Adds BootContext::WebApi (with a BootKernel::defaults arm for match
exhaustiveness) as the state's context; WebApi builds its own two-stage pipeline
rather than going through BootKernel, so no container context/options are set —
preserving the previous behaviour exactly.
Verified in a php+MariaDB dev container: WebApiBootstrap::init('api') populates
$db/$gitRelease/$rSettings, defines PHP_ERRORS/SERVER_ID, and the booted handle
queries the DB.
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
use XcVm\Core\Enum\ServerEnvironment;
|
|
use XcVm\Core\Enum\BootContext;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @covers BootContext
|
|
* @covers ServerEnvironment
|
|
*/
|
|
final class CoreEnumTest extends TestCase {
|
|
|
|
public function testBootContextValues() {
|
|
$this->assertSame('minimal', BootContext::Minimal->value);
|
|
$this->assertSame('cli', BootContext::Cli->value);
|
|
$this->assertSame('stream', BootContext::Stream->value);
|
|
$this->assertSame('admin', BootContext::Admin->value);
|
|
$this->assertSame('webapi', BootContext::WebApi->value);
|
|
}
|
|
|
|
public function testBootContextFromString() {
|
|
$this->assertSame(BootContext::Admin, BootContext::from('admin'));
|
|
$this->assertNull(BootContext::tryFrom('nope'));
|
|
$this->assertCount(5, BootContext::cases());
|
|
}
|
|
|
|
public function testServerEnvironmentValues() {
|
|
$this->assertSame('main', ServerEnvironment::Main->value);
|
|
$this->assertSame('lb', ServerEnvironment::LoadBalancer->value);
|
|
}
|
|
|
|
public function testServerEnvironmentFromString() {
|
|
$this->assertSame(ServerEnvironment::LoadBalancer, ServerEnvironment::from('lb'));
|
|
$this->assertNull(ServerEnvironment::tryFrom('xxx'));
|
|
$this->assertCount(2, ServerEnvironment::cases());
|
|
}
|
|
}
|