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
47
devel/tests/content/find_all_content_files.phpt
Normal file
47
devel/tests/content/find_all_content_files.phpt
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
--TEST--
|
||||
findAllContentFiles: returns sorted content file paths, ignores non-content files and index.php
|
||||
--FILE--
|
||||
<?php
|
||||
require '/var/www/app/constants.php';
|
||||
require '/var/www/app/hooks.php';
|
||||
require '/var/www/app/content.php';
|
||||
|
||||
$dir = sys_get_temp_dir() . '/phpt_content_' . getmypid();
|
||||
mkdir($dir);
|
||||
|
||||
// Non-existent directory
|
||||
echo count(findAllContentFiles($dir . '/nope')) . "\n";
|
||||
|
||||
// Empty directory
|
||||
echo count(findAllContentFiles($dir)) . "\n";
|
||||
|
||||
// Content files
|
||||
file_put_contents("$dir/page.md", '# Hello');
|
||||
file_put_contents("$dir/extra.html", '<p>Hi</p>');
|
||||
file_put_contents("$dir/script.php", '<?php echo "hi";');
|
||||
|
||||
// Non-content files are excluded
|
||||
file_put_contents("$dir/styles.css", 'body {}');
|
||||
file_put_contents("$dir/image.jpg", '');
|
||||
|
||||
// index.php is always excluded
|
||||
file_put_contents("$dir/index.php", '<?php');
|
||||
|
||||
$files = findAllContentFiles($dir);
|
||||
echo count($files) . "\n";
|
||||
|
||||
// Results are full paths, sorted by filename (natural order)
|
||||
foreach ($files as $f) {
|
||||
echo basename($f) . "\n";
|
||||
}
|
||||
|
||||
array_map('unlink', glob("$dir/*"));
|
||||
rmdir($dir);
|
||||
?>
|
||||
--EXPECT--
|
||||
0
|
||||
0
|
||||
3
|
||||
extra.html
|
||||
page.md
|
||||
script.php
|
||||
Loading…
Add table
Add a link
Reference in a new issue