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
48
devel/tests/content/resolve_slug_to_folder.phpt
Normal file
48
devel/tests/content/resolve_slug_to_folder.phpt
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
--TEST--
|
||||
resolveSlugToFolder: resolves URL slug to actual folder name, supports metadata slug override
|
||||
--FILE--
|
||||
<?php
|
||||
require '/var/www/app/hooks.php';
|
||||
require '/var/www/app/content.php';
|
||||
|
||||
$parent = sys_get_temp_dir() . '/phpt_slug_' . getmypid();
|
||||
mkdir($parent);
|
||||
|
||||
// Non-existent parent directory
|
||||
echo (resolveSlugToFolder($parent . '/nope', 'anything') ?? 'null') . "\n";
|
||||
|
||||
// Folder name matches slug directly
|
||||
mkdir("$parent/my-post");
|
||||
echo resolveSlugToFolder($parent, 'my-post') . "\n";
|
||||
|
||||
// Slug not found
|
||||
echo (resolveSlugToFolder($parent, 'missing') ?? 'null') . "\n";
|
||||
|
||||
// Metadata slug overrides folder name
|
||||
mkdir("$parent/2024-01-15-article");
|
||||
file_put_contents("$parent/2024-01-15-article/metadata.ini", "slug = article\n");
|
||||
echo resolveSlugToFolder($parent, 'article') . "\n";
|
||||
|
||||
// Original folder name still works when no slug conflicts
|
||||
echo resolveSlugToFolder($parent, '2024-01-15-article') . "\n";
|
||||
|
||||
// Metadata slug takes precedence over folder with that name
|
||||
mkdir("$parent/other");
|
||||
file_put_contents("$parent/other/metadata.ini", "slug = my-post\n");
|
||||
// 'my-post' folder exists AND 'other' has slug=my-post — folder name wins (first match)
|
||||
echo resolveSlugToFolder($parent, 'my-post') . "\n";
|
||||
|
||||
array_map('unlink', glob("$parent/2024-01-15-article/*"));
|
||||
rmdir("$parent/2024-01-15-article");
|
||||
array_map('unlink', glob("$parent/other/*"));
|
||||
rmdir("$parent/other");
|
||||
rmdir("$parent/my-post");
|
||||
rmdir($parent);
|
||||
?>
|
||||
--EXPECT--
|
||||
null
|
||||
my-post
|
||||
null
|
||||
2024-01-15-article
|
||||
2024-01-15-article
|
||||
my-post
|
||||
Loading…
Add table
Add a link
Reference in a new issue