diff --git a/tests/Unit/FlowviewConfigArraysTest.php b/tests/Unit/FlowviewConfigArraysTest.php new file mode 100644 index 0000000..5f5eeb9 --- /dev/null +++ b/tests/Unit/FlowviewConfigArraysTest.php @@ -0,0 +1,36 @@ + array()); +}); + +it('adds the FlowView menu entries under Import/Export', function () { + global $menu; + + flowview_config_arrays(); + + expect($menu)->toHaveKey('FlowView'); + expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_devices.php'); + expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_filters.php'); + expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_schedules.php'); + expect($menu['FlowView'])->toHaveKey('plugins/flowview/flowview_databases.php'); +}); diff --git a/tests/Unit/FlowviewLifecycleTest.php b/tests/Unit/FlowviewLifecycleTest.php new file mode 100644 index 0000000..7127fe7 --- /dev/null +++ b/tests/Unit/FlowviewLifecycleTest.php @@ -0,0 +1,43 @@ +toBeFalse(); + expect($GLOBALS['__test_messages'])->not->toBeEmpty(); + expect($GLOBALS['__test_messages'][0][0])->toBe('flowview_info'); +}); + +it('always reports no upgrade pending', function () { + expect(plugin_flowview_upgrade())->toBeFalse(); +}); + +it('skips the upgrade check on pages that do not need it', function () { + plugin_flowview_check_upgrade(); + + expect($GLOBALS['__test_db_calls'])->toBeEmpty(); +}); diff --git a/tests/Unit/FlowviewNavigationTest.php b/tests/Unit/FlowviewNavigationTest.php new file mode 100644 index 0000000..d55a768 --- /dev/null +++ b/tests/Unit/FlowviewNavigationTest.php @@ -0,0 +1,26 @@ + array('title' => 'Other'))); + + expect($nav)->toHaveKey('other.php:'); + + foreach (array('flowview.php:', 'flowview.php:view', 'flowview_devices.php:', 'flowview_schedules.php:', 'flowview_filters.php:') as $key) { + expect($nav)->toHaveKey($key); + } + + expect($nav['flowview_devices.php:edit']['mapping'])->toBe('index.php:,flowview_devices.php:'); +}); diff --git a/tests/Unit/FlowviewVersionTest.php b/tests/Unit/FlowviewVersionTest.php new file mode 100644 index 0000000..b9b1fea --- /dev/null +++ b/tests/Unit/FlowviewVersionTest.php @@ -0,0 +1,23 @@ +toBeArray(); + expect($info)->toHaveKey('name'); + expect($info)->toHaveKey('version'); + expect($info['name'])->toBe('flowview'); +}); diff --git a/tests/bootstrap-unit.php b/tests/bootstrap-unit.php index 43f03fa..1e2414b 100644 --- a/tests/bootstrap-unit.php +++ b/tests/bootstrap-unit.php @@ -213,6 +213,37 @@ function api_plugin_db_add_column($plugin, $table, $data) { if (!function_exists('api_plugin_db_table_create')) { function api_plugin_db_table_create($plugin, $table, $data) { + $GLOBALS['__test_db_calls'][] = array('fn' => 'api_plugin_db_table_create', 'sql' => $table, 'params' => $data); + return true; + } +} + +$GLOBALS['__test_registered_hooks'] = array(); + +if (!function_exists('api_plugin_register_hook')) { + function api_plugin_register_hook($plugin, $hook, $function, $file, $subtype = '') { + $GLOBALS['__test_registered_hooks'][] = array( + 'name' => $plugin, + 'hook' => $hook, + 'function' => $function, + 'file' => $file, + ); + + return true; + } +} + +$GLOBALS['__test_registered_realms'] = array(); + +if (!function_exists('api_plugin_register_realm')) { + function api_plugin_register_realm($plugin, $file, $description, $enabled) { + $GLOBALS['__test_registered_realms'][] = array( + 'name' => $plugin, + 'file' => $file, + 'description' => $description, + 'enabled' => $enabled, + ); + return true; } }