folderweb/devel/tests/plugins/plugin_manager.phpt
Ruben 449e6f8e03 Update framework testing infrastructure and standards
- Add phpt test runner and suite for app functions
- Introduce testing workflow to AGENT.md
- Add tests for cache, content, context, helpers, hooks, plugins,
  rendering
- Mount tests directory in dev container
2026-03-17 12:51:07 +01:00

59 lines
1.6 KiB
PHP

--TEST--
PluginManager: tracks loaded plugins, deduplicate loads, respects scope
--FILE--
<?php
require '/var/www/app/hooks.php';
require '/var/www/app/context.php';
require '/var/www/app/plugins.php';
$pm = new PluginManager();
// Initially empty
echo count($pm->getLoadedPlugins()) . "\n";
echo count($pm->getGlobalPlugins()) . "\n";
echo ($pm->isLoaded('languages') ? 'yes' : 'no') . "\n";
echo ($pm->getPluginInfo('languages') ?? 'null') . "\n";
// loadPagePlugins with null — no-op
$pm->loadPagePlugins(null);
echo count($pm->getLoadedPlugins()) . "\n";
// loadPagePlugins with no plugins key — no-op
$pm->loadPagePlugins(['title' => 'My Page']);
echo count($pm->getLoadedPlugins()) . "\n";
// loadGlobalPlugins with no enabled key — no-op
$pm->loadGlobalPlugins(['other' => 'stuff']);
echo count($pm->getLoadedPlugins()) . "\n";
// Load the built-in languages plugin via global config
$pm->loadGlobalPlugins(['plugins' => ['enabled' => 'languages']]);
echo ($pm->isLoaded('languages') ? 'yes' : 'no') . "\n";
echo count($pm->getGlobalPlugins()) . "\n";
echo in_array('languages', $pm->getGlobalPlugins()) ? 'in global' : 'not in global';
echo "\n";
// Loading again is a no-op (deduplication)
$pm->loadGlobalPlugins(['plugins' => ['enabled' => 'languages']]);
echo count($pm->getLoadedPlugins()) . "\n";
// getPluginInfo returns path and scope
$info = $pm->getPluginInfo('languages');
echo ($info['scope'] === 'global' ? 'scope ok' : 'scope wrong') . "\n";
echo (str_ends_with($info['path'], 'languages.php') ? 'path ok' : 'path wrong') . "\n";
?>
--EXPECT--
0
0
no
null
0
0
0
yes
1
in global
1
scope ok
path ok