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
38
devel/tests/hooks/hooks_add_apply.phpt
Normal file
38
devel/tests/hooks/hooks_add_apply.phpt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--
|
||||
Hooks: apply passes value through, add registers filters that chain in order
|
||||
--FILE--
|
||||
<?php
|
||||
require '/var/www/app/hooks.php';
|
||||
|
||||
// No filters registered — passthrough
|
||||
echo Hooks::apply(Hook::PROCESS_CONTENT, 'hello') . "\n";
|
||||
echo Hooks::apply(Hook::TEMPLATE_VARS, 'foo') . "\n";
|
||||
|
||||
// Register a filter
|
||||
Hooks::add(Hook::PROCESS_CONTENT, fn($v) => strtoupper($v));
|
||||
echo Hooks::apply(Hook::PROCESS_CONTENT, 'hello') . "\n";
|
||||
|
||||
// Filters chain: second receives output of first
|
||||
Hooks::add(Hook::PROCESS_CONTENT, fn($v) => $v . '!');
|
||||
echo Hooks::apply(Hook::PROCESS_CONTENT, 'hello') . "\n";
|
||||
|
||||
// Other hooks are unaffected
|
||||
echo Hooks::apply(Hook::TEMPLATE_VARS, 'foo') . "\n";
|
||||
|
||||
// Extra args are passed through to each filter
|
||||
Hooks::add(Hook::TEMPLATE_VARS, fn($v, $extra) => "$v:$extra");
|
||||
echo Hooks::apply(Hook::TEMPLATE_VARS, 'x', 'ctx') . "\n";
|
||||
|
||||
// Non-string values pass through too
|
||||
$arr = ['a' => 1];
|
||||
echo Hooks::apply(Hook::CONTEXT_READY, $arr) === $arr ? 'array passthrough' : 'fail';
|
||||
echo "\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
hello
|
||||
foo
|
||||
HELLO
|
||||
HELLO!
|
||||
foo
|
||||
x:ctx
|
||||
array passthrough
|
||||
Loading…
Add table
Add a link
Reference in a new issue