Commit Graph
2 Commits
Author SHA1 Message Date
Divarion_D 52d801acb2 test: dual-backend TestDb (SQLite + MariaDB) + skip-on-panel guards
TestDb can now run the DB-touching unit tests against a real MariaDB as
well as the default in-memory SQLite, so the suite can be exercised on
the panel host (which ships pdo_mysql, not pdo_sqlite). When
XCVM_TEST_DB_DSN is set it connects there and translates the SQLite test
DDL on the fly: AUTOINCREMENT -> AUTO_INCREMENT, a bare INTEGER PRIMARY
KEY gains AUTO_INCREMENT, and each CREATE TABLE is preceded by DROP TABLE
IF EXISTS (a MariaDB schema persists across the per-test connections that
:memory: starts fresh). DDL is routed through exec() on both backends so
the ModuleMigrator path (which runs DDL via query()) works too, and the
MySQL session uses a permissive sql_mode to match SQLite's leniency.
AuthRepositoryTest back-quotes the reserved column `key`.

Three env-fragile guards are tagged #[Group('skip-on-panel')] so the
deployed-panel run can exclude them (--exclude-group skip-on-panel):
ArchitectureTest and StreamTokenCallSitesTest scan the repo src/ tree
(absent / polluted in a flat deploy; they also self-skip when it is
missing), and LoginSessionFixationTest runs in isolated child processes
that the panel's ionCube/OPcache PHP cannot reconstitute.

Verified green on all three backends: SQLite (local, 721), MariaDB 11.4
(container, 721), and the panel's bundled PHP 8.1 + server MariaDB
(713, with the group excluded).
2026-09-13 21:17:06 +03:00
Divarion_D 6964e99f35 test(core): cover the DB layer — ModuleMigrator, SettingsRepository, AuthRepository
Fifth coverage batch, all driven against the in-memory SQLite TestDb:

- ModuleMigratorTest: install runs master database.sql (or falls back to
  replaying deltas <= target when there is none); up() applies only the
  (from, to] range ascending; uninstall runs database_drop.sql or no-ops; has()
  and discover() semver rules (non-semver files ignored, comments stripped);
  and failure propagation from a bad statement.
- SettingsRepositoryTest: getAll() JSON/CSV field normalisation (allow_countries,
  allowed_stb_types lowercase/trim/blank-drop, bouquet_name spaces, api_ips,
  shared_mount_prefixes incl. the legacy-CSV self-heal) and empty-list collapse.
  Points CACHE_TMP_PATH at a temp dir for the trailing FileCache write.
- AuthRepositoryTest: access-code and HMAC-key reads (getAllCodes with/without
  type filter, getCodeById, getCurrentCode via XC_CODE, getAllHMAC, getHMACById)
  and deleteHMAC existing/missing. getGroupPermissions (JSON_CONTAINS) and
  deleteCode (nginx config regen) are left for integration.

+20 tests. Suite: 678 tests, 0 errors.
2026-09-13 14:51:45 +03:00