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
49
devel/tests/helpers/extract_title.phpt
Normal file
49
devel/tests/helpers/extract_title.phpt
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
--TEST--
|
||||
extractTitle: extracts title from # heading in .md or <h1> in .html
|
||||
--FILE--
|
||||
<?php
|
||||
require '/var/www/app/constants.php';
|
||||
require '/var/www/app/hooks.php';
|
||||
require '/var/www/app/content.php';
|
||||
require '/var/www/app/helpers.php';
|
||||
|
||||
$dir = sys_get_temp_dir() . '/phpt_title_' . getmypid();
|
||||
mkdir($dir);
|
||||
|
||||
// No content files
|
||||
echo (extractTitle($dir) ?? 'null') . "\n";
|
||||
|
||||
// Markdown with # heading
|
||||
file_put_contents("$dir/index.md", "# My Great Post\n\nSome body text.");
|
||||
echo extractTitle($dir) . "\n";
|
||||
unlink("$dir/index.md");
|
||||
|
||||
// Markdown heading with extra whitespace
|
||||
file_put_contents("$dir/index.md", "# Spaced Title \n\nBody.");
|
||||
echo extractTitle($dir) . "\n";
|
||||
unlink("$dir/index.md");
|
||||
|
||||
// HTML with <h1>
|
||||
file_put_contents("$dir/index.html", "<h1>HTML Title</h1><p>Body</p>");
|
||||
echo extractTitle($dir) . "\n";
|
||||
unlink("$dir/index.html");
|
||||
|
||||
// HTML with attributes on h1
|
||||
file_put_contents("$dir/index.html", '<h1 class="main">Styled Title</h1>');
|
||||
echo extractTitle($dir) . "\n";
|
||||
unlink("$dir/index.html");
|
||||
|
||||
// Markdown without heading
|
||||
file_put_contents("$dir/index.md", "Just a paragraph, no heading.");
|
||||
echo (extractTitle($dir) ?? 'null') . "\n";
|
||||
unlink("$dir/index.md");
|
||||
|
||||
rmdir($dir);
|
||||
?>
|
||||
--EXPECT--
|
||||
null
|
||||
My Great Post
|
||||
Spaced Title
|
||||
HTML Title
|
||||
Styled Title
|
||||
null
|
||||
Loading…
Add table
Add a link
Reference in a new issue