toHaveCount(3); }); it('normalizes an out-of-range monitor_refresh setting to 300', function () { $GLOBALS['__test_config_options']['monitor_refresh'] = '9999'; expect(plugin_monitor_check_config())->toBeTrue(); expect($GLOBALS['__test_config_options']['monitor_refresh'])->toBe('300'); }); it('leaves a valid monitor_refresh setting untouched', function () { $GLOBALS['__test_config_options']['monitor_refresh'] = '60'; plugin_monitor_check_config(); expect($GLOBALS['__test_config_options']['monitor_refresh'])->toBe('60'); }); it('reports that no upgrade is pending', function () { expect(plugin_monitor_upgrade())->toBeFalse(); }); it('skips the version check on pages that do not need it', function () { $_SERVER['PHP_SELF'] = '/graphs.php'; monitor_check_upgrade(); expect($GLOBALS['__test_db_calls'])->toBeEmpty(); }); it('updates the stored plugin_config version when it drifts', function () { monitor_test_mock_db('db_fetch_cell_prepared', 'plugin_config', '0.0.0'); monitor_check_upgrade(); $sql = implode("\n", array_column($GLOBALS['__test_db_calls'], 'sql')); expect($sql)->toContain('ALTER TABLE host'); }); it('launches the poller with a php fallback when no binary is configured', function () { $GLOBALS['config']['poller_id'] = 1; $GLOBALS['__test_exec_calls'] = array(); monitor_poller_bottom(); expect($GLOBALS['__test_exec_calls'])->not->toBeEmpty(); expect($GLOBALS['__test_exec_calls'][0]['command'])->toBe('php'); });