- 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
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
--TEST--
|
|
renderContentFile: renders .html by inclusion and .md via Parsedown
|
|
--FILE--
|
|
<?php
|
|
require '/var/www/app/context.php';
|
|
require '/var/www/app/hooks.php';
|
|
require '/var/www/app/rendering.php';
|
|
|
|
$dir = sys_get_temp_dir() . '/phpt_render_' . getmypid();
|
|
mkdir($dir);
|
|
|
|
// HTML file — returned as-is (direct inclusion)
|
|
$htmlFile = "$dir/page.html";
|
|
file_put_contents($htmlFile, '<p>Hello <strong>world</strong></p>');
|
|
echo trim(renderContentFile($htmlFile)) . "\n";
|
|
|
|
// Markdown — converted to HTML by Parsedown
|
|
$mdFile = "$dir/post.md";
|
|
file_put_contents($mdFile, "# My Title\n\nA paragraph.");
|
|
$html = renderContentFile($mdFile);
|
|
echo (str_contains($html, '<h1>My Title</h1>') ? 'h1 ok' : 'h1 missing') . "\n";
|
|
echo (str_contains($html, '<p>A paragraph.</p>') ? 'p ok' : 'p missing') . "\n";
|
|
|
|
// Unknown extension — returns empty string
|
|
$txtFile = "$dir/notes.txt";
|
|
file_put_contents($txtFile, 'raw text');
|
|
echo (renderContentFile($txtFile) === '') ? 'empty ok' : 'not empty';
|
|
echo "\n";
|
|
|
|
unlink($htmlFile);
|
|
unlink($mdFile);
|
|
unlink($txtFile);
|
|
rmdir($dir);
|
|
?>
|
|
--EXPECT--
|
|
<p>Hello <strong>world</strong></p>
|
|
h1 ok
|
|
p ok
|
|
empty ok
|