mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-03 12:02:29 +02:00
Move the 17 global lookup arrays from resources/data/admin_constants.php into PSR-4 classes and enums, eliminating the last big pile of `global` reference data. New XcVm\Core\Reference\* (const + static accessors, FfmpegBinaries-style): GeoReference, LocaleReference, DeviceReference, UiReference, PermissionReference, StatusBadge. New XcVm\Core\Enum\* (backed enums with label()/options(), ModuleState-style): Theme (int), ResellerAction and ClientFilter (string). All consumers migrated off `global $rX` / `$GLOBALS['rX']` and the BaseAdminController extract bridge: TableController, DashboardController, SearchAjaxController, SettingsController, ResellerAPI and ResellerLoginController call the classes directly, and 21 view templates import them via `use`. The extract whitelist entries, the bootstrap require and admin_constants.php itself are removed. Fixes a latent bug: TableController read $rClientFilters without a `global`, so the client-request log showed raw status codes instead of labels; ClientFilter::labelFor() now resolves them. The reference classes and the three new enums are excluded from the load-balancer build (all consumers are already MAIN-only). Adds unit tests for the enums, StatusBadge and the reference data.
49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|
|
|
use XcVm\Core\Reference\GeoReference;
|
|
use XcVm\Core\Reference\LocaleReference;
|
|
use XcVm\Core\Reference\DeviceReference;
|
|
use XcVm\Core\Reference\UiReference;
|
|
use XcVm\Core\Reference\PermissionReference;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ReferenceDataTest extends TestCase {
|
|
|
|
public function testGeoCountryCodes(): void {
|
|
$this->assertSame('United States of America', GeoReference::countryCodes()['US']);
|
|
$this->assertSame('Germany', GeoReference::countryCodes()['DE']);
|
|
}
|
|
|
|
public function testGeoCountriesLeadingOffBucket(): void {
|
|
$first = GeoReference::countries()[0];
|
|
$this->assertSame(['id' => '', 'name' => 'Off'], $first);
|
|
}
|
|
|
|
public function testGeoCountriesFilterMap(): void {
|
|
$this->assertSame('All Countries', GeoReference::geoCountries()['ALL']);
|
|
}
|
|
|
|
public function testTmdbLanguages(): void {
|
|
$this->assertSame('Default - EN', LocaleReference::tmdbLanguages()['']);
|
|
$this->assertSame('English', LocaleReference::tmdbLanguages()['en']);
|
|
}
|
|
|
|
public function testMagModels(): void {
|
|
$models = DeviceReference::magModels();
|
|
$this->assertContains('MAG250', $models);
|
|
$this->assertNotEmpty($models);
|
|
}
|
|
|
|
public function testHues(): void {
|
|
$this->assertSame('Default', UiReference::hues()['']);
|
|
$this->assertSame('Blue', UiReference::hues()['primary']);
|
|
}
|
|
|
|
public function testPermissionKeysAreUniqueAndNonEmpty(): void {
|
|
$keys = PermissionReference::keys();
|
|
$this->assertNotEmpty($keys);
|
|
$this->assertSame($keys, array_values(array_unique($keys)));
|
|
$this->assertContains('settings', $keys);
|
|
}
|
|
}
|