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:
Ruben 2026-03-17 12:51:07 +01:00
parent 33943a907b
commit 449e6f8e03
22 changed files with 909 additions and 7 deletions

View file

@ -0,0 +1,54 @@
--TEST--
Context: set/get/has and magic property access for plugin data storage
--FILE--
<?php
require '/var/www/app/context.php';
$templates = new Templates(base: '/tmp/b.php', page: '/tmp/p.php', list: '/tmp/l.php');
$ctx = new Context(
contentDir: '/tmp/content',
templates: $templates,
requestPath: 'blog/post',
hasTrailingSlash: true
);
// Public readonly properties
echo $ctx->requestPath . "\n";
echo $ctx->contentDir . "\n";
echo ($ctx->hasTrailingSlash ? 'true' : 'false') . "\n";
// set/get/has
$ctx->set('langPrefix', '/fr');
echo $ctx->get('langPrefix') . "\n";
echo ($ctx->has('langPrefix') ? 'yes' : 'no') . "\n";
echo ($ctx->has('missing') ? 'yes' : 'no') . "\n";
// get with default
echo $ctx->get('nope', 'fallback') . "\n";
// Magic __get / __set
$ctx->customKey = 'magic-value';
echo $ctx->customKey . "\n";
// Magic __get for undefined key returns null
echo ($ctx->undefined ?? 'null') . "\n";
// set and magic access are the same store
$ctx->set('shared', 'data');
echo $ctx->shared . "\n";
$ctx->magic2 = 'x';
echo $ctx->get('magic2') . "\n";
?>
--EXPECT--
blog/post
/tmp/content
true
/fr
yes
no
fallback
magic-value
null
data
x