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
45
devel/tests/helpers/extract_meta_description.phpt
Normal file
45
devel/tests/helpers/extract_meta_description.phpt
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
--TEST--
|
||||
extractMetaDescription: returns description from metadata fields or first content paragraph
|
||||
--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_metadesc_' . getmypid();
|
||||
mkdir($dir);
|
||||
|
||||
// search_description takes priority
|
||||
echo extractMetaDescription($dir, ['search_description' => 'SEO description', 'summary' => 'Summary']) . "\n";
|
||||
|
||||
// summary is fallback when no search_description
|
||||
echo extractMetaDescription($dir, ['summary' => 'Page summary']) . "\n";
|
||||
|
||||
// null metadata, no content files
|
||||
echo (extractMetaDescription($dir, null) ?? 'null') . "\n";
|
||||
|
||||
// First paragraph from markdown (skips headings and short lines)
|
||||
file_put_contents("$dir/index.md", "# Title\n\nThis is the opening paragraph of the post.\n\nSecond paragraph.");
|
||||
echo extractMetaDescription($dir, null) . "\n";
|
||||
unlink("$dir/index.md");
|
||||
|
||||
// Heading-only markdown with no usable paragraph
|
||||
file_put_contents("$dir/index.md", "# Just a Heading\n\nShort.\n");
|
||||
echo (extractMetaDescription($dir, null) ?? 'null') . "\n";
|
||||
unlink("$dir/index.md");
|
||||
|
||||
// First <p> from HTML
|
||||
file_put_contents("$dir/index.html", "<h1>Title</h1><p>HTML paragraph text here.</p>");
|
||||
echo extractMetaDescription($dir, null) . "\n";
|
||||
unlink("$dir/index.html");
|
||||
|
||||
rmdir($dir);
|
||||
?>
|
||||
--EXPECT--
|
||||
SEO description
|
||||
Page summary
|
||||
null
|
||||
This is the opening paragraph of the post.
|
||||
null
|
||||
HTML paragraph text here.
|
||||
Loading…
Add table
Add a link
Reference in a new issue