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
This commit is contained in:
parent
33943a907b
commit
449e6f8e03
22 changed files with 909 additions and 7 deletions
59
devel/tests/plugins/plugin_manager.phpt
Normal file
59
devel/tests/plugins/plugin_manager.phpt
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
--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
|
||||
Loading…
Add table
Add a link
Reference in a new issue