| 2026-06-03 |
Переписан механизм определения offline: last_contact-based вместо TCP ping + retry для сканера
...
CronController::status_update_scanning():
- Устройства помечаются lost по таймауту last_contact (device_offline_threshold, default 300s)
- TCP ping fallback удалён — больше не даёт ложных active
- Сканер теперь нужен только для восстановления lost и обновления IP при роуминге
- Добавлен createDeviceScanner() для тестируемости
DeviceScanner:
- BATCH_SIZE 32 -> 8 (меньше коллизий на WiFi)
- Таймаут 1s -> 2s
- Пауза 200мс между батчами
- Retry с 500мс backoff для failed IPs
EventsController::new_event():
- Восстанавливает connection_status = active при входящем событии
DevicesRESTAPIController::device_status():
- Больше не помечает lost при временном сетевом сбое
Config:
- Добавлен device_offline_threshold (env DEVICE_OFFLINE_THRESHOLD)
Тесты: 6 новых тестов CronController, 145 tests/345 assertions — все green
Eugene Sukhodolskiy
committed
2 days ago
|

Fix Model layer & API robustness batch (7 items)
...
- Entity::update() now checks rowCount; returns false when no rows affected.
- Entity::update() preserves modified_fields on PDOException (try/catch).
- Device::set_device_token() caches auth() call instead of 3 repeated invocations.
- User::__construct() removed eager profile query; profile() now lazy-loads via get_pet_instance().
- alias_is_uniq() in Areas and Devices models accepts optional exclude_id to skip self on update.
- Controllers updated to pass entity id to alias_is_uniq() so updating alias to current value succeeds.
- CronController::run_regular_cron_scripts() wraps each script in try/catch; logs failure and continues.
- App::api_auth_guard() replaced exit() with return false; EventsHandlers stops routing on auth rejection.
- Tests added: EntityCrud (missing-record + preserved-fields), UserEntity (lazy-loading),
CronController (failure-continuation), AppAuthGuard (structured 401 output),
Areas/Devices validation (same-alias update allowed).
- Test bootstrap: added logs_enable/logs_folder to FCONF to suppress PHP warnings in Cron tests.
All 136 server tests pass, 334 assertions.
All 167 Vue client tests pass.
Eugene Sukhodolskiy
committed
2 days ago
|
Add high-complexity PHPUnit tests: retry/backoff, auth guard, transactions, happy-paths, script state
...
- Refactor Base.php: extract executeCurl/getCurlInfo for mockability
- Refactor App.php: split api_auth_guard into check_api_auth (testable) + guard wrapper
- Refactor Devices.php: add optional ?Base DI to connect_new_device
- Update TestApp.php: add control_scripts_instances for script tests
- Update bootstrap.php: define PHPUNIT_TEST to skip new App() autoload side-effect
New test files:
- DeviceAPIBaseRetryTest (7 tests) — retry/backoff with mock cURL
- AppAuthGuardTest (7 tests) — auth + rate limiter without exit
- DevicesModelTransactionTest (4 tests) — happy path, rollback, mode checks
- AreasControllerHappyPathTest (7 tests) — full area CRUD success flows
- ScriptsModelStateTest (8 tests) — scope list, script state, enable/disable
Total: 113 tests, 285 assertions — all passing.
Eugene Sukhodolskiy
committed
2 days ago
|
Add medium-complexity PHPUnit tests: Area recursion, controller validation
...
- AreaRecursionTest (10 tests): recursive traversal, depth limit ≤10,
remove() cascade, inner devices/scripts lookup, parent_area()
- AreasRESTAPIControllerValidationTest (10 tests): new_area, update_alias,
remove_area, place_in_area, update_display_name validation
- DevicesRESTAPIControllerValidationTest (12 tests): setup_new_device,
do_device_action, update_alias, devices_list, place_in_area validation
- ScriptsRESTAPIControllerValidationTest (10 tests): run_action_script,
set_*_state, place_in_area validation
- Fix Controller::validate_positive_int_ids() return type: ?array → ?string
- Add DevTools to TestApp/bootstrap for Model instantiation
- Expand bootstrap.php text_msgs with controller error aliases
- Update server-audit.md coverage table: 80 tests, 202 assertions
Eugene Sukhodolskiy
committed
2 days ago
|
Add PHPUnit coverage: Entity CRUD, Area placing, Sessions, Utils
...
- EntityCrudTest: 6 tests covering update, get, remove, id, to_array
- AreaPlacingTest: 2 tests for place_in_area and place_in_area_id
- SessionsTest: 4 tests for create, get_by_token, close, status
- UtilsTest: 7 tests for response_error/success, table_row_is_exists,
generate_token, dayname_translate, fast_ping_tcp
- TestApp helper + bootstrap init with SQLite :memory: for app() dependencies
- Update server-audit.md: 36 total tests, expand coverage roadmap
Eugene Sukhodolskiy
committed
2 days ago
|
Add PHPUnit test suite: ThinBuilder, RateLimiter, PasswordHash (17 tests, all passing)
Eugene Sukhodolskiy
committed
2 days ago
|