mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-03 12:02:29 +02:00
Second coverage batch — config, request state and the XML parser: - SettingsManagerTest: set/getAll roundtrip, update, and the typed getters. Locks the deliberate split on a present-null value (get()/getArray() fall back via ?? while getBool/getInt/getString cast), and getBool()'s PHP truthiness. - DomainResolverTest: the non-proxied resolve() path — forced vs kept protocol, https on :443, Host-header port stripping, and the domain_name / server_ip fallbacks. Captures a latent bug: an https:// prefix in domain_name yields 'https:host' because '/' is stripped before 'https://' in the str_replace order (documented in the test so a fix updates it deliberately). - RequestManagerTest: same store shape as SettingsManager, with has() on isset semantics (present-null reads as absent). - XmlStringStreamerTest: end-to-end StringWalker (depth-2 children) and UniqueNode (named element) parsing over an in-memory stream, empty document, the File "missing path" and UniqueNode "missing option" error paths. +26 tests. Suite: 634 tests, 0 errors.
48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
use XcVm\Core\Http\RequestManager;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* RequestManager — the process-global store of parsed request params, set once
|
|
* by LegacyInitializer and read across legacy code. Mirrors SettingsManager but
|
|
* its has() uses isset() semantics (a present-null key reads as absent), which
|
|
* is the whole reason it exists (isset() can't wrap a get() call).
|
|
*/
|
|
final class RequestManagerTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
RequestManager::set([]);
|
|
}
|
|
|
|
protected function tearDown(): void {
|
|
RequestManager::set([]);
|
|
}
|
|
|
|
public function testSetGetAllRoundtrips(): void {
|
|
RequestManager::set(['action' => 'save', 'id' => '7']);
|
|
$this->assertSame(['action' => 'save', 'id' => '7'], RequestManager::getAll());
|
|
}
|
|
|
|
public function testGetReturnsValueOrDefault(): void {
|
|
RequestManager::set(['action' => 'save']);
|
|
$this->assertSame('save', RequestManager::get('action'));
|
|
$this->assertNull(RequestManager::get('missing'));
|
|
$this->assertSame('def', RequestManager::get('missing', 'def'));
|
|
}
|
|
|
|
public function testUpdateSetsASingleKey(): void {
|
|
RequestManager::set(['keep' => '1']);
|
|
RequestManager::update('added', 'x');
|
|
$this->assertSame('x', RequestManager::get('added'));
|
|
$this->assertSame('1', RequestManager::get('keep'));
|
|
}
|
|
|
|
public function testHasUsesIssetSemantics(): void {
|
|
RequestManager::set(['set' => 'v', 'nullish' => null]);
|
|
$this->assertTrue(RequestManager::has('set'));
|
|
$this->assertFalse(RequestManager::has('nullish'), 'present-null reads as absent (isset)');
|
|
$this->assertFalse(RequestManager::has('missing'));
|
|
}
|
|
}
|