- 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
36 lines
825 B
PHP
36 lines
825 B
PHP
--TEST--
|
|
getCachedMarkdown / setCachedMarkdown: store and retrieve rendered HTML by file key
|
|
--FILE--
|
|
<?php
|
|
require '/var/www/app/cache.php';
|
|
|
|
$dir = sys_get_temp_dir() . '/phpt_mdcache_' . getmypid();
|
|
mkdir($dir);
|
|
$file = "$dir/post.md";
|
|
file_put_contents($file, '# Hello');
|
|
|
|
// Nothing cached yet
|
|
echo (getCachedMarkdown($file) ?? 'null') . "\n";
|
|
|
|
// Store and retrieve
|
|
setCachedMarkdown($file, '<h1>Hello</h1>');
|
|
echo getCachedMarkdown($file) . "\n";
|
|
|
|
// langPrefix produces a separate cache entry
|
|
echo (getCachedMarkdown($file, '/fr') ?? 'null') . "\n";
|
|
|
|
setCachedMarkdown($file, '<h1>Bonjour</h1>', '/fr');
|
|
echo getCachedMarkdown($file, '/fr') . "\n";
|
|
|
|
// Default key is unaffected
|
|
echo getCachedMarkdown($file) . "\n";
|
|
|
|
unlink($file);
|
|
rmdir($dir);
|
|
?>
|
|
--EXPECT--
|
|
null
|
|
<h1>Hello</h1>
|
|
null
|
|
<h1>Bonjour</h1>
|
|
<h1>Hello</h1>
|