- 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
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
--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
|